Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Continuous Profiling mit Grafana Pyroscope

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

Continuous Profiling mit Grafana Pyroscope

Avatar for Michael Kotten

Michael Kotten

June 11, 2024
Tweet

Other Decks in Programming

Transcript

  1. • Identify • performance bottlenecks • memory leaks • resource

    utilization patterns • Traditionally (non-continuous) • console.log debugging • Sample-based • Instrumentation-based • Profiling tools • JDK Mission Control • VisualVM • Other commercial tools
  2. • Better performance • Less operational costs • Increased customer

    satisfaction • Faster incident resolution • More revenue!!!
  3. • Continuous Profiling Platform • Open Source • Built-in UI

    • Grafana integration • Pyroscope data source • Flamegraph panel • Multi-tenancy support
  4. • Distributor • receives profiling data • divides data into

    batches • sends batches to ingester • Ingester • writes data to Object store • Compactor • increases query performance • reduces long-term storage usage
  5. • Query-frontend • receives query • send to queue of

    query-scheduler • Querier • picks queries from query-scheduler • evaluates query expressions • reads from ingester and store-gateway • Store-gateway • lookup data from long-term storage
  6. • Monolithic mode • Microservices mode • Installation using •

    Docker version: '3.9' services: pyroscope: image: 'grafana/pyroscope:latest' ports: - 4040:4040
  7. • Monolithic mode • Microservices mode • Installation using •

    Docker • K8s with helm (optionally in microservices mode) helm repo add grafana https://grafana.github.io/helm-charts helm repo update # install pyroscope in microservices mode helm upgrade --install -n pyroscope pyroscope grafana/pyroscope \ --values values-micro-services.yaml
  8. • Supports Prometheus, OTEL, Grafana ecosystem (Loki, ..., Pyroscope) •

    Built-in UI • Scalable • Runs in different modes • Static mode • Static mode Kubernetes operator • Flow mode * • Uses async-profiler for Java * currently only flow mode for Pyroscope
  9. • Supports Prometheus, OTEL, Grafana ecosystem (Loki, ..., Pyroscope) •

    Built-in UI • Scalable • Runs in different modes • Static mode • Static mode Kubernetes operator • Flow mode * • Uses async-profiler for Java • Deprecated, will be replaced by Grafana Alloy * currently only flow mode for Pyroscope
  10. • Support for multiple languages • As Maven or Gradle

    artifact <dependencies> ... <dependency> <groupId>io.pyroscope</groupId> <artifactId>agent</artifactId> <version>0.13.1</version> </dependency> ... </dependencies>
  11. • Support for multiple languages • As Maven or Gradle

    artifact PyroscopeAgent.start( new Config.Builder() .setApplicationName("demo-app-java") .setProfilingEvent(EventType.ITIMER) .setFormat(Format.JFR) .setServerAddress("http://localhost:4040") .build() );
  12. • Support for multiple languages • As Maven or Gradle

    artifact • As javaagent export PYROSCOPE_APPLICATION_NAME=demo-app-java export PYROSCOPE_SERVER_ADDRESS=http://localhost:4040 export PYROSCOPE_FORMAT=jfr java -javaagent:pyroscope.jar -jar app.jar
  13. • Filter data in the UI • Dynamic labels Pyroscope.LabelsWrapper.run(new

    LabelsSet("controller“, “slow_controller“), () -> { slowCode(); });
  14. • Filter data in the UI • Dynamic labels •

    Static labels Pyroscope.setStaticLabels(Map.of("region", System.getenv("REGION"))); // or with Config.Builder if you start pyroscope with PyroscopeAgent.start PyroscopeAgent.start(new Config.Builder() .setLabels(Map.of("region", System.getenv("REGION"))) // ... .build() );
  15. • Visualization of profiling data • Shows stacktrace with time

    spent • 100% on top node • width = time spent • narrower node = less time • call tree from top to bottom
  16. • Consumed CPU time • Memory allocation • Types: •

    Alloc objects • Alloc space • amount + frequency * supported in Java
  17. • Consumed CPU time • Memory allocation • Types: •

    Alloc objects • Alloc space • amount + frequency • Locks • Frequency • Duration * supported in Java
  18. • Traditional profiling • development and testing phase • detailed

    insights • under control of developer • Continuous profiling • production environment or extended performance tests • continuous view of system performance • less detailed due to minimized overhead