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

2020 - A space odyssey with Micronaut and Quarkus

2020 - A space odyssey with Micronaut and Quarkus

In 2019, two contenders have decided to go on an ambitious mission and compete with Spring Boot as the fastest microservice framework in Java space! Now the battle is on, but Developer productivity is ruled by more than speed alone…
In this session I discussed Micronaut and Quarkus and compared them with their cousin Spring Boot, who has been travelling the Java space since time immemorial. The question is: who can accelerate and adapt fast enough to outperform the others? Who will fail or prevail? Together, we will find out…

Frederieke Scheper

November 06, 2019
Tweet

More Decks by Frederieke Scheper

Other Decks in Programming

Transcript

  1. Agenda Introduction A brief history of Java Space Getting started

    Feature comparison Developer friendly? Production ready? High scores Wrap-up 2 https://pixabay.com/p-683065/
  2. Introduction - Let’s meet • Java Architect & Codesmith @

    Ordina JTech ‣ I ❤ JAVA conferences! • Contracted by Ministry of Justice and Security • Passion for ‣ Big Data technologies ‣ Machine learning 3
  3. Agenda Introduction A brief history of Java Space Getting started

    Feature comparison Developer friendly? Production ready? High scores Wrap-up 5 https://pixabay.com/p-683065/
  4. Micronaut 1. Developed by creators from Grails 2. Goals ‣

    Provide all the necessary tools to build full featured microservice applications ‣ Avoid downsides of Spring, Spring Boot, Grails 3. Features ‣ Fast startup, reduced memory ‣ Minimal use of proxies & reflection 11
  5. Quarkus 1. Developed by RedHat 2. Goals ‣ Container-first and

    cloud-native ‣ Imperative and reactive ‣ Optimized for developer joy 3. Features ‣ Extension system to integrate frameworks ‣ Minimal use of proxies & reflection 12
  6. 14

  7. Agenda Introduction A Brief history of Java Space Getting started

    Feature comparison Developer friendly? Production ready? High scores Wrap-up 15 https://pixabay.com/p-683065/
  8. Getting started – Spring Boot • Spring Initializr project ‣

    Open https://start.spring.io ‣ Enter name, features, etc. ‣ Download resulting zip-file • Or use the Spring-boot CLI … 17 $ brew tap pivotal/tap $ brew install springboot $ spring init -d=web,jpa \ -g com.github.fbascheper.odyssey \ -n spring-demo
  9. $ brew install micronaut $ setjdk8 # use JDK 8

    to prevent warnings $ mn profile-info base # lists available features $ mn create-app com.github.fbascheper.odyssey.mn-demo \ --features=junit,jdbc-hikari,hibernate-jpa,graal-native-image \ --build=maven # default is GRADLE $ cd mn-demo $ ./mvnw verify Getting started – Micronaut 18
  10. $ # No CLI available :-( $ # Requires Maven

    pre-installed $ # Requires Maven to create a Gradle project ;-)
 $ mvn io.quarkus:quarkus-maven-plugin:0.28.1:create \ -DprojectGroupId=com.github.fbascheper.odyssey \ -DprojectArtifactId=quarkus-demo \ -DclassName="com.github.fbascheper.odyssey.resource.VetResource" \ -Dpath="/vets" $ cd quarkus-demo $ ./mvnw quarkus:add-extension -Dextensions="agroal, hibernate-orm" $ ./mvnw compile quarkus:dev Getting started – Quarkus 19
  11. Getting started – Quarkus • Or you can also use

    the Quarkus bootstrap page HTTPS://CODE.QUARKUS.IO • Select the extensions • And download the resulting zip-file 20
  12. Agenda Introduction A Brief history of Java Space Getting started

    Feature comparison Developer friendly? Production ready? High scores Wrap-up 21 https://pixabay.com/p-683065/
  13. Feature comparison 1. Language support 2. Framework support 3. Shell

    integration (*NIX) 4. Kubernetes support 22 https://pixabay.com/nl/photos/vintage-schaal-evenwicht-weegschaal-2862708/
  14. • Java ✔ ✔ ✔ • Groovy ✔ ✘ ✔

    • Kotlin ✔ ✔ ✔ • Scala ✘ ✔ ✔ Language support 23 MICRONAUT QUARKUS SPRING BOOT
  15. Framework support • Java / Jakarta EE ✘ ✘ ✘

    • Eclipse MicroProfile certified ✘ ✔ ✘ ‣ (Sub) specification support: - CDI ✔ ✔ ✔ - JSON-P / JSON-B ✔ ✔ ✔ - JAX-RS ✔ ✔ ✔ - JWT ✔ ✔ ✔ • Reactive Messaging ✔ ✔ ✔ 24 MICRONAUT QUARKUS SPRING BOOT
  16. Spring DI compatibility • QUARKUS provides a ‘Spring’ compatibility extension

    • With support for Spring framework annotations, such as ‣ @Autowired (with @Qualifier) ‣ @Component ‣ @Value • NOTE: THIS WILL NOT ‣ Start a Spring Application Context ‣ Run any Spring infrastructure classes 26
  17. Spring DI compatibility • MICRONAUT also has integration for ‘Spring’

    compatibility • With support for ‣ Spring framework annotations, events, … ‣ Spring boot annotations ‣ Spring MVC controllers • You can even use Micronaut as a parent application context • QUESTION: HOW MUCH SPRING DO YOU NEED??? 27
  18. Command-line tools • Maven plugin ‣ Run application ✘ ✔

    ✔ ‣ Hot reloading ✘ ✔ ✘ • Gradle support ✔ ✘ ✔ • Shell support ‣ New project ✔ ✘ ✔ ‣ Modify project ✔ ✘ ✘ 28 MICRONAUT QUARKUS SPRING BOOT
  19. Cloud / Kubernetes support • Build Docker build ‣ Native

    compilation (GraalVM) ✔ ✔ ✘ • Read Kubernetes metadata ‣ ConfigMaps ✔ ✘ ✘ ‣ Secrets ✔ ✘ ✘ • Kubernetes Service Discovery ‣ Clients can discover Kubernetes services ✔ ✘ ✘ 29 MICRONAUT QUARKUS SPRING BOOT
  20. Summing up • Quarkus ‣ MicroProfile 2.2 certified ‣ Hot

    code replacement • Micronaut ‣ Best Kubernetes support • Spring Boot ‣ Familiar to everyone ‣ Best language / framework support 30 https://pixabay.com/nl/photos/rekenmachine-nummer-3051722/ NO CLEAR WINNER !
  21. Agenda Introduction A Brief history of Java Space Getting started

    Framework support Developer friendly? Production ready? High scores Wrap-up 31 https://pixabay.com/p-683065/
  22. Developer Friendly? • Minimal requirements ‣ Documentation ‣ IDE Support

    ‣ Examples • Stack overflow ?! • Productivity ‣ Hot code replacement ‣ Single configuration 32
  23. Developer Friendly? • Minimal requirements ‣ Documentation - similar ‣

    IDE Support - SPRING BOOT ! ‣ Examples • Stack overflow ?! • Productivity ‣ Hot code replacement ‣ Single configuration 33 QUARKUS ! }
  24. Various build types - with Quarkus 34 • Development build

    • Native image ‣ For your LOCAL operating system • Cross compilation $ ./mvnw compile quarkus:dev $ ./mvnw package -Pnative $ ./mvnw package -Pnative -Dnative-image.docker-build=true # Alternative: docker build -f src/main/docker/Dockerfile.multistage .\ WHAT’S THE DIFFERENCE ? / /
  25. Quarkus development build 39 @Entity @Table(name = "pets") public class

    Pet extends NamedEntity { @ManyToOne @JoinColumn(name = "owner_id") @JsonbTransient public Owner owner; @OneToMany(cascade = CascadeType.ALL, mappedBy = "pet", fetch = FetchType.EAGER) @JsonbTransient public Set<Visit> visits = new LinkedHashSet<>(); } CODE FIXED !
  26. Quarkus cross-compile build 41 ABOUT 30 MINUTES! $ ./mvnw package

    -Pnative -Dnative-image.docker-build=true
  27. Agenda Introduction A Brief history of Java Space Getting started

    Framework support Developer friendly? Production ready? High scores Wrap-up 43 https://pixabay.com/p-683065/
  28. Production ready? • Minimal requirements ‣ Stable ‣ Secure (patches)

    ‣ Active (updates) • Nice to have ‣ Community ?! ‣ Support contracts?! 44
  29. Performance timing • Startup time 3.448 s 3.430 s 0.019

    s 5.564 s • Average request time after warmup (time http :8080/vets) ‣ Real 0.365s 0.307s 0.265s 0.270s ‣ User 0.263s 0.246s 0.210s 0.215s ‣ Sys 0.055s 0.044s 0.045s 0.045s 45 MICRONAUT QUARKUS-DEV QUARKUS-NATIVE SPRING BOOT
  30. Agenda Introduction A Brief history of Java Space Getting started

    Framework support Developer friendly? Production ready? High scores Wrap-up 46 https://pixabay.com/p-683065/
  31. • You need native images ‣ GraalVM / Docker /

    Kubernetes ‣ Function as a Service applications • AND you can handle ‣ Living on the bleeding edge ‣ Frequent (weekly?) updates • AND you trust RedHat / IBM Choose Quarkus, if… 48
  32. Choose Micronaut, if… • You need native images ‣ GraalVM

    / Docker / Kubernetes ‣ Function as a Service • BUT you cannot handle ‣ Living on the bleeding edge ‣ Frequent (weekly?) updates • OR you need something special ‣ Gradle / Groovy support ? 49
  33. Choose Spring Boot, if… • You don’t need ‣ Native

    images ‣ Hot reloading (JRebel / DCEVM) ‣ … • OR You rely on JDK7, Reflection, … • OR You’re using Spring specific frameworks • OR you just want to be ‘safe’ 50
  34. Agenda Introduction A Brief history of Java Space Getting started

    Framework support Developer friendly? Production ready? High scores Wrap-up 51 https://pixabay.com/p-683065/