Git Product home page Git Product logo

serverless-java-frameworks-samples's Introduction

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 and Quarkus versions 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.83 5479.10 7551.76 10147.71 9.37 17.13 42.35 531.75
Quarkus 2858.41 2980.96 3310.81 4639.79 7.38 12.11 25.00 231.03
Spring Boot 5517.57 6442.13 8616.80 11551.01 9.37 16.86 40.38 319.69
Dagger * 3213.00 3629.68 4850.11 6896.54 8.94 16.34 40.38 292.20
*: 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
Quarkus 367.98 413.63 517.43 573.76 6.66 11.27 21.66 228.24
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.

serverless-java-frameworks-samples's People

Contributors

muraria avatar dmahapatro avatar amazon-auto avatar jeastham1993 avatar jeromevdl avatar maciejwalkowiak avatar urmichm avatar ravsrin avatar maschnetwork avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.