Q U A R K U S & G R A A L V M Q U A R K U S & G R A A L V M
booting Hibernate at supersonic speed, subatomic size @SanneGrinovero
Q U A R K U S & G R A A L V M Q U A R K U S & G R A A L - - PowerPoint PPT Presentation
Q U A R K U S & G R A A L V M Q U A R K U S & G R A A L V M booting Hibernate at supersonic speed, subatomic size @SanneGrinovero S A N N E G R I N O V E R O S A N N E G R I N O V E R O Dutch, Italian, now in London. S A N N E
booting Hibernate at supersonic speed, subatomic size @SanneGrinovero
Dutch, Italian, now in London.
Dutch, Italian, now in London. Red Hat : Middleware R&D
▪
Quarkus, engineering team
▪
Dutch, Italian, now in London. Red Hat : Middleware R&D
▪
Quarkus, engineering team
▪
Also contributing to:
Infinispan, Elasticsearch, JGroups, Byteman, Maven, Gradle, PostgreSQL, JakartaEE, Thorntail, ANTLR, Asciidoctor, ...
▪
GraalVM & native images
$ export GRAALVM_HOME= //path to your GraalVM download, unpacked $ export JAVA_HOME=$GRAALVM_HOME $ mvn package $ native-image -jar main.jar $ ./main
How about more complex apps?
used by Quarkus
A o T c o m p i l a t i o n w i t h G r a a l V M A o T c o m p i l a t i o n w i t h G r a a l V M
Application classes JDK API classes SubstrateVM classes Staticaly linked executable
A o T c o m p i l a t i o n w i t h G r a a l V M A o T c o m p i l a t i o n w i t h G r a a l V M
Static analysis
classes, fields, methods, branches
Deloying jars, wars, etc. at runtime impossible
+ other native VM interfaces
+ other native VM interfaces No agents
+ other native VM interfaces No agents JRebel, Byteman, profilers, tracers, ...
+ other native VM interfaces No agents JRebel, Byteman, profilers, tracers, ... No Java Debugger
No: Security Manager No: finalize() (deprecated anyway) Limited: InvokeDynamic and MethodHandles
Requires registration via native-image CLI/API
Need to register in advance also:
Dynamic proxies
Attempts to run them at build time
Attempts to run them at build time
Resolve classes, run "safe" static initializers
Attempts to run them at build time
Resolve classes, run "safe" static initializers
prune the unreachable ones
Attempts to run them at build time
Resolve classes, run "safe" static initializers
prune the unreachable ones
not allowed: file handles, sockets, threads
dependent constants, capturing environment variables, etc..
boolean jmxEnabled = parseConfiguration(...); if (jmxEnabled) { registerJMX(); }
boolean jmxEnabled = parseConfiguration(...); if (jmxEnabled) { registerJMX(); } static final JMX_ENABLED = false; if (JMX_ENABLED) { registerJMX(); }
All your dependencies need to get compiled too!
All your dependencies need to get compiled too! ALL DEPENDENCIES
Mindmap #3
and
for writing Java applications
and
for writing Java1 applications
1) and Kotlin
Helps overcome limitations of GraalVM Embraces them!
*.class QUARKUS
native executable JVM
Maven/Gradle plugin
Each Java library gets a Quarkus extension Makes it compatible with GraalVM native-images And makes it much lighter to run on JVM
L I B R A R I E S Y O U A L R E A D Y K N O W L I B R A R I E S Y O U A L R E A D Y K N O W
ECLIPSE VERT.X HIBERNATE RESTEASY APACHE CAMEL NETTY KUBERNETES JAEGER PROMETHEUS APACHE KAFKA INFINISPAN
Unifies
and R E A C T I V E
@Inject SayService say; @GET @Produces(MediaType.TEXT_PLAIN) public String hello() { return say.hello(); } @Inject @Stream("kafka") Publisher<String> reactiveSay @GET @Produces(MediaType.SERVER_SEN public Publisher<String> stre return reactiveSay; }
Small size on disk Small container images 💿 ✓
Small size on disk Small container images Fast boot time Instant scale up 💿 ✓ 🚁 ✓
Small size on disk Small container images Fast boot time Instant scale up Low RSS1 memory
1) Resident Set Size
More containers with the same RAM 💿 ✓ 🚁 ✓ 🔭 ✓
= all RAM consumed by the process RSS
$ ps -o pid,rss,command -p $(pgrep quarkus) PID RSS COMMAND 11229 12628 ./target/quarkus-hello
Quarkus + GraalVM Quarkus + OpenJDK Best of traditio
Quarkus + GraalVM Quarkus + OpenJDK Best of traditio
Quarkus + GraalVM Quarkus + OpenJDK Best of traditio
Often frameworks use lazy initialization "started" before all classes are initialized
Often frameworks use lazy initialization "started" before all classes are initialized
T I M E T O F I R S T R E Q U E S T T I M E T O F I R S T R E Q U E S T
s + GraalVM 0.014 sec Quarkus + OpenJDK 0.75 sec Traditional Cloud-Native Stack 4.3 sec
s + GraalVM 0.014 sec Quarkus + OpenJDK 0.75 sec Traditional Cloud-Native Stack 4.3 sec
JPA
s + GraalVM 0.055 sec Quarkus + OpenJDK 2.5 sec Traditional Cloud-Native Stac
Show me! Demo #2
*.class QUARKUS
native executable JVM
Maven/Gradle plugin
XML parsers, annotation lookups, management model, ... Thousands of classes run only during the boot
Quarkus:
As much work as possible done at build time Output: recorded wiring bytecode Application model validation
Flexible static initializer OR main()
preferred access to files, sockets, etc.
Required for frameworks that hit GraalVM limitations
runtime: extemely lean output!
Invoke Quarkus helpers to dynamically Interact with the GraalVM compiler needs
Makes Java the #1 choice for the cloud and serverless Good old Java
✓
More fun, less weight
✓
Can go small as Go, works great on JVM too
✓
Early days!
Early days! Yet based on proven libraries
Q & A Q & A
Docs & guides:
✓
quarkus.io Chat:
✓
quarkusio.zulipchat.com Quickstarts:
✓
github.com/quarkusio/quarkus-quick Stack Overflow tag:
✓
quarkus Twitter:
✓
@quarkusio
https://quarkus.io/get-started/
$ mvn io.quarkus:quarkus-maven-plugin:0.13.3:create \
$ mvn package $ java -jar target/*-runner.jar INFO [io.quarkus] (main) Quarkus 0.11.0 started in 0.729s. INFO [io.quarkus] (main) Installed features: [cdi, resteasy]
https://quarkus.io/guides/building-native-image-guide
$ mvn package -Pnative $ ls -lh target/*-runner
$ ./target/*-runner INFO [io.quarkus] (main) Quarkus 0.13.3 started in 0.003s. INFO [io.quarkus] (main) Installed features: [cdi, resteasy]
https://quarkus.io/guides/getting-started-guide
$ mvn compile quarkus:dev
@QuarkusTest runner JUnit 4 or 5
https://quarkus.io/guides/getting-started-guide#testing
$ mvn clean test
@SubstrateTest runner
https://quarkus.io/guides/building-native-image-guide.html#testing-the-native- executable
$ mvn clean verify -Pnative
https://quarkus.io/guides/maven-tooling.html
$ mvn quarkus:add-extension -Dextensions=hibernate-orm-panache
Makes simple Hibernate ORM easy
https://quarkus.io/guides/hibernate-orm-panache-guide
@Entity public class Person extends PanacheEntity { public String name; public LocalDate birth; public PersonStatus status; }
https://quarkus.io/guides/hibernate-orm-panache-guide
// Create a person Person person = new Person(); person.name = "Stef"; // Persist and delete person.persist(); person.delete();
Discover them
https://quarkus.io/guides/maven-tooling.html
$ mvn quarkus:list-extensions ... Available extensions: ... * Hibernate ORM (io.quarkus:quarkus-hibernate-orm) * Hibernate ORM with Panache (io.quarkus:quarkus-hibernate-orm-panache) * Hibernate Validator (io.quarkus:quarkus-hibernate-validator) ...
Contribute them!
https://github.com/quarkusio
ASL2
✓
Open community
✓