J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS Lambda

BertJanSchrijver 56 views 47 slides Jun 14, 2024
Slide 1
Slide 1 of 47
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47

About This Presentation

Presented at NLJUG's J-Spring 2024.


Slide Content

[email protected]
With Quarkus, GraalVM native images and AWS Lambda
Bert Jan Schrijver
Going serverless
@bjschrijver

Bert Jan Schrijver
L e t ’ s m e e t
@bjschrijver

About the NLJUG

The NLJUG events app

NLJUG app: look & feel

NLJUG app: architecture
AWS S3
Bucket
App backend
Internet
Votes
Content

NLJUG app voting backend

App backend: first iteration (2015)
AWS EC2
AWS ELB
Wildfly 8
Java 7
Java EE
Application
AWS EC2
MySQL 5

11

•Functions-as-a-service (FaaS)
•Short running
•Small units of execution
•On demand, pay per use, scale to zero
•Startup time matters (for cold starts)
•There are still servers ;-)
Serverless computingBackground source: https://filmquarterly.org/2012/07/02/i-robot-what-do-robots-dream-of/

My first serverless experience (2016)

App backend: second iteration (2018)
AWS EC2
AWS ELB
Spring Boot 2
Java 8
Spring
Application
AWS
DynamoDB

15

First serverless attempt (2019)

•JDK & JVM
•Built by Oracle
•Two runtime options:
•run as JVM (Based on Hotspot) with JIT
•ahead-of-time compilation to platform-
specific native image binary
GraalVM

In the meantime…

•Kubernetes native web framework
•Open source, developed by Red Hat
•Designed to work with Java ecosystem
•Tailored for OpenJDK HotSpot and
GraalVM
•Great developer experience
Quarkus

Second serverless attempt (2022)

Third serverless attempt (2023)

Third serverless attempt (2023)

App backend: third iteration (2023)
AWS Lambda
AWS
API Gateway
GraalVM
native image
Java 17
Quarkus
application
AWS
DynamoDB

Demo time!

Migrating from Spring to Quarkus

Migration: REST endpoints

Migration: REST entity classes

Migration: Other changes

Show me the code!

Experiences from running in productionPhoto: Dave Lehl

Monitoring, performance & scalability

Metrics during J-Fall 2023

Number of invocations per minute

Request duration (1 min avg)

Request duration (1 hour avg)

Success / error count

Concurrent executions

Logs

Costs

AWS costs for J-Fall 2023 app backend

AWS costs for J-Fall 2023 app backend

Is this the holy grail / graal?

•Cross compiling across cpu architectures is slow
•3rd party library support for native images is not
guaranteed (but Quarkus libs are good)
•Reflection and native images can be tricky
•Debugging can be painful if problem is not local
•You need limits on lambda and API GW
•Probably good to use build & deploy pipelines ;-)
Quarkus/GraalVM native/Lambda caveats

Let’s wrap up!

•Serverless Java is totally doable in 2024!
•Quarkus & GraalVM ❤ serverless
•Ideal for small/hobby projects
•As usual, YMMV ;-)
•Demo/seed project:
https://github.com/bertjan, repo:
quarkus-graalvm-aws-lambda-arm64
Summary

Source: https://cdn2.vox-cdn.com/thumbor/J9OqPYS7FgI9fjGhnF7AFh8foVY=/148x0:1768x1080/1280x854/cdn0.vox-cdn.com/uploads/chorus_image/image/46147742/cute-success-kid-1920x1080.0.0.jpg THAT’S IT.
NOW GO KICK SOME ASS!

Questions?
@bjschrijver

Thanks for your time.
Got feedback? Tweet it!
All pictures belong
to their respective
authors
@bjschrijver