1
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
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
bit.ly/dkquarkus2019 6
The hidden truth about Java + containers
7
8
Reactive
Imperative
9
10
QUARK: elementary particle / US: hardest thing in computer science
12
A cohesive platform for optimized developer joy:
●
●
●
●
●
Benefit No. 1: Developer Joy
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
● 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
bit.ly/dkquarkus2019 15
The hidden truth about Java + containers
16
Benefit No. 2: Supersonic Subatomic Java
Quarkus + AOT
19 MB
Quarkus + OpenJDK (JIT)
77 MB
Traditional Cloud-Native Stack
140 MB
17
Benefit No. 2: Supersonic Subatomic Java
Quarkus + AOT
35 MB
Quarkus + OpenJDK (JIT)
130 MB
Traditional Cloud-Native Stack
218 MB
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
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
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
Benefit No. 4: Best of Breed Frameworks & Standards
22
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
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
26
JDK JIT - HotSpot AOTC - GraalVM Native Image
27
bit.ly/dkquarkus2019 28
An ahead-of-time, build-time, runtime
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
Closed-world assumption
bit.ly/dkquarkus2019 30
AOTC - GraalVM - Dead code elimination
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
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
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
When to use which VM with Quarkus
34
More is better
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
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
38
39
Developer Joy
Quarkus Benefits
Supersonic Subatomic Java
Unifies
imperative and reactive
Best of breed
libraries and standards
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)
42
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

Quarkus Denmark 2019

  • 1.
  • 2.
    Quarkus Hands-on Just VMDevelopment: - 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.
  • 4.
    4 1. It isa surprise 2. It has a major impact “ 3. People contend that they expected the event to happen (in hindsight)
  • 5.
  • 6.
    bit.ly/dkquarkus2019 6 The hiddentruth about Java + containers
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
    QUARK: elementary particle/ US: hardest thing in computer science
  • 12.
    12 A cohesive platformfor optimized developer joy: ● ● ● ● ● Benefit No. 1: Developer Joy
  • 13.
    From monolith to... bit.ly/dkquarkus201913 ● 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.
    ● Designed forthroughputs (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.
    bit.ly/dkquarkus2019 15 The hiddentruth about Java + containers
  • 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 Benefit No. 2:Supersonic Subatomic Java Quarkus + AOT 35 MB Quarkus + OpenJDK (JIT) 130 MB Traditional Cloud-Native Stack 218 MB
  • 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.
    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 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 Benefit No. 4:Best of Breed Frameworks & Standards
  • 22.
  • 24.
    bit.ly/dkquarkus2019 24 What doesa 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
  • 25.
    bit.ly/dkquarkus2019 25 Do thework 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
  • 26.
    26 JDK JIT -HotSpot AOTC - GraalVM Native Image
  • 27.
  • 28.
  • 29.
    Quarkus Hands-on requirements JustVM 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
  • 30.
  • 31.
    bit.ly/dkquarkus2019 31 Not supported TheDark 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
  • 32.
    bit.ly/dkquarkus2019 32 Drives thegathering of metadata needed by GraalVM GraalVM specific benefits ● based on framework knowledge ● Classes using reflection, resources, etc Minimize dependencies Help dead code elimination
  • 33.
    33 JIT - OpenJDKHotSpot 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
  • 34.
    When to usewhich VM with Quarkus 34
  • 35.
  • 36.
    bit.ly/dkquarkus2019 36 @QuarkusTest public classHelloResourceTest { @Inject HelloService service; @Test public void testHelloEndpoint() { assertEquals( "Hello Quarkus", service.greeting("Quarkus") ); } } Fast start Testing is running Injection Full start
  • 37.
    bit.ly/dkquarkus2019 37 @Entity public classTodo 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
  • 38.
  • 39.
    39 Developer Joy Quarkus Benefits SupersonicSubatomic Java Unifies imperative and reactive Best of breed libraries and standards
  • 40.
  • 41.
    41 1. It isa surprise 2. It has a major impact “ 3. People contend that they expected the event to happen (in hindsight)
  • 42.
  • 43.
  • 44.
    Quarkus Hands-on Just VMDevelopment: - 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