Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Boston Java Meetup Group - 4-11-23 - Spring Boo...

Boston Java Meetup Group - 4-11-23 - Spring Boot microservices to Quarkus

From the Boston Java Meetup Group: https://www.meetup.com/boston-java/events/291073892

Quarkus allows Java™ developers to develop “with or without'' Spring APIs for container-based applications. Attendees will learn about the Spring compatibility in Quarkus. Common questions asked by Spring users about Quarkus will also be discussed. Performance differences between the Spring and Quarkus versions of an application will be demonstrated.

Attendees will also learn hands-on how to quickly migrate a Spring Boot microservice application to Quarkus with little-to-no code changes.

Objectives:
Learn about Quarkus, and its Supersonic, Subatomic characteristics.
Convert a Spring Boot application using Spring MVC, Spring Data JPA, and a PostgreSQL database and to Quarkus with little-to-no source code changes. Use the Red Hat® Migration Toolkit for Applications to analyze a Spring Boot application and offer suggestions for migrating it to Quarkus.

As a bonus exercise, create and run a Quarkus native binary, using Quarkus’ built-in tools to facilitate building the native binary as a Linux® executable. From there, create a container image from it, alleviating the need to install GraalVM on your local machine.

Pre-requisites (for hands-on portion):
- Computer with Java 17 (or higher) installed
- A working container runtime (Docker/Podman)
- Access to the internet
- Optionally an IDE (IntelliJ/VSCode/Eclipse/Gitpod/etc)
- Optionally GraalVM CE 22.3

Eric Deandrea

April 11, 2023
Tweet

More Decks by Eric Deandrea

Other Decks in Programming

Transcript

  1. @edeandrea Eric Deandrea Who’s on stage today? 🤘 22+ years

    software development experience 🤘 Contributor to Open Source projects 🤘 Quarkus 🤘 Spring Boot 🤘 Spring Framework 🤘 Spring Security 🤘 Spring Session 🤘 Build & deliver cloud-native development training programs 🤘 Published author
  2. Holly Cummins Sr. Principal Software Engineer Red Hat @holly_cummins Eric

    Deandrea Sr. Principal Developer Advocate Red Hat @edeandrea Avoiding common pitfalls with modern microservices testing
  3. @edeandrea • How Quarkus enables modern Java development & the

    Kubernetes-native experience 
 • Introduce familiar Spring concepts, constructs, & conventions and how they map to Quarkus 
 • Emphasis on testing patterns & practices https://red.ht/quarkus-spring-devs
  4. @edeandrea Java, The Enterprise Workhorse Monolith J2SE / J2EE Java

    / Jakarta EE Cloud-Native Microservices Spring Boot MicroProfile
  5. @edeandrea Java, The Enterprise Workhorse Monolith J2SE / J2EE Java

    / Jakarta EE Cloud-Native Microservices Spring Boot MicroProfile
  6. @edeandrea Java / Jakarta EE J2SE / J2EE Monolith Cloud-Native

    Microservices Serverless Event-Driven Microservices Cloud-Native Java, The Enterprise Workhorse Spring Boot MicroProfile
  7. @edeandrea Build Time Runtime Packaging 
 (maven, etc) gradle…) Load

    config file from file system Parse it Classpath scanning to find annotated classes Attempt to load class to enable/disable features Build its model of 
 the world. Start the management (thread, pool…) @ 
 @ </> How Does a Framework Start?
  8. @edeandrea Build Time Runtime @ 
 @ </> The Quarkus

    Way Runtime Build Time @ 
 @ </> Package 
 model Build Time Runtime @ 
 @ </>
  9. @edeandrea Command Line Job Github App Cloud / Container Native

    Serverless & Functions Micro 
 services EDA Kube Operator Traditional Apps CRUD Monoliths GitHub Actions Admin Tools Reactive 
 Systems Traditional CLI
  10. @edeandrea JVM Quarkus Spring Boot Ratio (Quarkus / SB) Framework

    version 2.13.7.CR2 2.7.9 Build time (s) 7.27 17.68 41.13% Av. RSS after startup (MB) 177.21 441.77 40.11% Av. time to 1st req (ms) 2,460.67 5,240.33 46.96% Av. RSS after 1st req (MB) 252.12 481.67 52.34% Av. throughput (req/sec) 17,940.55 6,808 263.52% Av. RSS for max throughput (MB) 523.82 665.58 78.7% Max throughput density (req/sec/ MB) 35.52 11.24 316.1% Native Quarkus Spring Boot Ratio (Quarkus / SB) Framework version 2.13.7.CR2 2.7.9 Build time (s) 118.53 199.15 59.52% Av. RSS after startup (MB) 60.33 136.54 44.18% Av. time to 1st req (ms) 41.67 217.67 19.14% Av. RSS after 1st req (MB) 65.2 141.87 45.96% Av. throughput (req/sec) 27,326.59 10,799.41 253.04% Av. RSS for max throughput (MB) 453.34 625.67 72.46% Max throughput density (req/sec/ MB) 69.43 18.47 375.95% Quarkus Performance Some real numbers (8 cores, 12GB RAM, GraalVM 22.3.r11)
  11. @edeandrea “We went from 1 min startup times to 400

    ms.” RH Press Release Community “We became increasingly worried about resource consumption that Spring Boot was having while being deployed on the Kubernetes cluster… It became increasingly cumbersome to find ways to circumvent the methodology we were using just to squeeze every little bit of performance out of Spring Boot” - Christos Sotiriou DXL Backend Chapter Lead, Vodafone Greece Information Week Community “We could run 3x denser deployments without sacrificing availability and response times of service.” “Quarkus is close to what our developers are already doing with Spring and it’s familiar to them. This is a big benefit” Community “Before we introduced Quarkus, many of our customers had started to look at alternative stacks like Go and node.js to improve performance and efficiency. These customers were weary of selecting a new language and having to hire new developers or retrain their existing Java developers.” - Arijit Mazumdar “There was a low learning curve with Quarkus. It took one of our developers one week to get up to speed on Quarkus and another week to migrate a Spring application to Quarkus.” - Arijit Mazumdar “Quarkus and the Spring API compatibility reduced the migration time and complexity which is critically important for our customers.” - Arijit Mazumdar Community https://quarkus.io/blog/tag/user-story Don’t Take Our Word For It!
  12. @edeandrea “using Spring with AWS Lambda would have been prohibitive

    because the startup time of Spring in AWS Lambda is too big from my research” - Dennis Baerten “As costs increase, this is when the benefit of using Quarkus will be experienced due to its more efficient use of cloud resources and fast startup time compared to plain Java and Spring Boot” - Dennis Baerten “It took me about 3 days to get familiar with the Quarkus stack” - Dennis Berten, Spring Developer Blog “Some of Payair’s developers had mainly Spring experience, we were concerned that it would be difficult for them to “switch sides”. It turned out that our fear of the unknown was completely unfounded. Quarkus leverages some good old Jakarta EE standards that all Java developers are familiar with. We did not have to learn a bunch of new APIs.” - Hubert Lewandowski “As a long term Spring developer I realized that Spring is slowly becoming the very thing it swore to destroy. The initial premises of Spring (which basically can be summed up as a lightweight alternative to Jakarta EE) are way past the expiry date now. Spring is the undisputed heavyweight champion that can handle everything you imagine but is not your best option for fast and light services. And that applies to Spring Boot as well. - Hubert Lewandowski Blog “When you adopt Quarkus, you will be productive from day one since you don’t really need to learn new technologies.” -TalkDesk Blog “After deploying, we found that Quarkus used about 15% of the CPU, 12% of the memory compared to Spring Boot. So far, we are sticking with Quarkus!” - Sam Dacanay, Lead Software Engineer Blog https://quarkus.io/blog/tag/user-story Don’t Take Our Word For It!
  13. @edeandrea 🤘 Kubernetes-native inner loop development with Quarkus 🤘 Kubernetes-Native

    Development with Quarkus and Eclipse JKube 🤘 Spring Boot on Quarkus: Magic or Madness? 🤘 Why should I choose Quarkus over Spring for my microservices? 🤘 Quarkus for Spring Developers: Getting Started 🤘 Evolution of the Quarkus Developer Experience 🤘 Quarkus Insights: Quarkus for Spring Developers 🤘 Quarkus Insights: Quarkus Superheroes Additional Resources
  14. @edeandrea Jam Time! 🤘 Convert and run a full-featured Spring

    Boot application on Quarkus with no code changes 🤘 Spring Web 🤘 Spring Data JPA 🤘 Spring Actuator 🤘 Spring Boot Config 🤘 SpringDoc OpenAPI 🤘 Micrometer metrics 🤘 PostgreSQL (JDBC) 🤘 Hibernate Validator
  15. @edeandrea 🤘 Replace Spring Boot starters with equivalent Quarkus extensions

    🤘 Replace Spring configuration with equivalent Quarkus configuration 🤘 Little changes to get tests working 🤘 Bonus Track: No hassle native image generation Quarkus & native rocking the stage since 2019! Jam Time!