Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Quarkus Denmark 2019

72 views

Published on

Intro on why and how for Quarkus - subsonic subatomic Java

Published in: Technology
  • Be the first to comment

Quarkus Denmark 2019

  1. 1. 1
  2. 2. Quarkus Hands-on Just VM Development: - Java 8 or 11 - Use code.quarkus.io to create your first app - Notepad (or VSCode, Eclipse, Intellij,...) For Native: - Java 8 - GraalVM 19.2.1 - Docker (if on Windows) Ideas for things to do: - quarkus.io/get-started - quarkus.io/guides/ - quarkus.io/guides/writing-extensions - Ascii Banner from png - Quarkus enable your favorite framework - Quarkus-coffeeshop-demo - Docker compose, kafka - - quarkus.io/quarkus-workshops/super-heros - 6-8 hours - - Your own idea… bit.ly/dkquarkus2019 2
  3. 3. 3
  4. 4. 4 1. It is a surprise 2. It has a major impact “ 3. People contend that they expected the event to happen (in hindsight)
  5. 5. 5
  6. 6. bit.ly/dkquarkus2019 6 The hidden truth about Java + containers
  7. 7. 7
  8. 8. 8 Reactive Imperative
  9. 9. 9
  10. 10. 10
  11. 11. QUARK: elementary particle / US: hardest thing in computer science
  12. 12. 12 A cohesive platform for optimized developer joy: ● ● ● ● ● Benefit No. 1: Developer Joy
  13. 13. From monolith to... bit.ly/dkquarkus2019 13 ● 1 monolith ≈ 20 microservices ≈ 200 functions ● Scale to 1 vs scale to 0 ● Start up time MONOLITH F FFFFFFFFF F FFFFFFFFF F FFFFFFFFF F FFFFFFFFF F FFFFFFFFF F FFFFFFFFF F FFFFFFFFF F FFFFFFFFF F FFFFFFFFF F FFFFFFFFF F FFFFFFFFF F FFFFFFFFF F FFFFFFFFF F FFFFFFFFF F FFFFFFFFF F FFFFFFFFF F FFFFFFFFF F FFFFFFFFF
  14. 14. ● Designed for throughputs (requests/s) ● Startup overhead ○ # of classes, bytecode, JIT ● Memory overhead ○ # of classes, metadata, compilation bit.ly/dkquarkus2019 14 The hidden truth about Java + containers RSS
  15. 15. bit.ly/dkquarkus2019 15 The hidden truth about Java + containers
  16. 16. 16 Benefit No. 2: Supersonic Subatomic Java Quarkus + AOT 19 MB Quarkus + OpenJDK (JIT) 77 MB Traditional Cloud-Native Stack 140 MB
  17. 17. 17 Benefit No. 2: Supersonic Subatomic Java Quarkus + AOT 35 MB Quarkus + OpenJDK (JIT) 130 MB Traditional Cloud-Native Stack 218 MB
  18. 18. 18 Benefit No. 2: Supersonic Subatomic Java Quarkus + AOT 0.014 Seconds Quarkus + OpenJDK 0.75 Seconds Quarkus + AOT 0.055 Seconds Quarkus + OpenJDK (JIT) 2.5 Seconds Traditional Cloud-Native Stack 9.5 Seconds Traditional Cloud-Native Stack 4.3 Seconds
  19. 19. bit.ly/dkquarkus2019 19 Benefit No. 2: Supersonic Subatomic Java CONTAINER ORCHESTRATION NodeNode Traditional Cloud-Native Java Stack Traditional Cloud-Native Java Stack Traditional Cloud-Native Java Stack Traditional Cloud-Native Java Stack Node NodeJS NodeJS NodeJS NodeJS NodeJS NodeJS NodeJS Go Go Go Go Go Go Go Go Go Go Go Go Go Go Go Go Go Go Go Go Go Node Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus
  20. 20. 20 Benefit No. 3: Unifies Imperative and Reactive ● ● ● @Inject SayService say; @GET @Produces(MediaType.TEXT_PLAIN) public String hello() { return say.hello(); } @Inject @Channel(”kafka”) Publisher<String> reactiveSay; @GET @Produces(MediaType.SERVER_SENT_EVENTS) public Publisher<String> stream() { return reactiveSay; }
  21. 21. 21 Benefit No. 4: Best of Breed Frameworks & Standards
  22. 22. 22
  23. 23. bit.ly/dkquarkus2019 24 What does a framework do at startup time Move startup time to build time ● Parse config files ● Classpath & classes scanning ○ for annotations, getters or other metadata ● Build framework metamodel objects ● Prepare reflection and build proxies ● Start and open IO, threads etc
  24. 24. bit.ly/dkquarkus2019 25 Do the work once, not at each start All the bootstrap classes are no longer loaded Less time to start, less memory used Less or no reflection nor dynamic proxy Build time benefits
  25. 25. 26 JDK JIT - HotSpot AOTC - GraalVM Native Image
  26. 26. 27
  27. 27. bit.ly/dkquarkus2019 28 An ahead-of-time, build-time, runtime
  28. 28. Quarkus Hands-on requirements Just VM Development: - Java 8 or 11 - Use code.quarkus.io to create your first app - Notepad (or VSCode, Eclipse, Intellij,...) For Native: - Java 8 - GraalVM 19.2.1 - Docker (if on Windows) Ideas for things to do: - quarkus.io/get-started - quarkus.io/guides/ - quarkus.io/guides/writing-extensions - Ascii Banner from png - Quarkus enable your favorite framework - Quarkus-coffeeshop-demo - Docker compose, kafka - - quarkus.io/quarkus-workshops/super-hero s - 6-8 hours - - Your own idea… bit.ly/dkquarkus2019 29
  29. 29. Closed-world assumption bit.ly/dkquarkus2019 30 AOTC - GraalVM - Dead code elimination
  30. 30. bit.ly/dkquarkus2019 31 Not supported The Dark Side of GraalVM ● Dynamic classloading ● InvokeDynamic & Method handles ● Finalizer ● Security manager ● JVMTI, JMX, native VM Interfaces OK with caveats in usage ● Reflection (manual list) ● Dynamic proxy (manual list) ● JNI (manual list) ● Static initializers (eager) ● References (similar) The “Good” Parts
  31. 31. bit.ly/dkquarkus2019 32 Drives the gathering of metadata needed by GraalVM GraalVM specific benefits ● based on framework knowledge ● Classes using reflection, resources, etc Minimize dependencies Help dead code elimination
  32. 32. 33 JIT - OpenJDK HotSpot When to use which VM with Quarkus High memory density requirements High request/s/MB Fast startup time Best raw performance (CPU) Best garbage collectors Higher heap size usage Known monitoring tools Compile Once, Run anywhere Libraries that only works in standard JDK AOT - GraalVM native image Highest memory density requirements Highest request/s/MB for low heap size usages Faster startup time 10s of ms for Serverless
  33. 33. When to use which VM with Quarkus 34
  34. 34. More is better
  35. 35. bit.ly/dkquarkus2019 36 @QuarkusTest public class HelloResourceTest { @Inject HelloService service; @Test public void testHelloEndpoint() { assertEquals( "Hello Quarkus", service.greeting("Quarkus") ); } } Fast start Testing is running Injection Full start
  36. 36. bit.ly/dkquarkus2019 37 @Entity public class Todo extends PanacheEntity { // id is inherited public String title; public boolean completed; public String url; public static List<Todo> findNotCompleted() { return list("completed", false); } } @Path("/api") public class TodoResource { @GET public List<Todo> getAll() { return Todo.listAll(Sort.by("order")); } } @Entity public class Todo { @Id @GeneratedValue public Long id; public String title; public boolean completed; public String url; } @ApplicationScoped public class TodoRepo extends PanacheRepository<Todo> { public List<Todo> findNotCompleted() { return list("completed", false); } } @Path("/api") public class TodoResource { @Inject TodoRepo repo; @GET public List<Todo> getAll() { return repo.listAll(Sort.by("order")); } } ActiveRecord or Repository pattern
  37. 37. 38
  38. 38. 39 Developer Joy Quarkus Benefits Supersonic Subatomic Java Unifies imperative and reactive Best of breed libraries and standards
  39. 39. 40
  40. 40. 41 1. It is a surprise 2. It has a major impact “ 3. People contend that they expected the event to happen (in hindsight)
  41. 41. 42
  42. 42. 43
  43. 43. Quarkus Hands-on Just VM Development: - Java 8 or 11 - Use code.quarkus.io to create your first app - Notepad (or VSCode, Eclipse, Intellij,...) For Native: - Java 8 - GraalVM 19.2.1 - Docker (if on Windows) Ideas for things to do: - quarkus.io/get-started - quarkus.io/guides/ - quarkus.io/guides/writing-extensions - Ascii Banner from png - Quarkus enable your favorite framework - quarkus.io/quarkus-workshops/super-hero s - 6-8 hours - Own ideas ? bit.ly/dkquarkus2019 44

×