Measuring Java 11 Lambda cold starts with SnapStart - Part 4 Using Spring Boot Framework

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • provided by us. This StreamLambdaHandler implements com.amazonaws.services.lambda.runtime.RequestStreamHandler interface. After this we instatiate SpringBootLambdaContainerHandler handler like this

  • Spring Boot

    Spring Boot

  • Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can "just run". To its features belong:

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • serverless-java-container

    A Java wrapper to run Spring, Spring Boot, Jersey, and other apps inside AWS Lambda.

  • For this we use aws-serverless-java-container-springboot2 project dependency provided in pom.xml. aws-serverless-java-container-springboot2 project is maintained by AWS with the goal to proxy the AWS API Gateway requests between the generic Lambda handler and the appropriate method of the Spring Boot Controller.

  • spring-native

    Discontinued Spring Native is now superseded by Spring Boot 3 official native support

  • It was probably not a very good idea to write Lambda using Java programming language and Spring Boot Framework. Despite the well-spread usage and knowledge of this framework, the fact that Spring (Boot) heavily uses reflection and takes time to start the embedded Web Application Server led to very big cold starts which we'll explore in the next section. But now with SnapStart on AWS and GraalVM Native Image Support we have two more options how to optimize those cold starts. So let's explore how to write Lambda function using the Spring Boot. The code of this sample application (the same as for the first 3 parts but rewritten to use Spring Boot) can be found here. It provides AWS API Gateway and 2 Lambda functions: "CreateProduct" and "GetProductById". The products are stored in the Amazon DynamoDB. We'll use AWS Serverless Application Model (AWS SAM) for the infrastructure as a code.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts