Data API for Amazon Aurora Serverless v2 with AWS SDK for Java - Part 5 Basic cold and warm starts measurements
Tags: aws, serverless, java, database
Published: 2024-04-08 15:52:54

## Introduction

In the [part 1](https://dev.to/aws-builders/data-api-for-amazon-aurora-serverless-v2-with-aws-sdk-for-java-part-1-introduction-and-set-up-of-the-sample-application-3g71) of the series we set up the sample application which has API Gateway in front of Lambda functions which communicate with Aurora Serverless v2 PostgreSQL database via Data API to create the products and retrieve them (by id). In the [part 2](https://dev.to/aws-builders/data-api-for-amazon-aurora-serverless-v2-with-aws-sdk-for-java-part-2-executing-sql-statements-4kon) we dove deeper into the new Data API for Aurora Serverless v2 itself and its capabilities like executing SQL Statements and used AWS SDK for Java for it. In the [part 3](https://dev.to/aws-builders/data-api-for-amazon-aurora-serverless-v2-with-aws-sdk-for-java-part-3-executing-update-and-insert-sql-statements-in-batch-3ajc) we took a look at the Data API capabilities to batch SQL statement over an array of data for bulk update and insert operations. In the [part 4](https://dev.to/aws-builders/data-api-for-amazon-aurora-serverless-v2-with-aws-sdk-for-java-part-4-working-with-database-transactions-555m) we learned how to use database transactions with Data API.
In this part of the series we'll perform some basic measurements of the cold and warm start/execution time of the operation via Data API for Amazon Aurora Serverless v2.

## Measuring cold and warm starts of the operation via Data API for Amazon Aurora Serverless v2

In our experiment we'll re-use the application introduced in the [part 1](https://dev.to/aws-builders/data-api-for-amazon-aurora-serverless-v2-with-aws-sdk-for-java-part-1-introduction-and-set-up-of-the-sample-application-3g71) which source code you can find [here](https://github.com/Vadym79/AWSLambdaJavaAuroraServerlessV2DataApi). There are basically 2 Lambda functions which both respond to the API Gateway requests to store and retrieve product  received from the API Gateway from Amazon PostgreSQL Aurora Serverless v2.

The results of the experiment to retrieve the existing product from the database by its id see [  GetProductByIdViaAuroraServerlessV2DataApiHandler](https://github.com/Vadym79/AWSLambdaJavaAuroraServerlessV2DataApi/blob/master/src/main/java/software/amazonaws/example/product/handler/GetProductByIdViaAuroraServerlessV2DataApiHandler.java) with Lambda function with 1024 MB memory setting were based on reproducing more than 100 cold and approximately 10.000 warm starts with experiment which ran for approximately 1 hour. For it (and experiments from my previous article) I used the load test tool [hey](https://github.com/rakyll/hey), but you can use whatever tool you want, like [Serverless-artillery](https://www.npmjs.com/package/serverless-artillery) or [Postman](https://www.postman.com/). We won't enable SnapStart on the Lambda function first.

**Cold (c) and warm (m) start time in ms:**

|c p50|c p75|c p90|c p99|c p99.9|c max|w p50|w p75 |w p90|w p99|w p99.9|w max|      
|----------|-----------|----------|----------|----------|----------|-----------|----------|----------|----------|----------|----------|
|3154.35|3237|3284.91|3581.49|3702.12|3764.92|104.68|173.96|271.32|572.11|1482.89|2179.7|


## Conclusion

In this part of the series performed some basic measurements of the cold and warm start/execution times of the operation via Data API for Amazon Aurora Serverless v2 without enabling SnapStart on the Lambda function. We observed quite a big cold start times but also the first call additionally results in the bigger warm start (execution time) as the database connection needs to be initialized on the database side. So, especially the very first execution and the subsequent ones where the cold starts occurs together with database connection initialization on the database side are very expensive.  
In the next part of the series we'll perform the measurements but with using the standard connection management  approaches (in case of Java with JDBC) including the usage of Amazon RDS Proxy.