DEV Community

Vadym Kazulkin for AWS Heroes

Posted on

Micronaut 4 application on AWS Lambda- Part 8 Measuring Lambda cold and warm starts with REST API application

In part 6, we learned how to develop a pure Micronaut REST application and deploy it on AWS Lambda.

For the preparation of my talk about developing Serverless Java REST applications on AWS using frameworks such as Micronaut, I found time to measure the performance of the Lambda function with the different approaches (see below). I refer to my articles where we didn't use the Micronaut REST controllers directly, but the pure AWS Lambda functions, to see how we implemented the SnapStart and priming approaches. They look completely the same when using Micronaut REST controllers.

  1. No SnapStart. Please read the article Introduction to the sample application and first Lambda performance measurements.
  2. SnapStart enabled, but no priming applied. Please read the article Reducing Lambda cold starts with Lambda SnapStart.
  3. SnapStart enabled, and DynamoDB request priming applied. Please read the article Reducing Lambda cold starts with SnapStart and DynamoDB request priming.
  4. SnapStart enabled, and API Gateway request event priming applied. Please read the article Reducing Lambda cold starts with SnapStart and API Gateway request event priming.

Cold (c) and warm (w) start time with -XX:+TieredCompilation -XX:TieredStopAtLevel=1 compilation in ms:

Scenario Number 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
No SnapStart enabled 5496 5646 5894 6239 6378 6383 8.00 9.68 13.51 29.40 68.19 1817
SnapStart enabled but no priming applied, all 2064 2116 2185 2260 4007 4009 8.00 9.23 11.34 23.54 49.64 3201
SnapStart enabled but no priming applied, last 70 2042 2100 2166 2262 2262 2262 8.13 9.53 12.09 24.30 48.86 1742
SnapStart enabled and DynamoDB request priming applied, all 849 911 1856 1892 11951 1951 7.75 8.88 10.41 22.19 52.47 1115
SnapStart enabled and DynamoDB request priming applied, last 70 827 862 923 1151 1151 1151 7.87 9.09 10.66 22.73 48.06 449
SnapStart enabled and API Gateway request event priming applied, all 693 741 1443 1457 1460 1461 8.07 9.54 11.73 22.37 61.04 685
SnapStart enabled and API Gateway request event priming applied, last 70 685 728 773 893 893 893 8.33 10.00 12.30 23.28 52.47 240

What we observe is that both cold and warm start times of the sample application using Micronaut REST controllers are generally higher when using the pure AWS Lambda functions. I suspect the reason for it lies in an extra adapter layer used to convert the Lambda request to the REST controller. This adapter uses several extra dependencies, which leads to a much bigger artifact size, which is also one of the factors of the increased cold start times. The advantage of using the REST controller is the ability to more easily migrate the business logic from AWS Lambda to EC2 or Containers.

Top comments (0)