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
12. 12
A cohesive platform for optimized developer joy:
●
●
●
●
●
Benefit No. 1: Developer Joy
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. ● 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
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
24. 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
25. 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
29. 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
31. 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
32. 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. 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
36. 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
37. 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
44. 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