Lock in $30 Savings on PRO—Offer Ends Soon! ⏳

Reactive Java REST APIs, FTW? Virtual JUG 2024

Reactive Java REST APIs, FTW? Virtual JUG 2024

For several years, luminaries like Jonas Bonér, James Ward, and Josh Long have encouraged us to use reactive programming. Now that reactive programming has gone mainstream, and many Java frameworks support it, is it really all that?

In this talk, you'll learn how to create Java REST APIs with Micronaut, Quarkus, Spring Boot, and Helidon. Then, you'll see how to secure them with OAuth 2.0 and what their reactive equivalents look like. I'll compare each framework's imperative versus reactive implementation performance numbers. Finally, you'll learn about their GraalVM support and see how they compare when running natively.

You'll leave with enough knowledge to create your own secure Java REST APIs and be confident if reactive works for you.

Meetup event: https://www.meetup.com/virtualjug/events/299634463
GitHub repo: https://github.com/mraible/java-rest-api-examples
YouTube recording: https://www.youtube.com/watch?v=Om66XAMf8tM

Matt Raible

May 23, 2024
Tweet

Video


Resources

More Decks by Matt Raible

Other Decks in Programming

Transcript

  1. Reactive Java REST APIs, FTW? Matt Raible | @mraible Photo

    by Lars Leber https://www.instagram.com/p/C609JShLNY0 May 23, 2024
  2. @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
  3. @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
  4. @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)
  5. @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
  6. @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
  7. @mraible Use SDKMAN! curl -s "https: // get.sdkman.io" | bash

    sdk install java 21-open Get Started with Java 21
  8. @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
  9. @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
  10. @mraible Micronaut gradle nativeCompile Quarkus gradle build -Dquarkus.package.type=native Spring Boot

    gradle nativeCompile Helidon mvn package -Pnative-image Build with GraalVM
  11. @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
  12. @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
  13. @mraible Performance Startup performance Docker startup on EC2 Native memory

    usage Docker memory usage Load testing with Apache Bench Load testing with Gatling
  14. @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
  15. @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
  16. @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
  17. @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
  18. @mraible Imperative Native Memory Usage 0 100 200 300 Megabytes

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

    70 222 56 103 Micronaut Quarkus Spring Boot Helidon After 10,000 requests
  20. @mraible Imperative Docker Memory Usage 0 25 50 75 100

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

    Megabytes 16 51 11 13 Micronaut Quarkus Spring Boot Helidon After 10 requests
  22. @mraible Imperative Apache Bench Results Requests per second Time per

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

    request Time for tests 0 125 250 375 500 Micronaut Quarkus Spring Boot Helidon
  24. @mraible Con f igure and Run Gatling export URL=<copy from

    Gitpod> export TOKEN=<copy from Auth0 CLI> ./mvnw gatling:test
  25. @mraible Quarkus Insights Quarkus Insights #137: Comparing Native Java REST

    API Frameworks https://www.youtube.com/watch?v=yoU1ruBSXSA
  26. @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
  27. @mraible GitHub Stars 0 20000 40000 60000 80000 May 2024

    3,400 73,100 13,200 6,000 Micronaut Quarkus Spring Boot Helidon
  28. @mraible Jobs on LinkedIn (US) 0 450 900 1350 1800

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

    May 2024 18 1,634 26 10 Micronaut Quarkus Spring Boot Helidon
  30. @mraible Twitter Followers 0 30000 60000 90000 120000 May 2024

    4,819 105,800 19,200 13,500 Micronaut Quarkus Spring Boot Helidon
  31. @mraible Thank you! Keep in touch https://raibledesigns.com @mraible and in/mraible

    Presentations https://speakerdeck.com/mraible Code https://github.com/mraible