101 Profiling

For Microservices

Empower your developers #EYD

Juan Antonio Breña Moral

Agenda

  1. Java Context
  2. Java profilers
  3. Introduction to VisualVM
  4. Profilers in Action
  5. Summary
  6. References
  7. Homework
  8. Q&A

Educational Goals

  1. Learn to use a Java Profiler
  2. Learn to use JVM flags

Java Context

  1. Java Lifecycle
  2. Java Architecture
  3. Java Memory Model
  4. Java & Containers
  5. JVM Flags

Java Lifecycle

Java Architecture

Java Memory Model

Java & Containers

JVM Flags


java -Xms256m -Xmx256m \
    -verbose:gc  \
    -XX:+UseG1GC -XX:-DisableExplicitGC \
    -Djava.security.egd=file:/dev/./urandom \
    -Dsun.management.jmxremote.level=FINEST \
    -Dsun.management.jmxremote.handlers=java.util.logging.ConsoleHandler \
    -Djava.util.logging.ConsoleHandler.level=FINEST \
    -Dcom.sun.management.jmxremote.local.only=false \
    -Dcom.sun.management.jmxremote=true \
    -Dcom.sun.management.jmxremote.ssl=false \
    -Dcom.sun.management.jmxremote.authenticate=false \
    -Dcom.sun.management.jmxremote.port=9010 \
    -Dcom.sun.management.jmxremote.rmi.port=9010 \
    -Dcom.sun.management.jmxremote.host=0.0.0.0 \
    -Djava.rmi.server.hostname=0.0.0.0 \
    -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 \
    -server \
    -jar -jar app.jar
                  

More flags...

Java profilers

  1. What is Profiling?
  2. What kind of problems try to solve?
  3. Alternatives

What is Profiling?

The term profiling describes a dynamic analysis that covers issues of the resource management of a program during execution.

Performance analysts profile their programs to find methods that are worth optimizing: the “hot” methods.

What kind of problems try to solve a Profiler?

  1. CPU Bottleneck
  2. Memory Leak
  3. Multithreading problems
  4. Define JVM Settings

Alternatives

  1. JProfiler (Commercial Product)
  2. YourKit (Commercial Product)
  3. Java VisualVM

Introduction to VisualVM

  1. Connections
  2. Overview
  3. Monitor
  4. Threads
  5. Sampler
  6. Profiler

Profilers in Action

  1. Scenario 1: Memory

Summary

  1. Pipelines are not a Silver Bullet
  2. Dynamic Scenarios could hide CPU/Memory problems
  3. Proling is a task to be included in the Springs

References

Articles

  1. A Guide to Java Profilers
  2. Memory Profiling using Visual VM
  3. The art of profiling
  4. Java is a first class citizen in a Docker ecosystem
  5. Java 9 by Example

Books

Books

Books

Homework

  1. What is Locked ownable synchronizers?
  2. What is the default GC in your last Microservice?
  3. Did you do a Test A/B between Java 8 & Java 9?

Q&A

 @juanantoniobm
 https://github.com/jabrena
 https://www.juanantonio.info
"Pressure makes diamonds."
- George S. Patton Jr.