SlideShare a Scribd company logo
A Glance at
The Java Performance
Toolbox
Java Champion Alumni, Certified Architect
Senior Developer Advocate at Oracle
Passionate about solving complex scenarios involving
Java and Kubernetes.
ammbra1508 ammbra1508.mastondon.social
What does application
performance mean?
Performance experienced by end-
users
Computational resources used by
the application
Performance Metrics
CPU Usage
Memory Usage
Error rates
User satisfaction (Apdex scores)
Average response time
Request rates
Latency and uptime
Throughput
More Questions Using Java Applications in
Containers
• Which JDK tools help you create container images with only what is needed at
runtime?
• How to run the JDK tools in containers and proxy their output?
• Which tools help you fine tune the JVM flags and keep application overhead at
minimum?
• How to capture performance relevant JVM and application events?
• How to correlate data from JVM monitoring tools with the one from tools like
Prometheus, Grafana?
Which tools help you create
container images with only what
is needed at runtime?
Tools to build an OCI Compliant Image
• Docker build
• Buildpacks
• Jib
• kaniko
• buildah
• s2i
• And many more J
The Good Old Dockerfile
The Good Old Dockerfile
Use a small base image
The Good Old Dockerfile
Use a small base image
Create images with common layers
The Good Old Dockerfile
Use a small base image
Install only what is strictly needed
Create images with common layers
JDK tools that shape
efficient Java Runtimes for
Container Images
jlink
JEP 282 “Link time is an opportunity to do whole-world optimizations that are
otherwise difficult at compile time or costly at run-time”
jlink: Command Line Tool to Link Modules
• Modules in a jimage file
• Generate runtime images
Jlink packaging
Legacy JDK image
JDK > 9 generated image
bin jre lib
bin conf ……..
Modular runtime image
jlink
Maintain The Good Old Dockerfile with jlink
The runtime stage build
• From a JDK base image
• Create your own custom JRE with jlink
Maintain The Good Old Dockerfile with JLink
The runtime stage build
• From a JDK base image
• Create your own custom JRE with jlink
The application stage build
• From an OS base image
• Copy the custom JRE from the runtime stage build
• Copy the artifacts needed by your application
• Run the application
The Runtime Stage Build
The Runtime Stage Build
jdeps --ignore-missing-deps -q -recursive 
--multi-release 21 --print-module-deps 
--class-path 'target/libs/*' 
target/spring-todo-app.jar
The Runtime Stage Build
Exclude man pages and header files
The Runtime Stage Build
Enable compression of resources:
0: No compression
1: Constant string sharing
2: ZIP
The Application Stage Build
Copy the custom JRE
The Application Stage Build
Copy the artifacts needed by your application
The Application Stage Build
Run the application
How about fine tuning
JVM Flags?
Conserving Dynamic Footprint by
Minimizing Java Heap Size
Start by looking at the JVM ergonomics
Conserving Dynamic Footprint by
Minimizing Java Heap Size
Start by looking at the JVM ergonomics
At initialization of the virtual machine, the entire space for the heap is reserved.
Eg: setting for minimum and maximum heap size: -Xms768m -Xmx768m
Conserving Dynamic Footprint by
Minimizing Java Heap Size
Start by looking at the JVM ergonomics
At initialization of the virtual machine, the entire space for the heap is reserved.
Eg: setting for minimum and maximum heap size: -Xms768m -Xmx768m
Minimize Java heap size by lowering the values of the options:
• -XX:MaxHeapFreeRatio (default value is 70%)
-XX:MinHeapFreeRatio (default value is 40%)
• Eg:-XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=70
What if the problem is not
the amount of resources
allocated to/by the JVM?
Tracking Native Memory With Jcmd
Add jdk.jcmd module
Tracking Native Memory With Jcmd
Overusing jcmd to send diagnostic commands can affect the performance of the VM.
Tracking Native Memory With Jcmd
Overusing jcmd to send diagnostic commands can affect the performance of the VM.
-XX:NativeMemoryTracking={off|summary|detail}
• kubectl set env deployment/app JDK_JAVA_OPTIONS=“-XX:NativeMemoryTracking=summary”
• Please consider that having NMT enabled can add application performance overhead.
Tracking Native Memory With Jcmd
Overusing jcmd to send diagnostic commands can affect the performance of the VM.
Add -XX:NativeMemoryTracking={off|summary|detail} to JDK_JAVA_OPTIONS
Create a native memory baseline
kubectl exec pod_name –it --/bin/bash -c "jcmd llvmid VM.native_memory baseline"
Tracking Native Memory With Jcmd
Overusing jcmd to send diagnostic commands can affect the performance of the VM.
Add -XX:NativeMemoryTracking={off|summary|detail} to JDK_JAVA_OPTIONS
Create a native memory baseline
kubectl exec pod_name –it --/bin/bash -c "jcmd llvmid VM.native_memory baseline"
Create a native memory summary diff
kubectl exec pod_name –it --/bin/bash -c "jcmd llvmid VM.native_memory summary.diff"
Performance and
Resource Consumption
Overview information about the Java VM and
monitored values.
Information about memory use.
Information about thread use.
Information about class loading.
Information about the Java VM.
Information about MBeans
Get Statistics About
Running Java Processes
Obtain Statistics with jstat and jmap
Obtain statistics about garbage collectors by running jstat
kubectl exec pod_name –it --/bin/bash -c "jstat -gcutil llvmid 500 50"
Obtain Statistics with Jstat and Jmap
Obtain statistics about garbage collectors by running jstat
kubectl exec pod_name –it --/bin/bash -c "jstat -gcutil llvmid 500 50"
Print heap summaries
kubectl exec pod_name –it --/bin/bash -c "jmap -histo llvmid"
Capture Performance
Relevant JVM And
Application Events
When to Use Profiling
“To consume the data today, a user must start a recording, stop it, dump the
contents to disk and then parse the recording file. This works well for
application profiling, where typically at least a minute of data is being
recorded at a time, but not for monitoring purposes.“
source: JEP 349
Add JFR To Your Container Image
Add jdk.jfr module
How to use JFR
Enable JFR in JDK_JAVA_OPTIONS
kubectl set env deployment/app JDK_JAVA_OPTIONS=“--XX:StartFlightRecording:..”
For example, start a time fixed recording with default profile
-XX:StartFlightRecording=delay=10s,duration=10m,name=Default,settings=default
Use the diagnostic command:
kubectl exec pod_name –it --/bin/bash -c "jcmd llvimd JFR.start…"
Monitor and React
…..
AppTarget 1
AppTarget 2
AppTarget n
Prometheus server
Pull metrics
Pull metrics
Pull metrics
Gathering metrics
Visualizing metrics
Alerting
Streaming selected metrics to your
monitoring service
Where to Use JFR
Event Streaming
Stream selected metrics to your
monitoring service
Send an average, min, max, etc of a metric
Where to Use JFR
Event Streaming
Stream selected metrics to your
monitoring service
Send an average, min, max, etc of a metric
Expose JFR data through other
management APIs
Where to Use JFR
Event Streaming
Make your settings by extending
jdk.jfr.SettingControl
Recording Custom
JFR Events
Make your settings by extending
jdk.jfr.SettingControl
Create your custom event by extending
jdk.jfr.Event
Recording Custom
JFR Events
Recording Custom
JFR Events
Make your settings by extending
jdk.jfr.SettingControl
Create your custom event by extending
jdk.jfr.Event
Register the custom settings in your custom
event via
@jdk.jfr.SettingsDefinition
Recording Custom Events in Spring Boot
(example)
Capture the custom JFR events in a dedicated filter and register it
Recording Custom Events in Spring Boot
(example)
Listen the custom JFR events and record their duration
Takeaways
Use jlink to create a
minimal custom
JRE.
Send diagnostic
commands to a
running JVM via
jcmd.
Inspect
performance
statistics
Profile your
application with jfr.
Stream preferred
JVM metrics to
your monitoring
service with JFR
Event Streaming
API.
Thank You!
https://github.com/ammbra/performance-glance
Useful Links
• Article https://www.javaadvent.com/2022/12/a-sneak-peek-at-the-java-performance-toolbox.html
• Tools https://docs.oracle.com/en/java/javase/21/docs/specs/man/index.html
• jlink https://dev.java/learn/jlink/
• Troubleshoot Memory Leaks: https://docs.oracle.com/en/java/javase/21/troubleshoot/troubleshooting-memory-
leaks.html
• JFR Runtime guide : https://docs.oracle.com/javacomponents/jmc-5-4/jfr-runtime-guide/about.htm#JFRUH170
• Innovative JFR use by @gunnarmorling: https://www.morling.dev/blog/finding-java-thread-leaks-with-jdk-flight-
recorder-and-bit-of-sql/
• @gunnarmorling article on custom JDK Flight Recorder Events
• Great intro by @BillyKorando https://www.youtube.com/watch?v=K1ApBZGiT-Y
• Stack walker episode by @BillyKorando: https://inside.java/2023/05/14/stackwalker-02/

More Related Content

Similar to A Glance At The Java Performance Toolbox

JDK Tools For Performance Diagnostics
JDK Tools For Performance DiagnosticsJDK Tools For Performance Diagnostics
JDK Tools For Performance Diagnostics
Baruch Sadogursky
 
3 rad extensibility-srilakshmi_s_rajesh_k
3 rad extensibility-srilakshmi_s_rajesh_k3 rad extensibility-srilakshmi_s_rajesh_k
3 rad extensibility-srilakshmi_s_rajesh_kIBM
 
Rad Extensibility - Srilakshmi S Rajesh K
Rad Extensibility - Srilakshmi S Rajesh KRad Extensibility - Srilakshmi S Rajesh K
Rad Extensibility - Srilakshmi S Rajesh KRoopa Nadkarni
 
WebSphere Technical University: Top WebSphere Problem Determination Features
WebSphere Technical University: Top WebSphere Problem Determination FeaturesWebSphere Technical University: Top WebSphere Problem Determination Features
WebSphere Technical University: Top WebSphere Problem Determination Features
Chris Bailey
 
Jenkins Pipelines Advanced
Jenkins Pipelines AdvancedJenkins Pipelines Advanced
Jenkins Pipelines Advanced
Oliver Lemm
 
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Docker, Inc.
 
Useful practices of creation automatic tests by using cucumber jvm
Useful practices of creation automatic tests by using cucumber jvmUseful practices of creation automatic tests by using cucumber jvm
Useful practices of creation automatic tests by using cucumber jvm
Anton Shapin
 
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
London Microservices
 
Openshift operator insight
Openshift operator insightOpenshift operator insight
Openshift operator insight
Ryan ZhangCheng
 
Performance Monitoring with Java Flight Recorder on OpenJDK [DEV2406]
Performance Monitoring with Java Flight Recorder on OpenJDK [DEV2406]Performance Monitoring with Java Flight Recorder on OpenJDK [DEV2406]
Performance Monitoring with Java Flight Recorder on OpenJDK [DEV2406]
Hiroaki NAKADA
 
Commit to excellence - Java in containers
Commit to excellence - Java in containersCommit to excellence - Java in containers
Commit to excellence - Java in containers
Red Hat Developers
 
Rapid Development With Docker Compose
Rapid Development With Docker ComposeRapid Development With Docker Compose
Rapid Development With Docker Compose
Justin Crown
 
Build Your Kubernetes Operator with the Right Tool!
Build Your Kubernetes Operator with the Right Tool!Build Your Kubernetes Operator with the Right Tool!
Build Your Kubernetes Operator with the Right Tool!
Rafał Leszko
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by Example
Nalin Goonawardana
 
Swagger codegen tool to generate REST services
Swagger codegen tool to generate REST servicesSwagger codegen tool to generate REST services
Swagger codegen tool to generate REST services
dhanup123
 
Troubleshooting Tools In JDK
Troubleshooting Tools In JDKTroubleshooting Tools In JDK
Troubleshooting Tools In JDK
Poonam Bajaj Parhar
 
ASML_FlightRecorderMeetsJava.pdf
ASML_FlightRecorderMeetsJava.pdfASML_FlightRecorderMeetsJava.pdf
ASML_FlightRecorderMeetsJava.pdf
Miro Wengner
 
SemeruRuntimesUnderTheCover .pptx
SemeruRuntimesUnderTheCover .pptxSemeruRuntimesUnderTheCover .pptx
SemeruRuntimesUnderTheCover .pptx
SumanMitra22
 
Jdk Tools For Performance Diagnostics
Jdk Tools For Performance DiagnosticsJdk Tools For Performance Diagnostics
Jdk Tools For Performance Diagnostics
Dror Bereznitsky
 
DevOps Workflow: A Tutorial on Linux Containers
DevOps Workflow: A Tutorial on Linux ContainersDevOps Workflow: A Tutorial on Linux Containers
DevOps Workflow: A Tutorial on Linux Containers
inside-BigData.com
 

Similar to A Glance At The Java Performance Toolbox (20)

JDK Tools For Performance Diagnostics
JDK Tools For Performance DiagnosticsJDK Tools For Performance Diagnostics
JDK Tools For Performance Diagnostics
 
3 rad extensibility-srilakshmi_s_rajesh_k
3 rad extensibility-srilakshmi_s_rajesh_k3 rad extensibility-srilakshmi_s_rajesh_k
3 rad extensibility-srilakshmi_s_rajesh_k
 
Rad Extensibility - Srilakshmi S Rajesh K
Rad Extensibility - Srilakshmi S Rajesh KRad Extensibility - Srilakshmi S Rajesh K
Rad Extensibility - Srilakshmi S Rajesh K
 
WebSphere Technical University: Top WebSphere Problem Determination Features
WebSphere Technical University: Top WebSphere Problem Determination FeaturesWebSphere Technical University: Top WebSphere Problem Determination Features
WebSphere Technical University: Top WebSphere Problem Determination Features
 
Jenkins Pipelines Advanced
Jenkins Pipelines AdvancedJenkins Pipelines Advanced
Jenkins Pipelines Advanced
 
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
 
Useful practices of creation automatic tests by using cucumber jvm
Useful practices of creation automatic tests by using cucumber jvmUseful practices of creation automatic tests by using cucumber jvm
Useful practices of creation automatic tests by using cucumber jvm
 
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
 
Openshift operator insight
Openshift operator insightOpenshift operator insight
Openshift operator insight
 
Performance Monitoring with Java Flight Recorder on OpenJDK [DEV2406]
Performance Monitoring with Java Flight Recorder on OpenJDK [DEV2406]Performance Monitoring with Java Flight Recorder on OpenJDK [DEV2406]
Performance Monitoring with Java Flight Recorder on OpenJDK [DEV2406]
 
Commit to excellence - Java in containers
Commit to excellence - Java in containersCommit to excellence - Java in containers
Commit to excellence - Java in containers
 
Rapid Development With Docker Compose
Rapid Development With Docker ComposeRapid Development With Docker Compose
Rapid Development With Docker Compose
 
Build Your Kubernetes Operator with the Right Tool!
Build Your Kubernetes Operator with the Right Tool!Build Your Kubernetes Operator with the Right Tool!
Build Your Kubernetes Operator with the Right Tool!
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by Example
 
Swagger codegen tool to generate REST services
Swagger codegen tool to generate REST servicesSwagger codegen tool to generate REST services
Swagger codegen tool to generate REST services
 
Troubleshooting Tools In JDK
Troubleshooting Tools In JDKTroubleshooting Tools In JDK
Troubleshooting Tools In JDK
 
ASML_FlightRecorderMeetsJava.pdf
ASML_FlightRecorderMeetsJava.pdfASML_FlightRecorderMeetsJava.pdf
ASML_FlightRecorderMeetsJava.pdf
 
SemeruRuntimesUnderTheCover .pptx
SemeruRuntimesUnderTheCover .pptxSemeruRuntimesUnderTheCover .pptx
SemeruRuntimesUnderTheCover .pptx
 
Jdk Tools For Performance Diagnostics
Jdk Tools For Performance DiagnosticsJdk Tools For Performance Diagnostics
Jdk Tools For Performance Diagnostics
 
DevOps Workflow: A Tutorial on Linux Containers
DevOps Workflow: A Tutorial on Linux ContainersDevOps Workflow: A Tutorial on Linux Containers
DevOps Workflow: A Tutorial on Linux Containers
 

More from Ana-Maria Mihalceanu

Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Java 22 and Beyond- A Roadmap of Innovations
Java 22 and Beyond- A Roadmap of InnovationsJava 22 and Beyond- A Roadmap of Innovations
Java 22 and Beyond- A Roadmap of Innovations
Ana-Maria Mihalceanu
 
Surveillance de la sécurité des applications Java avec les outils du JDK e...
Surveillance de la sécurité des applications Java  avec les outils du JDK e...Surveillance de la sécurité des applications Java  avec les outils du JDK e...
Surveillance de la sécurité des applications Java avec les outils du JDK e...
Ana-Maria Mihalceanu
 
Monitoring Java Application Security with JDK Tools and JFR Events.pdf
Monitoring Java Application Security with JDK Tools and JFR Events.pdfMonitoring Java Application Security with JDK Tools and JFR Events.pdf
Monitoring Java Application Security with JDK Tools and JFR Events.pdf
Ana-Maria Mihalceanu
 
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
Enhancing Productivity and Insight  A Tour of JDK Tools Progress Beyond Java 17Enhancing Productivity and Insight  A Tour of JDK Tools Progress Beyond Java 17
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
Ana-Maria Mihalceanu
 
Java 21 Language Features and Beyond
Java 21 Language Features and BeyondJava 21 Language Features and Beyond
Java 21 Language Features and Beyond
Ana-Maria Mihalceanu
 
From Java 17 to 21- A Showcase of JDK Security Enhancements
From Java 17 to 21- A Showcase of JDK Security EnhancementsFrom Java 17 to 21- A Showcase of JDK Security Enhancements
From Java 17 to 21- A Showcase of JDK Security Enhancements
Ana-Maria Mihalceanu
 
Java 21 and Beyond- A Roadmap of Innovations
Java 21 and Beyond- A Roadmap of InnovationsJava 21 and Beyond- A Roadmap of Innovations
Java 21 and Beyond- A Roadmap of Innovations
Ana-Maria Mihalceanu
 
How Java 19 Influences the Future of Your High-Scale Applications .pdf
How Java 19 Influences the Future of Your High-Scale Applications .pdfHow Java 19 Influences the Future of Your High-Scale Applications .pdf
How Java 19 Influences the Future of Your High-Scale Applications .pdf
Ana-Maria Mihalceanu
 
The Automation Challenge Kubernetes Operators vs Helm Charts.pdf
The Automation Challenge Kubernetes Operators vs Helm Charts.pdfThe Automation Challenge Kubernetes Operators vs Helm Charts.pdf
The Automation Challenge Kubernetes Operators vs Helm Charts.pdf
Ana-Maria Mihalceanu
 
Exploring Quarkus on JDK 17
Exploring Quarkus on JDK 17Exploring Quarkus on JDK 17
Exploring Quarkus on JDK 17
Ana-Maria Mihalceanu
 
Cloud native resiliency patterns from the ground up
Cloud native resiliency patterns from the ground upCloud native resiliency patterns from the ground up
Cloud native resiliency patterns from the ground up
Ana-Maria Mihalceanu
 
Cloud native resiliency patterns from the ground up
Cloud native resiliency patterns from the ground upCloud native resiliency patterns from the ground up
Cloud native resiliency patterns from the ground up
Ana-Maria Mihalceanu
 
Cloud native resiliency patterns from the ground up
Cloud native resiliency patterns from the ground upCloud native resiliency patterns from the ground up
Cloud native resiliency patterns from the ground up
Ana-Maria Mihalceanu
 
The automation challenge Kubernetes operators vs Helm charts
The automation challenge Kubernetes operators vs Helm chartsThe automation challenge Kubernetes operators vs Helm charts
The automation challenge Kubernetes operators vs Helm charts
Ana-Maria Mihalceanu
 
Cloud native resiliency patterns from the ground up
Cloud native resiliency patterns from the ground upCloud native resiliency patterns from the ground up
Cloud native resiliency patterns from the ground up
Ana-Maria Mihalceanu
 
DevoxxUK 2021 Techniques for maintainable Quarkus applications
DevoxxUK 2021 Techniques for maintainable Quarkus applicationsDevoxxUK 2021 Techniques for maintainable Quarkus applications
DevoxxUK 2021 Techniques for maintainable Quarkus applications
Ana-Maria Mihalceanu
 
The automation challenge: Kubernetes Operators vs Helm Charts
The automation challenge: Kubernetes Operators vs Helm ChartsThe automation challenge: Kubernetes Operators vs Helm Charts
The automation challenge: Kubernetes Operators vs Helm Charts
Ana-Maria Mihalceanu
 
Techniques for maintainable Quarkus applications
Techniques for maintainable Quarkus applicationsTechniques for maintainable Quarkus applications
Techniques for maintainable Quarkus applications
Ana-Maria Mihalceanu
 
Techniques for maintainable Quarkus applications
Techniques for maintainable Quarkus applicationsTechniques for maintainable Quarkus applications
Techniques for maintainable Quarkus applications
Ana-Maria Mihalceanu
 

More from Ana-Maria Mihalceanu (20)

Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Java 22 and Beyond- A Roadmap of Innovations
Java 22 and Beyond- A Roadmap of InnovationsJava 22 and Beyond- A Roadmap of Innovations
Java 22 and Beyond- A Roadmap of Innovations
 
Surveillance de la sécurité des applications Java avec les outils du JDK e...
Surveillance de la sécurité des applications Java  avec les outils du JDK e...Surveillance de la sécurité des applications Java  avec les outils du JDK e...
Surveillance de la sécurité des applications Java avec les outils du JDK e...
 
Monitoring Java Application Security with JDK Tools and JFR Events.pdf
Monitoring Java Application Security with JDK Tools and JFR Events.pdfMonitoring Java Application Security with JDK Tools and JFR Events.pdf
Monitoring Java Application Security with JDK Tools and JFR Events.pdf
 
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
Enhancing Productivity and Insight  A Tour of JDK Tools Progress Beyond Java 17Enhancing Productivity and Insight  A Tour of JDK Tools Progress Beyond Java 17
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
 
Java 21 Language Features and Beyond
Java 21 Language Features and BeyondJava 21 Language Features and Beyond
Java 21 Language Features and Beyond
 
From Java 17 to 21- A Showcase of JDK Security Enhancements
From Java 17 to 21- A Showcase of JDK Security EnhancementsFrom Java 17 to 21- A Showcase of JDK Security Enhancements
From Java 17 to 21- A Showcase of JDK Security Enhancements
 
Java 21 and Beyond- A Roadmap of Innovations
Java 21 and Beyond- A Roadmap of InnovationsJava 21 and Beyond- A Roadmap of Innovations
Java 21 and Beyond- A Roadmap of Innovations
 
How Java 19 Influences the Future of Your High-Scale Applications .pdf
How Java 19 Influences the Future of Your High-Scale Applications .pdfHow Java 19 Influences the Future of Your High-Scale Applications .pdf
How Java 19 Influences the Future of Your High-Scale Applications .pdf
 
The Automation Challenge Kubernetes Operators vs Helm Charts.pdf
The Automation Challenge Kubernetes Operators vs Helm Charts.pdfThe Automation Challenge Kubernetes Operators vs Helm Charts.pdf
The Automation Challenge Kubernetes Operators vs Helm Charts.pdf
 
Exploring Quarkus on JDK 17
Exploring Quarkus on JDK 17Exploring Quarkus on JDK 17
Exploring Quarkus on JDK 17
 
Cloud native resiliency patterns from the ground up
Cloud native resiliency patterns from the ground upCloud native resiliency patterns from the ground up
Cloud native resiliency patterns from the ground up
 
Cloud native resiliency patterns from the ground up
Cloud native resiliency patterns from the ground upCloud native resiliency patterns from the ground up
Cloud native resiliency patterns from the ground up
 
Cloud native resiliency patterns from the ground up
Cloud native resiliency patterns from the ground upCloud native resiliency patterns from the ground up
Cloud native resiliency patterns from the ground up
 
The automation challenge Kubernetes operators vs Helm charts
The automation challenge Kubernetes operators vs Helm chartsThe automation challenge Kubernetes operators vs Helm charts
The automation challenge Kubernetes operators vs Helm charts
 
Cloud native resiliency patterns from the ground up
Cloud native resiliency patterns from the ground upCloud native resiliency patterns from the ground up
Cloud native resiliency patterns from the ground up
 
DevoxxUK 2021 Techniques for maintainable Quarkus applications
DevoxxUK 2021 Techniques for maintainable Quarkus applicationsDevoxxUK 2021 Techniques for maintainable Quarkus applications
DevoxxUK 2021 Techniques for maintainable Quarkus applications
 
The automation challenge: Kubernetes Operators vs Helm Charts
The automation challenge: Kubernetes Operators vs Helm ChartsThe automation challenge: Kubernetes Operators vs Helm Charts
The automation challenge: Kubernetes Operators vs Helm Charts
 
Techniques for maintainable Quarkus applications
Techniques for maintainable Quarkus applicationsTechniques for maintainable Quarkus applications
Techniques for maintainable Quarkus applications
 
Techniques for maintainable Quarkus applications
Techniques for maintainable Quarkus applicationsTechniques for maintainable Quarkus applications
Techniques for maintainable Quarkus applications
 

Recently uploaded

Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 

Recently uploaded (20)

Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 

A Glance At The Java Performance Toolbox

  • 1. A Glance at The Java Performance Toolbox
  • 2.
  • 3. Java Champion Alumni, Certified Architect Senior Developer Advocate at Oracle Passionate about solving complex scenarios involving Java and Kubernetes. ammbra1508 ammbra1508.mastondon.social
  • 5. Performance experienced by end- users Computational resources used by the application
  • 6. Performance Metrics CPU Usage Memory Usage Error rates User satisfaction (Apdex scores) Average response time Request rates Latency and uptime Throughput
  • 7.
  • 8. More Questions Using Java Applications in Containers • Which JDK tools help you create container images with only what is needed at runtime? • How to run the JDK tools in containers and proxy their output? • Which tools help you fine tune the JVM flags and keep application overhead at minimum? • How to capture performance relevant JVM and application events? • How to correlate data from JVM monitoring tools with the one from tools like Prometheus, Grafana?
  • 9. Which tools help you create container images with only what is needed at runtime?
  • 10.
  • 11. Tools to build an OCI Compliant Image • Docker build • Buildpacks • Jib • kaniko • buildah • s2i • And many more J
  • 12. The Good Old Dockerfile
  • 13. The Good Old Dockerfile Use a small base image
  • 14. The Good Old Dockerfile Use a small base image Create images with common layers
  • 15. The Good Old Dockerfile Use a small base image Install only what is strictly needed Create images with common layers
  • 16. JDK tools that shape efficient Java Runtimes for Container Images
  • 17. jlink JEP 282 “Link time is an opportunity to do whole-world optimizations that are otherwise difficult at compile time or costly at run-time” jlink: Command Line Tool to Link Modules • Modules in a jimage file • Generate runtime images
  • 18. Jlink packaging Legacy JDK image JDK > 9 generated image bin jre lib bin conf …….. Modular runtime image jlink
  • 19. Maintain The Good Old Dockerfile with jlink The runtime stage build • From a JDK base image • Create your own custom JRE with jlink
  • 20. Maintain The Good Old Dockerfile with JLink The runtime stage build • From a JDK base image • Create your own custom JRE with jlink The application stage build • From an OS base image • Copy the custom JRE from the runtime stage build • Copy the artifacts needed by your application • Run the application
  • 22. The Runtime Stage Build jdeps --ignore-missing-deps -q -recursive --multi-release 21 --print-module-deps --class-path 'target/libs/*' target/spring-todo-app.jar
  • 23. The Runtime Stage Build Exclude man pages and header files
  • 24. The Runtime Stage Build Enable compression of resources: 0: No compression 1: Constant string sharing 2: ZIP
  • 25. The Application Stage Build Copy the custom JRE
  • 26. The Application Stage Build Copy the artifacts needed by your application
  • 27. The Application Stage Build Run the application
  • 28. How about fine tuning JVM Flags?
  • 29. Conserving Dynamic Footprint by Minimizing Java Heap Size Start by looking at the JVM ergonomics
  • 30. Conserving Dynamic Footprint by Minimizing Java Heap Size Start by looking at the JVM ergonomics At initialization of the virtual machine, the entire space for the heap is reserved. Eg: setting for minimum and maximum heap size: -Xms768m -Xmx768m
  • 31. Conserving Dynamic Footprint by Minimizing Java Heap Size Start by looking at the JVM ergonomics At initialization of the virtual machine, the entire space for the heap is reserved. Eg: setting for minimum and maximum heap size: -Xms768m -Xmx768m Minimize Java heap size by lowering the values of the options: • -XX:MaxHeapFreeRatio (default value is 70%) -XX:MinHeapFreeRatio (default value is 40%) • Eg:-XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=70
  • 32. What if the problem is not the amount of resources allocated to/by the JVM?
  • 33. Tracking Native Memory With Jcmd Add jdk.jcmd module
  • 34. Tracking Native Memory With Jcmd Overusing jcmd to send diagnostic commands can affect the performance of the VM.
  • 35. Tracking Native Memory With Jcmd Overusing jcmd to send diagnostic commands can affect the performance of the VM. -XX:NativeMemoryTracking={off|summary|detail} • kubectl set env deployment/app JDK_JAVA_OPTIONS=“-XX:NativeMemoryTracking=summary” • Please consider that having NMT enabled can add application performance overhead.
  • 36. Tracking Native Memory With Jcmd Overusing jcmd to send diagnostic commands can affect the performance of the VM. Add -XX:NativeMemoryTracking={off|summary|detail} to JDK_JAVA_OPTIONS Create a native memory baseline kubectl exec pod_name –it --/bin/bash -c "jcmd llvmid VM.native_memory baseline"
  • 37. Tracking Native Memory With Jcmd Overusing jcmd to send diagnostic commands can affect the performance of the VM. Add -XX:NativeMemoryTracking={off|summary|detail} to JDK_JAVA_OPTIONS Create a native memory baseline kubectl exec pod_name –it --/bin/bash -c "jcmd llvmid VM.native_memory baseline" Create a native memory summary diff kubectl exec pod_name –it --/bin/bash -c "jcmd llvmid VM.native_memory summary.diff"
  • 38. Performance and Resource Consumption Overview information about the Java VM and monitored values. Information about memory use. Information about thread use. Information about class loading. Information about the Java VM. Information about MBeans
  • 40. Obtain Statistics with jstat and jmap Obtain statistics about garbage collectors by running jstat kubectl exec pod_name –it --/bin/bash -c "jstat -gcutil llvmid 500 50"
  • 41. Obtain Statistics with Jstat and Jmap Obtain statistics about garbage collectors by running jstat kubectl exec pod_name –it --/bin/bash -c "jstat -gcutil llvmid 500 50" Print heap summaries kubectl exec pod_name –it --/bin/bash -c "jmap -histo llvmid"
  • 42. Capture Performance Relevant JVM And Application Events
  • 43. When to Use Profiling “To consume the data today, a user must start a recording, stop it, dump the contents to disk and then parse the recording file. This works well for application profiling, where typically at least a minute of data is being recorded at a time, but not for monitoring purposes.“ source: JEP 349
  • 44. Add JFR To Your Container Image Add jdk.jfr module
  • 45. How to use JFR Enable JFR in JDK_JAVA_OPTIONS kubectl set env deployment/app JDK_JAVA_OPTIONS=“--XX:StartFlightRecording:..” For example, start a time fixed recording with default profile -XX:StartFlightRecording=delay=10s,duration=10m,name=Default,settings=default Use the diagnostic command: kubectl exec pod_name –it --/bin/bash -c "jcmd llvimd JFR.start…"
  • 46. Monitor and React ….. AppTarget 1 AppTarget 2 AppTarget n Prometheus server Pull metrics Pull metrics Pull metrics Gathering metrics Visualizing metrics Alerting
  • 47. Streaming selected metrics to your monitoring service Where to Use JFR Event Streaming
  • 48. Stream selected metrics to your monitoring service Send an average, min, max, etc of a metric Where to Use JFR Event Streaming
  • 49. Stream selected metrics to your monitoring service Send an average, min, max, etc of a metric Expose JFR data through other management APIs Where to Use JFR Event Streaming
  • 50. Make your settings by extending jdk.jfr.SettingControl Recording Custom JFR Events
  • 51. Make your settings by extending jdk.jfr.SettingControl Create your custom event by extending jdk.jfr.Event Recording Custom JFR Events
  • 52. Recording Custom JFR Events Make your settings by extending jdk.jfr.SettingControl Create your custom event by extending jdk.jfr.Event Register the custom settings in your custom event via @jdk.jfr.SettingsDefinition
  • 53. Recording Custom Events in Spring Boot (example) Capture the custom JFR events in a dedicated filter and register it
  • 54. Recording Custom Events in Spring Boot (example) Listen the custom JFR events and record their duration
  • 55. Takeaways Use jlink to create a minimal custom JRE. Send diagnostic commands to a running JVM via jcmd. Inspect performance statistics Profile your application with jfr. Stream preferred JVM metrics to your monitoring service with JFR Event Streaming API.
  • 57. Useful Links • Article https://www.javaadvent.com/2022/12/a-sneak-peek-at-the-java-performance-toolbox.html • Tools https://docs.oracle.com/en/java/javase/21/docs/specs/man/index.html • jlink https://dev.java/learn/jlink/ • Troubleshoot Memory Leaks: https://docs.oracle.com/en/java/javase/21/troubleshoot/troubleshooting-memory- leaks.html • JFR Runtime guide : https://docs.oracle.com/javacomponents/jmc-5-4/jfr-runtime-guide/about.htm#JFRUH170 • Innovative JFR use by @gunnarmorling: https://www.morling.dev/blog/finding-java-thread-leaks-with-jdk-flight- recorder-and-bit-of-sql/ • @gunnarmorling article on custom JDK Flight Recorder Events • Great intro by @BillyKorando https://www.youtube.com/watch?v=K1ApBZGiT-Y • Stack walker episode by @BillyKorando: https://inside.java/2023/05/14/stackwalker-02/