Slide 1

Slide 1 text

Reactive Java REST APIs, FTW? Matt Raible | @mraible Photo by Lars Leber https://www.instagram.com/p/C609JShLNY0 May 23, 2024

Slide 2

Slide 2 text

@mraible Father, Husband, Skier, Mountain Biker, Whitewater Rafter Bus Lover Web Developer and Java Champion JHipster Project Co-Leader Blogger on raibledesigns.com Hi, I'm Matt Raible

Slide 3

Slide 3 text

@mraible

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

@mraible

Slide 6

Slide 6 text

@mraible

Slide 7

Slide 7 text

@mraible What is reactive programming? Why Java? Building Java REST APIs Building with GraalVM Containerizing with Docker Performance Community Today's Agenda https://unsplash.com/photos/JsTmUnHdVYQ

Slide 8

Slide 8 text

@mraible The Reactive Manifesto https://www.reactivemanifesto.org FORM MEANS VALUE Responsive Maintainable Extensible Resilient Message Driven Elastic Published on September 16 2014. (v2.0)

Slide 9

Slide 9 text

@mraible Is reactive programming better?

Slide 10

Slide 10 text

@mraible Reactive Programming In f luencers @_JamesWard @jboner @starbuxman

Slide 11

Slide 11 text

@mraible Why Java? 25+ Years of use, abuse, and improvements Open Source code is available; many popular open source frameworks and tools Hugely popular and widely used by many enterprises and web-scale companies

Slide 12

Slide 12 text

@mraible Get Started with Java 21 Download the Oracle builds of OpenJDK https://jdk.java.net/archive Or Eclipse builds from Adoptium https://adoptium.net

Slide 13

Slide 13 text

@mraible Use SDKMAN! curl -s "https: // get.sdkman.io" | bash sdk install java 21-open Get Started with Java 21

Slide 14

Slide 14 text

@mraible Build Java REST APIs gh repo clone mraible/java-rest-api-examples https://github.com/mraible/java-rest-api-examples

Slide 15

Slide 15 text

@mraible 4.4.2 3.10.2 3.2.5 4.0.8 Framework Versions

Slide 16

Slide 16 text

@mraible Imperative vs Reactive Micronaut has no separate reactive web framework Quarkus uses OIDC with reactive because MicroPro f ile is imperative Spring Boot uses same code with different dependencies Helidon has different dependencies and code

Slide 17

Slide 17 text

@mraible Micronaut gradle build & & java -jar build/libs/app-0.1-all.jar Quarkus gradle build & & java -jar build/quarkus-app/quarkus-run.jar Spring Boot gradle bootJar && java -jar build/libs/spring-boot-0.0.1-SNAPSHOT.jar Helidon mvn package && java -jar target/helidon.jar Build and run on the JVM

Slide 18

Slide 18 text

@mraible Build with GraalVM https://www.graalvm.org sdk install java 21.0.2-graalce

Slide 19

Slide 19 text

@mraible Serverless https://unsplash.com/photos/glRqyWJgUeY 💵 💸

Slide 20

Slide 20 text

@mraible https://twitter.com/therealdanvega/status/1666098085616046081 Use Cases for Native Images

Slide 21

Slide 21 text

@mraible Micronaut gradle nativeCompile Quarkus gradle build -Dquarkus.package.type=native Spring Boot gradle nativeCompile Helidon mvn package -Pnative-image Build with GraalVM

Slide 22

Slide 22 text

@mraible Containerizing with Docker

Slide 23

Slide 23 text

@mraible Micronaut gradle dockerBuildNative docker tag app:latest mraible/micronaut:latest Quarkus gradle build -Dquarkus.package.type=native -Dquarkus.native.container-build=true docker build -f src/main/docker/Dockerfile.native -t quarkus . docker tag quarkus:latest mraible/quarkus:latest Build Docker Images

Slide 24

Slide 24 text

@mraible Spring Boot gradle bootBuildImage -- imageName=spring-boot docker tag spring-boot:latest mraible/spring-boot:latest Helidon docker build -t helidon -f Dockerfile.native . docker tag helidon:latest mraible/helidon:latest Build Docker Images

Slide 25

Slide 25 text

@mraible Performance Startup performance Docker startup on EC2 Native memory usage Docker memory usage Load testing with Apache Bench Load testing with Gatling

Slide 26

Slide 26 text

@mraible Imperative Native Startup Apple M3; printed Duration (ms) 0 12.5 25 37.5 50 23.2 25.6 9 8.2 Micronaut Quarkus Spring Boot Helidon

Slide 27

Slide 27 text

@mraible Reactive Native Startup Apple M3; scripted Duration (ms) 0 12.5 25 37.5 50 30.4 36.6 16.8 26 Micronaut Quarkus Spring Boot Helidon

Slide 28

Slide 28 text

@mraible Tests run on a 2023 MacBook Pro M3

Slide 29

Slide 29 text

@mraible Imperative Docker Startup AWS EC2 t2.micro Duration (ms) 0 37.5 75 112.5 150 132.4 136 33.6 50.4 Micronaut Quarkus Spring Boot Helidon

Slide 30

Slide 30 text

@mraible Reactive Docker Startup AWS EC2 t2.micro Duration (ms) 0 37.5 75 112.5 150 132.8 146.2 43.4 59.2 Micronaut Quarkus Spring Boot Helidon

Slide 31

Slide 31 text

@mraible Imperative Native Memory Usage 0 100 200 300 Megabytes 69 109 71 105 Micronaut Quarkus Spring Boot Helidon After 10,000 requests

Slide 32

Slide 32 text

@mraible Reactive Native Memory Usage 0 100 200 300 Megabytes 70 222 56 103 Micronaut Quarkus Spring Boot Helidon After 10,000 requests

Slide 33

Slide 33 text

@mraible Imperative Docker Memory Usage 0 25 50 75 100 Megabytes 51 45 11 16 Micronaut Quarkus Spring Boot Helidon After 10 requests

Slide 34

Slide 34 text

@mraible Reactive Docker Memory Usage 0 25 50 75 100 Megabytes 16 51 11 13 Micronaut Quarkus Spring Boot Helidon After 10 requests

Slide 35

Slide 35 text

@mraible Load Testing with Apache Bench

Slide 36

Slide 36 text

@mraible Imperative Apache Bench Results Requests per second Time per request Time for tests 0 125 250 375 500 Micronaut Quarkus Spring Boot Helidon

Slide 37

Slide 37 text

@mraible Reactive Apache Bench Results Requests per second Time per request Time for tests 0 125 250 375 500 Micronaut Quarkus Spring Boot Helidon

Slide 38

Slide 38 text

@mraible Load Testing with Gatling ⬇ https://docs.gatling.io/reference/install/oss

Slide 39

Slide 39 text

@mraible Gatling Simulation

Slide 40

Slide 40 text

@mraible Con f igure and Run Gatling export URL= export TOKEN= ./mvnw gatling:test

Slide 41

Slide 41 text

@mraible Gatling Reports

Slide 42

Slide 42 text

@mraible Gatling Results: Micronaut

Slide 43

Slide 43 text

@mraible Gatling Results: Micronaut

Slide 44

Slide 44 text

@mraible Imperative Gatling Results 🏆

Slide 45

Slide 45 text

@mraible Reactive Gatling Results 🏆

Slide 46

Slide 46 text

@mraible Full Gatling Results

Slide 47

Slide 47 text

@mraible 🏆 Spring WebFlux and Helidon SE

Slide 48

Slide 48 text

@mraible TechEmpower Benchmarks https://www.techempower.com/benchmarks

Slide 49

Slide 49 text

@mraible Quarkus Insights Quarkus Insights #166: Lies, Damn Lies...and Techempower(?) https://www.youtube.com/watch?v=m48IDNTxJcM

Slide 50

Slide 50 text

@mraible Quarkus Insights Quarkus Insights #137: Comparing Native Java REST API Frameworks https://www.youtube.com/watch?v=yoU1ruBSXSA

Slide 51

Slide 51 text

@mraible Hyperfoil

Slide 52

Slide 52 text

@mraible Community https://unsplash.com/photos/PGnqT0rXWLs

Slide 53

Slide 53 text

@mraible Stack Over f low Tags 0 40000 80000 120000 160000 May 2024 152 148,913 4,545 1,818 Micronaut Quarkus Spring Boot Helidon

Slide 54

Slide 54 text

@mraible GitHub Stars 0 20000 40000 60000 80000 May 2024 3,400 73,100 13,200 6,000 Micronaut Quarkus Spring Boot Helidon

Slide 55

Slide 55 text

@mraible GitHub Star Growth

Slide 56

Slide 56 text

@mraible Jobs on LinkedIn (US) 0 450 900 1350 1800 May 2024 1,628 665 0 1 Micronaut Quarkus Spring Boot Helidon

Slide 57

Slide 57 text

@mraible Jobs on Indeed (US) 0 450 900 1350 1800 May 2024 18 1,634 26 10 Micronaut Quarkus Spring Boot Helidon

Slide 58

Slide 58 text

@mraible Twitter Followers 0 30000 60000 90000 120000 May 2024 4,819 105,800 19,200 13,500 Micronaut Quarkus Spring Boot Helidon

Slide 59

Slide 59 text

@mraible Action! https://github.com/mraible/java-rest-api-examples gh repo clone \ mraible/java-rest-api-examples

Slide 60

Slide 60 text

@mraible Thank you! Keep in touch https://raibledesigns.com @mraible and in/mraible Presentations https://speakerdeck.com/mraible Code https://github.com/mraible