Java hat ein Problem. Es ist für die Cloud-Native Welt zu Ressourcen fressend. Mit Quarkus und der GraalVM gibt es eine Möglichkeit das Problem anzugehen. Die Präsentation wurde in folgendem MeetUp gehalten: https://www.meetup.com/de-DE/IBM-Hybrid-Multi-Cloud-Munich/events/262893313/
4. 4 Part of
WLP 19.0.0.6 WebProfile
~ 5s
Wildfly 17.0.1 Servlet-Only
~ 3s
Spring Boot 2.1.6.RELEASE mit Spring Web Starter
~ 3s
+ WarmUp HotSpot-Engine
Startzeit
5. 5 Part of
WLP 19.0.0.6 WebProfile
verwendet ca. 220 MB
Wildfly 17.0.1 Servlet-Only
verwendet ca. 180 MB
Spring Boot 2.1.6.RELEASE mit Spring Web Starter
verwendet ca. 230 MB
Arbeitsspeicher
6. 6 Part of
Ist das ein Problem?
App A
App B
App C
App A
App B
App C
App A
App B
App C
App B
App C App C
7. 7 Part of
Ist das ein Problem?
App A App A1 App A2 App A3
8. 8 Part of
Ist das ein Problem?
https://cloud.google.com/compute/pricing
9. 9 Part of
Ist das ein Problem?
https://cloud.ibm.com/kubernetes/catalog/cluster
10. 10 Part of
Ist das ein Problem?
https://run.pivotal.io/pricing/
11. 11 Part of
Wohin geht die Zukunft?
Function as a Service / Serverless
IoT
Long running processes?
Cattle vs. Pets
Automatische Skalierung
Ist das ein Problem?
13. 13 Part of
Open Source Cloud Native, Container first framework for Java
Apache License v2.0
Ziel: Minimaler Footprint
Setzt auf Standards (Microprofile) und Frameworks, die sich bereits bewiesen haben
Baut auf GraalVM auf
Est. März 2019
https://quarkus.io
https://github.com/quarkusio/quarkus
Quarkus
!
14. 14 Part of
The goal of Quarkus is to make Java a leading
platform in Kubernetes and serverless
environments while offering developers a
unified reactive and imperative programming
model to optimally address a wider range of
distributed application architectures.
https://developers.redhat.com/blog/2019/03/07/quarkus-next-generation-kubernetes-native-java-framework/
Jason Greene
Quarkus Co-Founder, Distinguished
Engineer and Manager, Red Hat
15. 15 Part of
Native Image
JVM Mode
Quarkus: JVM Mode vs. Native Image
Todo-Service
todo-runner.jar
todo-runner
SubstrateVM
17. 17 Part of
Quarkus – Startzeit und Speicherverbrauch (eigene Angabe)
https://quarkus.io/
18. 18 Part of
0
1
2
3
4
5
6
7
8
Startzeit [s]
Liberty
Quarkus
JVM
Quarkus
Native
Startzeit
Ausführung inkl. Starten eines Docker-Containers
Aufruf mit Zugriff auf die Datenbank
2 fache Ausführung, Mittelwert
Zeit bis Beantwortung des 1. Requests
Messung analog zu
https://quarkus.io/guides/performance-
measure#how-do-we-measure-startup-time
19. 19 Part of
0
20
40
60
80
100
120
140
160
Memory Usage
[mb]
Liberty
Quarkus
JVM
Quarkus
Native
RAM-Verbrauch
Anwendungen in Docker-Container gestartet
Mind. 1 Request pro Anwendung (inkl. Zugriff auf
Datenbank)
docker stats -a
20. 20 Part of
0
50
100
150
200
250
300
350
400
450
Docker-Image-
Size [mb]
Liberty
Quarkus
JVM
Quarkus
Native
Docker-Image-Size
Für WLP wurde das offizielle Image genommen
https://hub.docker.com/_/websphere-liberty/
Kernel
Für Quarkus wurden die mitgelieferten Dockerfiles
verwendet
Es wurde nicht weiter optimiert
21. 21 Part of
Quarkus Module
Quarkus Extensions
Quarkus Core
Jandex Gizmo Graal SDK
JVM Substrate
22. 22 Part of
Runtime -> Buildtime
Verzicht auf Reflection so gut es geht
Recorded Bytecode
Kein Config Parsen zur Laufzeit
Metadata Processing (Annotations, Getter & Setter)
Aufrufe vorbereiten (Proxy, Interfaces, …)
Unnötige Klassen werden nicht geladen
23. 23 Part of
GraalVM is a Java VM and JDK based on
HotSpot/OpenJDK, implemented in Java. It supports
additional programming languages and execution
modes, like ahead-of-time compilation of Java
applications for fast startup and low memory footprint.
GraalVM
https://en.wikipedia.org/wiki/GraalVM
24. 24 Part of
Edition
GraalVM CE (OpenSource, GPLv2 License)
GraalVM EE
Production Ready seit Mai 2019 (Version 19.0)
Unterstützt Linux und MacOS (an Windows wird gearbeitet)
Contributors
Industrie
Forschung (Ausschnitt)
Johannes Kepler University Linz, TU Berlin, University of Edinburgh, TU Dortmund, University of Lugano
https://www.graalvm.org/community/contributors/
GraalVM
!
25. 25 Part of
AoT – Compiler (Ahead of Time)
Closed World Assumption
Output: Native Executable
Kein Bytecode mehr!
Analyse, welche Klassen erreicht werden
können
Vorsicht vor Reflection!
Programm wird während Build-Prozess
ausgeführt
Image Heap
Static Initializer
Native Image
26. 26 Part of
Dynamic Class Loading nicht möglich
Reflection eingeschränkt möglich
Dynamic Proxy eingeschränkt möglich
JNI & Unsafe Memory Access „mostly
supported“
JMX nicht möglich
https://github.com/oracle/graal/blob/master/s
ubstratevm/LIMITATIONS.md
Limitations Native Image
27. 27 Part of
Native Image: Optimierung RAM & Boot-Time
Long running processes?
JIT nur im JVM Mode
Performance bzgl.
Durchsatz?
Antwortzeiten?
Skalierung?
Native Image vs. JVM Mode
30. 30 Part of
Für Migrationsprojekte
u.a. kein EJB und JMS support
Einschränkung der Libraries! (siehe Limitations)
Buildprozess (Native Image)
Infrastruktur muss während des Builds vorhanden sein
Benötigt viel Arbeitsspeicher
Benötigt Zeit
Zu beachten
35. 35 Part of
Just In Time (JIT) – Compiler benötigen CPU-Zyklen und
Speicher
Greifen v.a. bei langlaufenden Prozessen
JIT-Compiler
App C
JIT
App C
JIT
App C
JIT
36. 36 Part of
Konkurrenz zu GraalVM: JITaaS by OpenJ9
App C
JIT
App C
JIT
App C
JIT
JIT
JIT as a Service
https://github.com/eclipse/openj9/tree/jitaas
37. 37 Part of
Software Engineering ist eine Kunst.
Sie erfordert die Tugenden eines Ingenieurs.
Hinweis der Redaktion
Fokus Java bisher: Long running process.
2 tWAS Instanzen > Jede App hat eigenen Server
Monolith > Microservice
Story Franzl: Horizontal Auto Scaler mit RAM. Sofort waren alle 10 Instanzen da, weil falsch konfiguriert…
… zeigt, dass es gut ist, wenn die Anwendung wenig RAM verbraucht, aber war im Grunde eine Fehlkonfiguration… kA ob das Beispiel passend ist (wahrscheinlich eher nicht)
Demogott anbeten!
Wie sieht die Anwendung aus
Wie baut man die Anwendung
Dev-Mode
Native Image bauen
Extension = Runtime & Buildtime
The compiler depends on a JDK that supports a compatible version of JVMCI (JVM Compiler Interface).
Beispiel mit Datum in static initializer: buuuuh blöd. Dafür kommt das native image aber mit reflection im static initializer klar -> logisch, da wird’s noch in der jvm ausgeführt
The native executable contains not just code, but also an initial heap that serves as the starting point of the Java heap at run time. We call this initial heap the “image heap”. The image heap allows us to skip class initialization at run time, which is crucial for fast startup. While a traditional Java VM needs to run the
class initializers of many core JDK classes before the main method of your application starts running, the native executable calls your main method quite directly.
https://medium.com/graalvm/understanding-class-initialization-in-graalvm-native-image-generation-d765b7e4d6ed