Technical expert & |
Technical Architect & Innovation Estratego @ VASS Associate Professor @ ICAI JVM Builder for ARM5 @ Eclipse Adoptium @juanantoniobm | Github | Linkedin |
GraalVM is the next Java Virtual Machine Generation and it includes multiple new features but in this presentation, we will put the focus on: Native Images
Traditionally, Java applications are called WORA (Write Once Run Anywhere).
But in some scenarios, 147MB is Ok, but in others is so much...
It is the amount of time a product goes from being introduced into the market until it is taken off the shelves.
In the book Crossing the Chasm, Geoffrey A. Moore begins with the diffusion of innovations theory from Everett Rogers, and argues there is a chasm between the early adopters of the product (the technology enthusiasts and visionaries) and the early majority (the pragmatists).
In what stage is GraalVM and Native Images?
Types of Innovation:
Is this feature, compatible with your Evolutionary architecture?
Is Java HotSpot Virtual Machine at the end of the product life cycle?
Is Java HotSpot Virtual Machine at the end of the product life cycle?
In 2021, exist so much interest in Java HotSpot Virtual Machine.
Is Java HotSpot Virtual Machine at the end of the product life cycle?
Is Java HotSpot Virtual Machine at the end of the product life cycle?
Is Java HotSpot Virtual Machine at the end of the product life cycle?
"I don´t know Rick, it seems false."
Microservices running as Native images from a GraalVM compilation have better performance than Microservices running on Java HotSpot Virtual Machine?
Source: https://blogs.oracle.com/javamagazine/pedal-to-the-metal-high-performance-java-with-graalvm-native-image
Microservices running as Native images from a GraalVM compilation have better performance than Microservices running on Java HotSpot Virtual Machine?
"How to verify that hypothesis?"
Is it easy or complex to create native images from your Spring Boot applications?
Quarkus was designed with that feature in mind.
1. We add the Spring Native dependency
2. We added the plugin to compile Native images
3. Enable native image support (using Spring Boot’s Cloud Native Buildpacks support)
4. Added a maven profile to compile Native images
Install GraalVM:
sdk use java 21.1.0.r11-grl
Gu install native-image
Generate the native image from Spring Boot:
mvn clean package -pl imperative-api -P native-image
After few minutes compiling...
Git repository tour:
"Rick, show me the project!"
Experiment: Develop a Microservice which connect with a Database (PostgreSQL) and the logic use ORM Features (In the cases that it is possible) and SQL (Native Query) but in a non trivial queries trying to test the performance of that dependencies.
We implemented the experiment with:
And... We added Node.js in the salad too...
Because we can do it!
That developments was implemented and included in a Docker compose running the microservices with Postgresql (One database container per microservice to avoid possible side effects)
With the Docker compose running with the microservices connected with their databases, we running a JMeter script pointing for:
We run the JMeter 10x to collect some reports to analyze later.
Hardware used in the experiments:
iMac 4.2 GHz 4-core Intel Core i7 processor
32 GB 2400 MHz DDR4
Throughput results:
HTTP Request - Spring Imperative JDBC (Native) jvm 21.2766
HTTP Request - Spring Reactive jvm 18.53912
HTTP Request - Spring Imperative JDBC (Native) jvm 18.02127
HTTP Request - Spring Imperative JDBC (Native) jvm 17.96945
HTTP Request - Spring Imperative JDBC (Native) jvm 16.28664
HTTP Request - Spring Imperative JDBC (Native) jvm 15.37752
HTTP Request - Spring Reactive jvm 15.03986
HTTP Request - Spring Reactive jvm 14.9723
HTTP Request - Spring Imperative JDBC (Native) jvm 14.56876
HTTP Request - Nodejs native 13.95868
Compare the best Throughput result between JVM Hotspot and Native image:
HTTP Request - Spring Imperative JDBC (Native) jvm 21.2766
HTTP Request - Spring Imperative JDBC (Native) native 13.40123
The Throughput from JVM Hotspot is about 63% greater than using Native Images generated by GraalVM CE.
Compare the best Throughput result among different Spring options:
Spring Imperative JDBC (Native) jvm 21.2766
Spring Imperative JPA (ORM) jvm 1.90494
Spring Reactive jvm 18.53912
Compare the best Throughput result among different event-loop options:
Spring Reactive jvm 18.53912
Quarkus Reactive jvm 12.32894
Nodejs native 13.95868
Maybe the graph should be upgraded because it is greather the performance with JVM Hotspot.
Throughput results:
"Rick, show me your sources!"
Start up times:
The whole project, performance data are here:
https://github.com/EstefaniaExamples/crossing-the-chasm-native-imagesThanks