Skip to content

ravsrin/serverless-java-frameworks-samples

 
 

Repository files navigation

Lambda demo with common Java application frameworks

Architecture diagram

This is a simple serverless application built in Java using popular frameworks - Micronaut, Quarkus, and Spring Boot

It consists of an Amazon API Gateway backed by four AWS Lambda functions and an Amazon DynamoDB table for storage.

Requirements

Software

Each of the sub folders contains a Products maven project. Each maven project contains all the code for all four Lambda functions. It uses the hexagonal architecture pattern to decouple the entry points, from the main domain logic and the storage logic.

Infrastructure

The sample application can be deployed in three different ways:

  1. Managed Java Runtime (without SnapStart) - This mode uses zip packaging style and runs on the JVM inside the Lambda environment.
  2. Managed Java Runtime (with SnapStart) - This mode enables SnapStart on the Lambda functions. Current examples only include Spring boot version of the application. Stay tuned for other framework examples with SnapStart. Learn more about SnapStart here.
  3. Custom Runtime - This mode uses GraalVM native image and uses Custom Runtime to run on Lambda. GraalVM native image is a stand-alone execution binary and does not require a JVM to run.

Deployment and Testing

Micronaut

Quarkus

Spring Boot

Dagger

Summary

Below is the cold start and warm start latencies observed. Please refer to "Load Test" section of each sub-project for more details. All latencies listed below are in milliseconds.

Artillery is used to make 100 requests / second for 10 minutes to our API endpoints.

Results from Managed Java Runtime without SnapStart

Cold Start (ms) Warm Start (ms)
p50 p90 p99 max p50 p90 p99 max
Micronaut 4898.8332 5479.1013 7551.7604 10147.71 9.3759 17.1385 42.356 531.75
Quarkus 3808.0718 4229.4438 5501.0506 7195.38 8.6605 15.3362 38.5082 375.65
Spring Boot 5517.570 6442.1359 8616.8082 11551.01 9.3759 16.8686 40.3863 319.69
Dagger * 3213.0091 3629.6889 4850.1132 6896.54 8.9399 16.3415 40.3863 292.2
*: Dagger is not fully comparable to other frameworks as it only provides dependency injection, and thus is much lighter than the others, which explains these results. When choosing a framework, be conscious of the features available. Dagger was initially done with Android in mind, to provide a lightweight dependency injection framework, without introspection (like Spring). It fits particularly well with Lambda to reduce the initialization time, but does not provide the breadth of the others.

Results from Managed Java Runtime with SnapStart enabled Lambda functions

Cold Start (ms) Warm Start (ms)
p50 p90 p99 max p50 p90 p99 max
Spring Boot 767.15 868.37 978.05 1271.93 8.07 13.65 28.41 226.37

Results from GraalVM Native images running in custom runtime

Cold Start (ms) Warm Start (ms)
p50 p90 p99 max p50 p90 p99 max
Micronaut 604.16 659.02 700.45 893.70 6.30 8.00 15.88 69.9
Quarkus 437.45 475.76 519.50 528.03 7.45 12.60 21.32 93.45
Spring Boot 620.66 684.53 721.77 751.98 9.10 14.22 23.61 259.16

👀 With other languages

You can find implementations of this project in other languages here:

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 91.0%
  • JavaScript 6.1%
  • Shell 2.9%