Vadym Kazulkin | @VKazulkin |ip.labs GmbH
High Performance Serverless Java on AWS
Vadym Kazulkin, ip.labs , WeAreDevelopers World Congress, 10 July 2025
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
Vadym Kazulkin
ip.labs GmbH Bonn, Germany
Co-Organizer of the Java User Group Bonn
v.kazulkin@gmail.com
@VKazulkin
https://dev.to/vkazulkin
https://github.com/Vadym79/
https://de.slideshare.net/VadymKazulkin/
https://www.linkedin.com/in/vadymkazulkin
https://www.iplabs.de/
Contact
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
Java Popularity
4 High performance Serverless Java on AWS Vadym Kazulkin | @VKazulkin | ip.labs GmbH
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
5 High performance Serverless Java on AWS
https://distantjob.com/blog/programming-languages-rank/
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
Life of the Java
(Serverless)
Developer
on AWS
6 High performance Serverless Java on AWS
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
▪ Corretto Java 8
▪ With extended long-term support until 2026
▪ Coretto Java 11 (since 2019)
▪ Coretto Java 17 (since April 2023)
▪ Corretto Java 21(since November 2023)
▪ Only Long Term Support (LTS) by AWS
AWS Java Versions Support
High performance Serverless Java on AWS
7
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
… but
serverless
adoption of
Java looks like
this!
9 High performance Serverless Java on AWS
Java is a very
fast and
mature
programming
language…
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
Percent of AWS Lambda Invocations by Language
2021 vs 2023
High performance Serverless Java on AWS
10
https://www.datadoghq.com/state-of-serverless-2021
https://www.datadoghq.com/state-of-serverless/
PHYTON IS THE
MOST POPULAR
LAMDA
RUNTIME
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
Developers love Java and will be happy
to use it for Serverless applications
But what are the challenges ?
High performance Serverless Java on AWS
11
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
▪ “cold start” times (latencies)
▪ memory footprint (high cost in AWS)
Serverless with Java Challenges
High performance Serverless Java on AWS
12
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
Demo Application
High performance Serverless Java on AWS
13
https://github.com/Vadym79/AWSLambdaJavaSnapStart
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
AWS Lambda
Basics
14 High performance Serverless Java on AWS
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
AWS Lambda
High performance Serverless Java on AWS
15
▪ Runs code without provisioning or
managing servers
▪ Runs your code on a high-availability
compute infrastructure and manages
all the computing resources, including
server and operating system
maintenance, capacity provisioning,
automatic scaling, and logging
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
Creating AWS Lambda with Java runtime
High performance Serverless Java on AWS
16
Full CPU access only
approx. at 1.8 GB
memory allocated
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
Creating AWS Lambda with Java runtime
High performance Serverless Java on AWS
17
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
Amazon API Gateway
High performance Serverless Java on AWS
18
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
Amazon API Gateway
High performance Serverless Java on AWS
19
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
public class GetProductByIdHandler implements
RequestHandler<APIGatewayProxyRequestEvent, Optional<Product>> {
private static final ProductDao productDao = new DynamoProductDao();
@Override
public Optional<Product> handleRequest(APIGatewayProxyRequestEvent event,
Context context) {
String id = event.getPathParameters().get("id");
return productDao.getProduct(id);
}}
AWS Lambda Function with Java runtime
How to develop, run and optimize Spring Boot 3 application on AWS Lambda
20
Invocation of the
handeRequest method is
the warm start
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
21
https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-input-format
API Gateway Proxy Request Event JSON
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
Amazon DynamoDB
High performance Serverless Java on AWS
22
▪ Amazon DynamoDB is a serverless,
NoSQL, fully managed database with
single-digit millisecond performance at
any scale.
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
23 High performance Serverless Java on AWS
Challenge No. 1
A Big Cold-Start
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
Lambda function lifecycle – a full cold start
How to develop, run and optimize Spring Boot 3 application on AWS Lambda
24
Sources: Ajay Nair „Become a Serverless Black Belt” https://www.youtube.com/watch?v=oQFORsso2go
Tomasz Łakomy "Notes from Optimizing Lambda Performance for Your Serverless Applications“ https://tlakomy.com/optimizing-lambda-performance-for-serverless-applications
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
▪ Start Firecracker VM (execution environment)
▪ AWS Lambda starts the Java runtime
▪ Java runtime loads and initializes Lambda function code
(Lambda handler Java class)
▪ Class loading
▪ Static initializer block of the handler class is executed (i.e. AWS service client
creation)
▪ Runtime dependency injection
▪ Just-in-Time (JIT) compilation
▪ Lambda invokes the handler method
High performance Serverless Java on AWS
25
Sources: Ajay Nair „Become a Serverless Black Belt” https://www.youtube.com/watch?v=oQFORsso2go
Tomasz Łakomy "Notes from Optimizing Lambda Performance for Your Serverless Applications“ https://tlakomy.com/optimizing-lambda-performance-for-serverless-applications
Michael Hart: „Shave 99.93% off your Lambda bill with this one weird trick“ https://hichaelmart.medium.com/shave-99-93-off-your-lambda-bill-with-this-one-weird-trick-33c0acebb2ea
Lambda function lifecycle
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
Demo Application
High performance Serverless Java on AWS
26
https://github.com/Vadym79/AWSLambdaJavaSnapStart
▪ Lambda has 1024 MB memory setting
▪ Lambda uses x86 architecture
▪ Default (Apache) Http Client for
communication with DynamoDB
▪ 14 MB artifact size, , all dependencies in
the POM file
▪ Java compilation option -
XX:+TieredCompilation -
XX:TieredStopAtLevel=1
▪ Info about the experiments:
▪ Approx. 1 hour duration
▪ Approx. first* 100 cold starts
▪ Approx. first 100.000 warm starts
*after Lambda function being re-deployed
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
https://dev.to/aws-builders/aws-snapstart-part-13-measuring-warm-starts-with-java-21-using-different-lambda-memory-settings-160k
Measurements in
ms
p50 p75 p90 p99 p99.9 max
Amazon Corretto
Java 21 cold start
3158 3214 3270 3428 3601 3725
Amazon Corretto
Java 21 warm start
5,77 6,50 7,81 20,65 90,20 1423,63
Cold and warm starts with Java 21
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
▪ AWS SnapStart
▪ GraalVM (Native Image)
Options To Reduce Cold Start Time
High performance Serverless Java on AWS
30
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
AWS Lambda
SnapStart
31 How to develop, run and optimize Spring Boot 3 application on AWS Lambda
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
„AWS Lambda SnapStart „ series
How to develop, run and optimize Spring Boot 3 application on AWS Lambda
33
https://dev.to/vkazulkin/series/24979
Article series covers they why and what
behind Lambda SnapStart and priming
techniques including measurements for cold
and warm starts with different settings for
▪ Java 11
▪ Java 17
▪ Java 21
▪ Micronaut
▪ Quarkus
▪ Spring Boot 2.7
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
▪ Lambda SnapStart for Java can improve startup performance for latency-
sensitive applications
▪ SnapStart is fully managed
AWS Lambda SnapStart
How to develop, run and optimize Spring Boot 3 application on AWS Lambda
34
https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
▪ Currently available for Lambda managed Java Runtimes (Java 11, 17 and 21),
Python and .NET
▪ Not available for all other Lambda runtimes:
▪ Docker Container Image
▪ Custom (Lambda) Runtime (a way to ship GraalVM Native Image)
AWS Lambda SnapStart
35
https://github.com/Vadym79/AWSLambdaJavaDockerImage/
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
AWS SnapStart Deployment & Invocation
36
https://aws.amazon.com/de/blogs/compute/reducing-java-cold-starts-on-aws-lambda-functions-with-snapstart/
Vadym Kazulkin @VKazulkin , ip.labs GmbH
C
Create
Snapshot
Firecracker microVM
create & restore
snapshot
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
▪ Linux CRIU available since 2012 allows a running application to be paused and restarted at some
point later in time, potentially on a different machine.
▪ The overall goal of the project is to support the migration of containers.
▪ When performing a checkpoint, essentially, the full context of the process is saved: program
counter, registers, stacks, memory-mapped and shared memory
▪ To restore the application, all this data can be reloaded and (theoretically) it continues from the
same point.
▪ Challenges
▪ open files
▪ network connections
▪ sudden change in the value of the system clock
▪ time-based caches
CRIU (Checkpoint/Restore in Userspace)
37
https://criu.org/Main_Page
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
▪ Comparing Firecracker and CRIU snapshotting:
▪ Firecracker snapshotting saves a whole running OS
▪ CRIU snapshotting saves a single process or container
▪ Advantages of the Firecracker snapshot : we don't have to care about
file handles because they will be still valid after resume.
▪ Drawbacks the Firecracker snapshot : the need to reseed /dev/random
and to sync the system clock.
Snapshot /checkpointing and restore
Firecracker microVM vs CRIU
40
https://mail.openjdk.org/pipermail/discuss/2021-July/005864.html
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
AWS SnapStart Deployment & Invocation
How to develop, run and optimize Spring Boot 3 application on AWS Lambda
41
https://dev.to/vkazulkin/measuring-java-11-lambda-cold-starts-with-snapstart-part-1-first-impressions-30a4
https://aws.amazon.com/de/blogs/compute/using-aws-lambda-snapstart-with-infrastructure-as-code-and-ci-cd-pipelines/
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
AWS Lambda SnapStart with Priming
44
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
▪ Pre-load as many Java classes as possible before the SnapStart
takes the snapshot
▪ Java loads classes on demand (lazy-loading)
▪ Pre-initialize as much as possible before the SnapStart takes the
snapshot
▪ Http Clients (Apache, UrlConnection) and JSON Marshallers (Jackson)
require expensive one-time initialization per (Lambda) lifecycle. They both
are used when creating Amazon DynamoDbClient
Ideas behind priming
45
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
AWS SnapStart Deployment & Invocation
High performance Serverless Java on AWS
46
https://aws.amazon.com/de/blogs/compute/reducing-java-cold-starts-on-aws-lambda-functions-with-snapstart/
Vadym Kazulkin @VKazulkin , ip.labs GmbH
Lambda uses the
CRaC APIs for
runtime hooks
for Priming
C
Create
Snapshot
Firecracker microVM
create & restore snapshot
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
▪ Prime dependencies during initialization phase (when it worth doing)
▪ „Fake“ the calls to pre-initialize „some other expensive stuff“ (this technique is called
Priming)
▪ In case of DynamoDB client put the following code outside of the handler method to
pre-initialize the HTTP Client and Jackson Marshaller:
DynamoDbClient client = DynamoDbClientBuilder.builder().region(Regions.US_WEST_2).build();
GetItemResponse getItemResponse = client.getItem(GetItemRequest.builder()
.key(Map.of("PK", AttributeValue.builder().s(id).build()))
.tableName(PRODUCT_TABLE_NAME).build());
……
Best Practices & Recommendations
How to develop, run and optimize Spring Boot 3 application on AWS Lambda
47
invocation forces HTTP Client and Jackson
Marshallers to pre-initialize
getProductById (int id)
method
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
AWS SnapStart Enabled with Java Priming
High performance Serverless Java on AWS
48
https://dev.to/aws-builders/measuring-java-11-lambda-cold-starts-with-snapstart-part-5-priming-end-to-end-latency-and-deployment-time-jem
<dependency>
<groupId>io.github.crac</groupId>
<artifactId>org-crac</artifactId>
<version>0.1.3</version>
</dependency>
if a refer to Priming in this
talk, I mean concretely
DynamoDB request
invocation priming
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
Lambda SnapStart Priming Guide
High performance Serverless Java on AWS
49
guide aims to explain techniques
for priming Java applications.
It assumes a base understanding
of AWS Lambda, Lambda
SnapStart, and CRaC.
https://github.com/marksailes/snapstart-priming-guide
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
0
500
1000
1500
2000
2500
3000
3500
4000
w/o SnapStart with SnapStart w/o Priming with SnapStart with Priming
Cold starts of Lambda function with Java 21 runtime with
1024 MB memory setting, Apache Http Client, compilation
-XX:+TieredCompilation -XX:TieredStopAtLevel=1
p50 p75 p90 p99 p99.9 max
https://dev.to/aws-builders/aws-snapstart-part-13-measuring-warm-starts-with-java-21-using-different-lambda-memory-settings-160k
ms
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
0,00
5,00
10,00
15,00
20,00
25,00
w/o SnapStart with SnapStart w/o Priming with SnapStart with Priming
Warm starts of Lambda function with Java 21 runtime with
1024 MB memory setting, Apache Http Client compilation -
XX:+TieredCompilation -XX:TieredStopAtLevel=1
p50 p75 p90 p99
https://dev.to/aws-builders/aws-snapstart-part-13-measuring-warm-starts-with-java-21-using-different-lambda-memory-settings-160k
ms
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
0
200
400
600
800
1000
1200
1400
1600
w/o SnapStart with SnapStart w/o Priming with SnapStart with Priming
Warm starts of Lambda function with Java 21 runtime with
1024 MB memory setting, Apache Http Client compilation -
XX:+TieredCompilation -XX:TieredStopAtLevel=1
p99.9 max
https://dev.to/aws-builders/aws-snapstart-part-13-measuring-warm-starts-with-java-21-using-different-lambda-memory-settings-160k
ms
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
Demo Application
High performance Serverless Java on AWS
53
https://github.com/Vadym79/AWSLambdaJavaSnapStart
▪ Lambda has 1024 MB memory setting
▪ Lambda uses x86 architecture
▪ Default (Apache) Http Client for
communication with DynamoDB
▪ 18 MB artifact size, , all dependencies in
the POM file
▪ Java compilation option -
XX:+TieredCompilation -
XX:TieredStopAtLevel=1
▪ Info about the experiments:
▪ Approx. 1 hour duration
▪ Approx. first* 100 cold starts
▪ Approx. first 100.000 warm starts
*after Lambda function being re-deployed
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
Demo Application
High performance Serverless Java on AWS
92
https://github.com/Vadym79/AWSLambdaJavaSnapStart
▪ Lambda has 1024 MB memory setting
▪ Lambda uses x86 architecture
▪ Default (Apache) Http Client for
communication with DynamoDB
▪ 14 MB artifact size, all dependencies in the
POM file
▪ Java compilation option -
XX:+TieredCompilation -
XX:TieredStopAtLevel=1
▪ Info about the experiments:
▪ Approx. 1 hour duration
▪ Approx. first* 100 cold starts
▪ Approx. first 100.000 warm starts
*after Lambda function being re-deployed
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
AWS SnapStart Deployment & Invocation
High performance Serverless Java on AWS
93
https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html
https://aws.amazon.com/de/blogs/compute/reducing-java-cold-starts-on-aws-lambda-functions-with-snapstart/
Firecracker microVM
create & restore
snapshot
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
AWS SnapStart tiered cache
How to develop, run and optimize Spring Boot 3 application on AWS Lambda
94
https://dev.to/aws-builders/aws-snapstart-part-17-impact-of-the-snapshot-tiered-cache-on-the-cold-starts-with-java-21-52ef
• Due to the effect of
snapshot tiered cache, cold
start times reduces with the
number of invocations
• After certain number of
invocations reached the
cold start times becomes
stable
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
AWS Lambda under the Hood
High performance Serverless Java on AWS
95
https://www.infoq.com/articles/aws-lambda-under-the-hood/
https://www.infoq.com/presentations/aws-lambda-arch/
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
0
500
1000
1500
2000
2500
with SnapStart w/o Primingwith SnapStart w/o Priming
(last 70)
with SnapStart with
Priming
with SnapStart with
Priming (last 70)
Cold starts of all approx.100 and last 70 Lambda functions with
Java 21 runtime with
1024 MB memory setting, Apache Http Client, compilation
-XX:+TieredCompilation -XX:TieredStopAtLevel=1
p50 p75 p90 p99 p99.9 max
https://dev.to/aws-builders/aws-snapstart-part-17-impact-of-the-snapshot-tiered-cache-on-the-cold-starts-with-java-21-52ef
Due to the effect of
snapshot tiered cache,
cold start times
reduces with the
number of invocations
ms
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
AWS Lambda Profiler Extension for Java
High performance Serverless Java on AWS
97
https://github.com/aws/aws-lambda-java-libs/tree/main/experimental/aws-lambda-java-profiler
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
AWS Lambda Implementation
High performance Serverless Java on AWS
98
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
99
https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-input-format
API Gateway Proxy Request Event JSON
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
AWS Lambda Profiler Extension for Java
High performance Serverless Java on AWS
100
https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-input-format
https://github.com/aws/aws-lambda-java-libs/tree/main/experimental/aws-lambda-java-profiler
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
Full Priming including APIGatewayProxyRequestEvent
High performance Serverless Java on AWS
101
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
Full Priming including APIGatewayProxyRequestEvent
Deserialization
High performance Serverless Java on AWS
102
https://dev.to/aws-heroes/aws-lambda-profiler-extension-for-java-part-2-improving-lambda-performance-with-lambda-snapstart-4p06
This priming technique leads to up to
25% reduction of the cold start times vs.
DynamoDB request priming alone
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
AWS SnapStart Pricing
103
https://aws.amazon.com/lambda/pricing/?nc1=h_ls
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
▪ SnapStart supports the Java 11, 17 and 21 (Corretto), Python and .NET
managed runtime only
▪ Deployment with SnapStart enabled takes more than 2-2,5 minutes
additionally
▪ Snapshot is deleted from cache if Lambda function is not invoked for 14
days
▪ SnapStart currently does not support :
▪ Provisioned concurrency
▪ Amazon Elastic File System (Amazon EFS)
▪ Ephemeral storage greater than 512 MB
AWS SnapStart Challenges & Limitations
104
https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
108 High performance Serverless Java on AWS
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
GraalVM Architecture
High performance Serverless Java on AWS
110
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
GraalVM Ahead-of-Time Compilation
High performance Serverless Java on AWS
111
Source: Oleg Šelajev, Thomas Wuerthinger, Oracle: “Deep dive into using GraalVM for Java and JavaScript”
https://www.youtube.com/watch?v=a-XEZobXspo
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
Promise: Java Function compiled into a native executable
using GraalVM Native Image significantly reduces
▪ “cold start” times
▪ memory footprint
GraalVM Native Image
113
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
▪ AWS doesn’t provide GraalVM (Native Image) as Java Runtime out of the box
▪ AWS provides Custom Runtime Option
Current Challenges with Native Executable using
GraalVM
High performance Serverless Java on AWS
114
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
Custom Lambda Runtimes
High performance Serverless Java on AWS
115
https://github.com/Vadym79/AWSLambdaGraalVMNativeImage
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
0
500
1000
1500
2000
2500
3000
3500
4000
w/o SnapStart with SnapStart w/o Priming with SnapStart with
Priming
GraalVM 23 Native Image
p50 p75 p90 p99 p99.9 max
https://dev.to/aws-builders/aws-snapstart-part-13-measuring-warm-starts-with-java-21-using-different-lambda-memory-settings-160k
ms
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
0,00
5,00
10,00
15,00
20,00
25,00
w/o SnapStart with SnapStart w/o
Priming
with SnapStart with
Priming
GraalVM 23 Native Image
p50 p75 p90 p99
https://dev.to/aws-builders/aws-snapstart-part-13-measuring-warm-starts-with-java-21-using-different-lambda-memory-settings-160k
ms
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
0
200
400
600
800
1000
1200
1400
1600
w/o SnapStart with SnapStart w/o Priming with SnapStart with
Priming
GraalVM Native Image 23
p99.9 max
https://dev.to/aws-builders/aws-snapstart-part-13-measuring-warm-starts-with-java-21-using-different-lambda-memory-settings-160k
ms
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
Frameworks and libraries Ready for GraalVM Native Image
High performance Serverless Java on AWS
126
https://www.graalvm.org/native-image/libraries-and-frameworks/
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
▪ You can run into errors when application
is running
Complex GraalVM Native Image configuration
High performance Serverless Java on AWS
127
https://github.com/Vadym79/AWSLambdaGraalVMNativeImage/blob/master/pure-lambda-graalvm-jdk-21-native-image/src/main/reflect.json
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
Assisted Configuration with GraalVM Tracing Agent
High performance Serverless Java on AWS
131
https://www.graalvm.org/latest/reference-manual/native-image/metadata/AutomaticMetadataCollection/
https://www.graalvm.org/latest/reference-manual/native-image/guides/configure-with-tracing-agent/
Run the GraalVM tracing
agent during the
execution of your tests
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
▪ GraalVM is really powerful and has a lot of potential
▪ GraalVM Native Image improves cold starts and memory footprint
significantly
▪ GraalVM Native Image is currently not without challenges
▪ Complex GraalVM Native Image configuration files
▪ AWS Lambda Custom Runtime requires Linux executable only
▪ Building Custom Runtime requires some additional effort
▪ e.g. you need a scalable CI/CD pipeline to build memory-intensive native
image
▪ Build time is a factor
▪ You need to carefully test to avoid runtime errors
GraalVM Conclusion
132
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
“Spring Boot 3.4 application on AWS Lambda” series
143
Article series covers different
ways to write Spring Boot 3.4
application on AWS Lambda
▪ AWS Serverless Java Container
▪ AWS Lambda Web Adapter
▪ Spring Cloud Functions
▪ Custom Docker Image
▪ GraalVM Native Image
Cold and warm start time
measurements are also provided
https://dev.to/vkazulkin/series/30408
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
“Quarkus 3 application on AWS Lambda” series
144
Article series covers different
ways to write, run and optimize
Quarkus 3 application on AWS
Lambda using:
▪ Managed Java 21 Lambda
runtime
▪ GraalVM Native Image
Cold and warm start time
measurements are also provided
https://dev.to/vkazulkin/series/31519
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
Experiment with:
▪ Lambda memory settings
▪ Java compilation options
▪ HTTP Client implementations (sync and async)
▪ Lambda architecture
▪ Lambda SnapStart (with priming techniques) and GraalVM Native Image
To find the right trade-off between Lambda cost and performance for your
particular use case
Wrap up
How to develop, run and optimize Spring Boot 3 application on AWS Lambda
145
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
▪ With AWS SnapStart and GraalVM Native Image you can reduce cold
start times of the AWS Lambda with Java 21 runtime to the acceptable
values
▪ If you’re willing to accept slightly higher cold and warm start times for
certain the Lambda function(s) and solid priming is applicable -> use fully
managed AWS SnapStart with priming
▪ If a very high performance for certain the Lambda function(s) is really
crucial for your business -> go for GraalVM Native Image
Wrap up and personal suggestions
How to develop, run and optimize Spring Boot 3 application on AWS Lambda
146
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
Project Leyden
High performance Serverless Java on AWS
147
The primary goal of
this Project is to
improve the startup
time, time to peak
performance, and
footprint of Java
programs.
https://www.youtube.com/watch?v=teXijm79vno
https://openjdk.org/projects/leyden/
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
Word of caution
High performance Serverless Java on AWS
148
Re-measure for your use case!
Even with my examples measurements might
already produce different results due to:
▪ Lambda Amazon Corretto Java 21 managed
runtime minor version changes
▪ Lambda SnapStart snapshot create and
restore improvements
▪ Firecracker VM improvements
▪ Dependencies updates (impacts its size)
▪ GraalVM (major and minor version) and
Native Image improvements
▪ There are still servers behind Lambda
▪ Java Memory Model impact (L or RAM
caches hits and misses)
Vadym Kazulkin | @VKazulkin |ip.labs GmbH
149 High performance Serverless Java on AWS
Thank you

High performance Serverless Java on AWS-We Are Developers 2025

  • 1.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH High Performance Serverless Java on AWS Vadym Kazulkin, ip.labs , WeAreDevelopers World Congress, 10 July 2025
  • 2.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH Vadym Kazulkin ip.labs GmbH Bonn, Germany Co-Organizer of the Java User Group Bonn v.kazulkin@gmail.com @VKazulkin https://dev.to/vkazulkin https://github.com/Vadym79/ https://de.slideshare.net/VadymKazulkin/ https://www.linkedin.com/in/vadymkazulkin https://www.iplabs.de/ Contact
  • 3.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH Java Popularity 4 High performance Serverless Java on AWS Vadym Kazulkin | @VKazulkin | ip.labs GmbH
  • 4.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH 5 High performance Serverless Java on AWS https://distantjob.com/blog/programming-languages-rank/
  • 5.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH Life of the Java (Serverless) Developer on AWS 6 High performance Serverless Java on AWS
  • 6.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH ▪ Corretto Java 8 ▪ With extended long-term support until 2026 ▪ Coretto Java 11 (since 2019) ▪ Coretto Java 17 (since April 2023) ▪ Corretto Java 21(since November 2023) ▪ Only Long Term Support (LTS) by AWS AWS Java Versions Support High performance Serverless Java on AWS 7
  • 7.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH … but serverless adoption of Java looks like this! 9 High performance Serverless Java on AWS Java is a very fast and mature programming language…
  • 8.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH Percent of AWS Lambda Invocations by Language 2021 vs 2023 High performance Serverless Java on AWS 10 https://www.datadoghq.com/state-of-serverless-2021 https://www.datadoghq.com/state-of-serverless/ PHYTON IS THE MOST POPULAR LAMDA RUNTIME
  • 9.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH Developers love Java and will be happy to use it for Serverless applications But what are the challenges ? High performance Serverless Java on AWS 11
  • 10.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH ▪ “cold start” times (latencies) ▪ memory footprint (high cost in AWS) Serverless with Java Challenges High performance Serverless Java on AWS 12
  • 11.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH Demo Application High performance Serverless Java on AWS 13 https://github.com/Vadym79/AWSLambdaJavaSnapStart
  • 12.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH AWS Lambda Basics 14 High performance Serverless Java on AWS
  • 13.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH AWS Lambda High performance Serverless Java on AWS 15 ▪ Runs code without provisioning or managing servers ▪ Runs your code on a high-availability compute infrastructure and manages all the computing resources, including server and operating system maintenance, capacity provisioning, automatic scaling, and logging
  • 14.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH Creating AWS Lambda with Java runtime High performance Serverless Java on AWS 16 Full CPU access only approx. at 1.8 GB memory allocated
  • 15.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH Creating AWS Lambda with Java runtime High performance Serverless Java on AWS 17
  • 16.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH Amazon API Gateway High performance Serverless Java on AWS 18
  • 17.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH Amazon API Gateway High performance Serverless Java on AWS 19
  • 18.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH public class GetProductByIdHandler implements RequestHandler<APIGatewayProxyRequestEvent, Optional<Product>> { private static final ProductDao productDao = new DynamoProductDao(); @Override public Optional<Product> handleRequest(APIGatewayProxyRequestEvent event, Context context) { String id = event.getPathParameters().get("id"); return productDao.getProduct(id); }} AWS Lambda Function with Java runtime How to develop, run and optimize Spring Boot 3 application on AWS Lambda 20 Invocation of the handeRequest method is the warm start
  • 19.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH 21 https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-input-format API Gateway Proxy Request Event JSON
  • 20.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH Amazon DynamoDB High performance Serverless Java on AWS 22 ▪ Amazon DynamoDB is a serverless, NoSQL, fully managed database with single-digit millisecond performance at any scale.
  • 21.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH 23 High performance Serverless Java on AWS Challenge No. 1 A Big Cold-Start
  • 22.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH Lambda function lifecycle – a full cold start How to develop, run and optimize Spring Boot 3 application on AWS Lambda 24 Sources: Ajay Nair „Become a Serverless Black Belt” https://www.youtube.com/watch?v=oQFORsso2go Tomasz Łakomy "Notes from Optimizing Lambda Performance for Your Serverless Applications“ https://tlakomy.com/optimizing-lambda-performance-for-serverless-applications
  • 23.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH ▪ Start Firecracker VM (execution environment) ▪ AWS Lambda starts the Java runtime ▪ Java runtime loads and initializes Lambda function code (Lambda handler Java class) ▪ Class loading ▪ Static initializer block of the handler class is executed (i.e. AWS service client creation) ▪ Runtime dependency injection ▪ Just-in-Time (JIT) compilation ▪ Lambda invokes the handler method High performance Serverless Java on AWS 25 Sources: Ajay Nair „Become a Serverless Black Belt” https://www.youtube.com/watch?v=oQFORsso2go Tomasz Łakomy "Notes from Optimizing Lambda Performance for Your Serverless Applications“ https://tlakomy.com/optimizing-lambda-performance-for-serverless-applications Michael Hart: „Shave 99.93% off your Lambda bill with this one weird trick“ https://hichaelmart.medium.com/shave-99-93-off-your-lambda-bill-with-this-one-weird-trick-33c0acebb2ea Lambda function lifecycle
  • 24.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH Demo Application High performance Serverless Java on AWS 26 https://github.com/Vadym79/AWSLambdaJavaSnapStart ▪ Lambda has 1024 MB memory setting ▪ Lambda uses x86 architecture ▪ Default (Apache) Http Client for communication with DynamoDB ▪ 14 MB artifact size, , all dependencies in the POM file ▪ Java compilation option - XX:+TieredCompilation - XX:TieredStopAtLevel=1 ▪ Info about the experiments: ▪ Approx. 1 hour duration ▪ Approx. first* 100 cold starts ▪ Approx. first 100.000 warm starts *after Lambda function being re-deployed
  • 25.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH https://dev.to/aws-builders/aws-snapstart-part-13-measuring-warm-starts-with-java-21-using-different-lambda-memory-settings-160k Measurements in ms p50 p75 p90 p99 p99.9 max Amazon Corretto Java 21 cold start 3158 3214 3270 3428 3601 3725 Amazon Corretto Java 21 warm start 5,77 6,50 7,81 20,65 90,20 1423,63 Cold and warm starts with Java 21
  • 26.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH ▪ AWS SnapStart ▪ GraalVM (Native Image) Options To Reduce Cold Start Time High performance Serverless Java on AWS 30
  • 27.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH AWS Lambda SnapStart 31 How to develop, run and optimize Spring Boot 3 application on AWS Lambda
  • 28.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH „AWS Lambda SnapStart „ series How to develop, run and optimize Spring Boot 3 application on AWS Lambda 33 https://dev.to/vkazulkin/series/24979 Article series covers they why and what behind Lambda SnapStart and priming techniques including measurements for cold and warm starts with different settings for ▪ Java 11 ▪ Java 17 ▪ Java 21 ▪ Micronaut ▪ Quarkus ▪ Spring Boot 2.7
  • 29.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH ▪ Lambda SnapStart for Java can improve startup performance for latency- sensitive applications ▪ SnapStart is fully managed AWS Lambda SnapStart How to develop, run and optimize Spring Boot 3 application on AWS Lambda 34 https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html
  • 30.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH ▪ Currently available for Lambda managed Java Runtimes (Java 11, 17 and 21), Python and .NET ▪ Not available for all other Lambda runtimes: ▪ Docker Container Image ▪ Custom (Lambda) Runtime (a way to ship GraalVM Native Image) AWS Lambda SnapStart 35 https://github.com/Vadym79/AWSLambdaJavaDockerImage/
  • 31.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH AWS SnapStart Deployment & Invocation 36 https://aws.amazon.com/de/blogs/compute/reducing-java-cold-starts-on-aws-lambda-functions-with-snapstart/ Vadym Kazulkin @VKazulkin , ip.labs GmbH C Create Snapshot Firecracker microVM create & restore snapshot
  • 32.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH ▪ Linux CRIU available since 2012 allows a running application to be paused and restarted at some point later in time, potentially on a different machine. ▪ The overall goal of the project is to support the migration of containers. ▪ When performing a checkpoint, essentially, the full context of the process is saved: program counter, registers, stacks, memory-mapped and shared memory ▪ To restore the application, all this data can be reloaded and (theoretically) it continues from the same point. ▪ Challenges ▪ open files ▪ network connections ▪ sudden change in the value of the system clock ▪ time-based caches CRIU (Checkpoint/Restore in Userspace) 37 https://criu.org/Main_Page
  • 33.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH ▪ Comparing Firecracker and CRIU snapshotting: ▪ Firecracker snapshotting saves a whole running OS ▪ CRIU snapshotting saves a single process or container ▪ Advantages of the Firecracker snapshot : we don't have to care about file handles because they will be still valid after resume. ▪ Drawbacks the Firecracker snapshot : the need to reseed /dev/random and to sync the system clock. Snapshot /checkpointing and restore Firecracker microVM vs CRIU 40 https://mail.openjdk.org/pipermail/discuss/2021-July/005864.html
  • 34.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH AWS SnapStart Deployment & Invocation How to develop, run and optimize Spring Boot 3 application on AWS Lambda 41 https://dev.to/vkazulkin/measuring-java-11-lambda-cold-starts-with-snapstart-part-1-first-impressions-30a4 https://aws.amazon.com/de/blogs/compute/using-aws-lambda-snapstart-with-infrastructure-as-code-and-ci-cd-pipelines/
  • 35.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH AWS Lambda SnapStart with Priming 44
  • 36.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH ▪ Pre-load as many Java classes as possible before the SnapStart takes the snapshot ▪ Java loads classes on demand (lazy-loading) ▪ Pre-initialize as much as possible before the SnapStart takes the snapshot ▪ Http Clients (Apache, UrlConnection) and JSON Marshallers (Jackson) require expensive one-time initialization per (Lambda) lifecycle. They both are used when creating Amazon DynamoDbClient Ideas behind priming 45
  • 37.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH AWS SnapStart Deployment & Invocation High performance Serverless Java on AWS 46 https://aws.amazon.com/de/blogs/compute/reducing-java-cold-starts-on-aws-lambda-functions-with-snapstart/ Vadym Kazulkin @VKazulkin , ip.labs GmbH Lambda uses the CRaC APIs for runtime hooks for Priming C Create Snapshot Firecracker microVM create & restore snapshot
  • 38.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH ▪ Prime dependencies during initialization phase (when it worth doing) ▪ „Fake“ the calls to pre-initialize „some other expensive stuff“ (this technique is called Priming) ▪ In case of DynamoDB client put the following code outside of the handler method to pre-initialize the HTTP Client and Jackson Marshaller: DynamoDbClient client = DynamoDbClientBuilder.builder().region(Regions.US_WEST_2).build(); GetItemResponse getItemResponse = client.getItem(GetItemRequest.builder() .key(Map.of("PK", AttributeValue.builder().s(id).build())) .tableName(PRODUCT_TABLE_NAME).build()); …… Best Practices & Recommendations How to develop, run and optimize Spring Boot 3 application on AWS Lambda 47 invocation forces HTTP Client and Jackson Marshallers to pre-initialize getProductById (int id) method
  • 39.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH AWS SnapStart Enabled with Java Priming High performance Serverless Java on AWS 48 https://dev.to/aws-builders/measuring-java-11-lambda-cold-starts-with-snapstart-part-5-priming-end-to-end-latency-and-deployment-time-jem <dependency> <groupId>io.github.crac</groupId> <artifactId>org-crac</artifactId> <version>0.1.3</version> </dependency> if a refer to Priming in this talk, I mean concretely DynamoDB request invocation priming
  • 40.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH Lambda SnapStart Priming Guide High performance Serverless Java on AWS 49 guide aims to explain techniques for priming Java applications. It assumes a base understanding of AWS Lambda, Lambda SnapStart, and CRaC. https://github.com/marksailes/snapstart-priming-guide
  • 41.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH 0 500 1000 1500 2000 2500 3000 3500 4000 w/o SnapStart with SnapStart w/o Priming with SnapStart with Priming Cold starts of Lambda function with Java 21 runtime with 1024 MB memory setting, Apache Http Client, compilation -XX:+TieredCompilation -XX:TieredStopAtLevel=1 p50 p75 p90 p99 p99.9 max https://dev.to/aws-builders/aws-snapstart-part-13-measuring-warm-starts-with-java-21-using-different-lambda-memory-settings-160k ms
  • 42.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH 0,00 5,00 10,00 15,00 20,00 25,00 w/o SnapStart with SnapStart w/o Priming with SnapStart with Priming Warm starts of Lambda function with Java 21 runtime with 1024 MB memory setting, Apache Http Client compilation - XX:+TieredCompilation -XX:TieredStopAtLevel=1 p50 p75 p90 p99 https://dev.to/aws-builders/aws-snapstart-part-13-measuring-warm-starts-with-java-21-using-different-lambda-memory-settings-160k ms
  • 43.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH 0 200 400 600 800 1000 1200 1400 1600 w/o SnapStart with SnapStart w/o Priming with SnapStart with Priming Warm starts of Lambda function with Java 21 runtime with 1024 MB memory setting, Apache Http Client compilation - XX:+TieredCompilation -XX:TieredStopAtLevel=1 p99.9 max https://dev.to/aws-builders/aws-snapstart-part-13-measuring-warm-starts-with-java-21-using-different-lambda-memory-settings-160k ms
  • 44.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH Demo Application High performance Serverless Java on AWS 53 https://github.com/Vadym79/AWSLambdaJavaSnapStart ▪ Lambda has 1024 MB memory setting ▪ Lambda uses x86 architecture ▪ Default (Apache) Http Client for communication with DynamoDB ▪ 18 MB artifact size, , all dependencies in the POM file ▪ Java compilation option - XX:+TieredCompilation - XX:TieredStopAtLevel=1 ▪ Info about the experiments: ▪ Approx. 1 hour duration ▪ Approx. first* 100 cold starts ▪ Approx. first 100.000 warm starts *after Lambda function being re-deployed
  • 45.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH Demo Application High performance Serverless Java on AWS 92 https://github.com/Vadym79/AWSLambdaJavaSnapStart ▪ Lambda has 1024 MB memory setting ▪ Lambda uses x86 architecture ▪ Default (Apache) Http Client for communication with DynamoDB ▪ 14 MB artifact size, all dependencies in the POM file ▪ Java compilation option - XX:+TieredCompilation - XX:TieredStopAtLevel=1 ▪ Info about the experiments: ▪ Approx. 1 hour duration ▪ Approx. first* 100 cold starts ▪ Approx. first 100.000 warm starts *after Lambda function being re-deployed
  • 46.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH AWS SnapStart Deployment & Invocation High performance Serverless Java on AWS 93 https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html https://aws.amazon.com/de/blogs/compute/reducing-java-cold-starts-on-aws-lambda-functions-with-snapstart/ Firecracker microVM create & restore snapshot
  • 47.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH AWS SnapStart tiered cache How to develop, run and optimize Spring Boot 3 application on AWS Lambda 94 https://dev.to/aws-builders/aws-snapstart-part-17-impact-of-the-snapshot-tiered-cache-on-the-cold-starts-with-java-21-52ef • Due to the effect of snapshot tiered cache, cold start times reduces with the number of invocations • After certain number of invocations reached the cold start times becomes stable
  • 48.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH AWS Lambda under the Hood High performance Serverless Java on AWS 95 https://www.infoq.com/articles/aws-lambda-under-the-hood/ https://www.infoq.com/presentations/aws-lambda-arch/
  • 49.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH 0 500 1000 1500 2000 2500 with SnapStart w/o Primingwith SnapStart w/o Priming (last 70) with SnapStart with Priming with SnapStart with Priming (last 70) Cold starts of all approx.100 and last 70 Lambda functions with Java 21 runtime with 1024 MB memory setting, Apache Http Client, compilation -XX:+TieredCompilation -XX:TieredStopAtLevel=1 p50 p75 p90 p99 p99.9 max https://dev.to/aws-builders/aws-snapstart-part-17-impact-of-the-snapshot-tiered-cache-on-the-cold-starts-with-java-21-52ef Due to the effect of snapshot tiered cache, cold start times reduces with the number of invocations ms
  • 50.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH AWS Lambda Profiler Extension for Java High performance Serverless Java on AWS 97 https://github.com/aws/aws-lambda-java-libs/tree/main/experimental/aws-lambda-java-profiler
  • 51.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH AWS Lambda Implementation High performance Serverless Java on AWS 98
  • 52.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH 99 https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-input-format API Gateway Proxy Request Event JSON
  • 53.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH AWS Lambda Profiler Extension for Java High performance Serverless Java on AWS 100 https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-input-format https://github.com/aws/aws-lambda-java-libs/tree/main/experimental/aws-lambda-java-profiler
  • 54.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH Full Priming including APIGatewayProxyRequestEvent High performance Serverless Java on AWS 101
  • 55.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH Full Priming including APIGatewayProxyRequestEvent Deserialization High performance Serverless Java on AWS 102 https://dev.to/aws-heroes/aws-lambda-profiler-extension-for-java-part-2-improving-lambda-performance-with-lambda-snapstart-4p06 This priming technique leads to up to 25% reduction of the cold start times vs. DynamoDB request priming alone
  • 56.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH AWS SnapStart Pricing 103 https://aws.amazon.com/lambda/pricing/?nc1=h_ls
  • 57.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH ▪ SnapStart supports the Java 11, 17 and 21 (Corretto), Python and .NET managed runtime only ▪ Deployment with SnapStart enabled takes more than 2-2,5 minutes additionally ▪ Snapshot is deleted from cache if Lambda function is not invoked for 14 days ▪ SnapStart currently does not support : ▪ Provisioned concurrency ▪ Amazon Elastic File System (Amazon EFS) ▪ Ephemeral storage greater than 512 MB AWS SnapStart Challenges & Limitations 104 https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html
  • 58.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH 108 High performance Serverless Java on AWS
  • 59.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH GraalVM Architecture High performance Serverless Java on AWS 110
  • 60.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH GraalVM Ahead-of-Time Compilation High performance Serverless Java on AWS 111 Source: Oleg Šelajev, Thomas Wuerthinger, Oracle: “Deep dive into using GraalVM for Java and JavaScript” https://www.youtube.com/watch?v=a-XEZobXspo
  • 61.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH Promise: Java Function compiled into a native executable using GraalVM Native Image significantly reduces ▪ “cold start” times ▪ memory footprint GraalVM Native Image 113
  • 62.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH ▪ AWS doesn’t provide GraalVM (Native Image) as Java Runtime out of the box ▪ AWS provides Custom Runtime Option Current Challenges with Native Executable using GraalVM High performance Serverless Java on AWS 114
  • 63.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH Custom Lambda Runtimes High performance Serverless Java on AWS 115 https://github.com/Vadym79/AWSLambdaGraalVMNativeImage
  • 64.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH 0 500 1000 1500 2000 2500 3000 3500 4000 w/o SnapStart with SnapStart w/o Priming with SnapStart with Priming GraalVM 23 Native Image p50 p75 p90 p99 p99.9 max https://dev.to/aws-builders/aws-snapstart-part-13-measuring-warm-starts-with-java-21-using-different-lambda-memory-settings-160k ms
  • 65.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH 0,00 5,00 10,00 15,00 20,00 25,00 w/o SnapStart with SnapStart w/o Priming with SnapStart with Priming GraalVM 23 Native Image p50 p75 p90 p99 https://dev.to/aws-builders/aws-snapstart-part-13-measuring-warm-starts-with-java-21-using-different-lambda-memory-settings-160k ms
  • 66.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH 0 200 400 600 800 1000 1200 1400 1600 w/o SnapStart with SnapStart w/o Priming with SnapStart with Priming GraalVM Native Image 23 p99.9 max https://dev.to/aws-builders/aws-snapstart-part-13-measuring-warm-starts-with-java-21-using-different-lambda-memory-settings-160k ms
  • 67.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH Frameworks and libraries Ready for GraalVM Native Image High performance Serverless Java on AWS 126 https://www.graalvm.org/native-image/libraries-and-frameworks/
  • 68.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH ▪ You can run into errors when application is running Complex GraalVM Native Image configuration High performance Serverless Java on AWS 127 https://github.com/Vadym79/AWSLambdaGraalVMNativeImage/blob/master/pure-lambda-graalvm-jdk-21-native-image/src/main/reflect.json
  • 69.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH Assisted Configuration with GraalVM Tracing Agent High performance Serverless Java on AWS 131 https://www.graalvm.org/latest/reference-manual/native-image/metadata/AutomaticMetadataCollection/ https://www.graalvm.org/latest/reference-manual/native-image/guides/configure-with-tracing-agent/ Run the GraalVM tracing agent during the execution of your tests
  • 70.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH ▪ GraalVM is really powerful and has a lot of potential ▪ GraalVM Native Image improves cold starts and memory footprint significantly ▪ GraalVM Native Image is currently not without challenges ▪ Complex GraalVM Native Image configuration files ▪ AWS Lambda Custom Runtime requires Linux executable only ▪ Building Custom Runtime requires some additional effort ▪ e.g. you need a scalable CI/CD pipeline to build memory-intensive native image ▪ Build time is a factor ▪ You need to carefully test to avoid runtime errors GraalVM Conclusion 132
  • 71.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH “Spring Boot 3.4 application on AWS Lambda” series 143 Article series covers different ways to write Spring Boot 3.4 application on AWS Lambda ▪ AWS Serverless Java Container ▪ AWS Lambda Web Adapter ▪ Spring Cloud Functions ▪ Custom Docker Image ▪ GraalVM Native Image Cold and warm start time measurements are also provided https://dev.to/vkazulkin/series/30408
  • 72.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH “Quarkus 3 application on AWS Lambda” series 144 Article series covers different ways to write, run and optimize Quarkus 3 application on AWS Lambda using: ▪ Managed Java 21 Lambda runtime ▪ GraalVM Native Image Cold and warm start time measurements are also provided https://dev.to/vkazulkin/series/31519
  • 73.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH Experiment with: ▪ Lambda memory settings ▪ Java compilation options ▪ HTTP Client implementations (sync and async) ▪ Lambda architecture ▪ Lambda SnapStart (with priming techniques) and GraalVM Native Image To find the right trade-off between Lambda cost and performance for your particular use case Wrap up How to develop, run and optimize Spring Boot 3 application on AWS Lambda 145
  • 74.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH ▪ With AWS SnapStart and GraalVM Native Image you can reduce cold start times of the AWS Lambda with Java 21 runtime to the acceptable values ▪ If you’re willing to accept slightly higher cold and warm start times for certain the Lambda function(s) and solid priming is applicable -> use fully managed AWS SnapStart with priming ▪ If a very high performance for certain the Lambda function(s) is really crucial for your business -> go for GraalVM Native Image Wrap up and personal suggestions How to develop, run and optimize Spring Boot 3 application on AWS Lambda 146
  • 75.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH Project Leyden High performance Serverless Java on AWS 147 The primary goal of this Project is to improve the startup time, time to peak performance, and footprint of Java programs. https://www.youtube.com/watch?v=teXijm79vno https://openjdk.org/projects/leyden/
  • 76.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH Word of caution High performance Serverless Java on AWS 148 Re-measure for your use case! Even with my examples measurements might already produce different results due to: ▪ Lambda Amazon Corretto Java 21 managed runtime minor version changes ▪ Lambda SnapStart snapshot create and restore improvements ▪ Firecracker VM improvements ▪ Dependencies updates (impacts its size) ▪ GraalVM (major and minor version) and Native Image improvements ▪ There are still servers behind Lambda ▪ Java Memory Model impact (L or RAM caches hits and misses)
  • 77.
    Vadym Kazulkin |@VKazulkin |ip.labs GmbH 149 High performance Serverless Java on AWS Thank you