How to Use Pyroscope for Continuous Performance Profiling in Microservices
This guide explains how to integrate the open‑source Pyroscope platform with Rainbond to continuously profile microservices, detect CPU bottlenecks and memory leaks, and visualize performance data through its UI and various view modes.
When microservice architectures are deployed in production, issues such as high traffic can cause performance bottlenecks, high CPU usage, or memory leaks, and finding the root cause by inspecting logs and code can be time‑consuming.
This article introduces the open‑source continuous performance analysis platform Pyroscope , which helps quickly locate memory leaks and high‑CPU code.
What is Pyroscope?
Pyroscope is an open‑source continuous profiling platform that helps you:
Find performance problems in code
Resolve high CPU utilization
Detect and fix memory leaks
Understand application call trees
Track changes over time
It stores long‑term profiling data from many applications, offers low CPU overhead, high compression efficiency, low disk space requirements, and a fast UI.
Pyroscope Architecture
Pyroscope consists of two main components: Pyroscope Server and Pyroscope Agent .
Pyroscope Agent: records and aggregates runtime data from your application and sends it to the server. Supports Go, Python, Ruby, eBPF, Java, Rust, PHP, Node.js, .NET.
Pyroscope Server: processes, aggregates, and stores data from agents, enabling fast queries over any time range.
Integration with Rainbond
1. Integrate Pyroscope Agent: Install the Pyroscope Agent plugin via Rainbond, which launches
pyroscope.jarusing
java -javaagent:pyroscope.jar -jar app.jar.
2. Depend on Pyroscope Server: Connect the microservice components that have the agent plugin to the Pyroscope Server.
Practical Steps
The following steps demonstrate the integration using the Pig microservice framework.
Deploy Spring Cloud Pig microservices.
Deploy Pyroscope Server.
Install and configure the Pyroscope Java Agent plugin.
Establish dependency between microservices and Pyroscope.
Basic usage of Pyroscope.
1. Deploy Spring Cloud Pig
Install Spring Cloud Pig from the open‑source app store.
2. Deploy Pyroscope Server
Install Pyroscope Server from the app store.
3. Install Pyroscope Java Agent Plugin and Configure
Install the
Pyroscope-Java-Agentplugin from the app store.
Enable the plugin for each microservice component.
Set environment variables, e.g.,
JAVA_OPTS=-javaagent:/agent/pyroscope.jarand a unique
PYROSCOPE_APPLICATION_NAMEsuch as
pig.auth.
4. Create Dependency Between Microservices and Pyroscope
Add a dependency link from each microservice component to the Pyroscope Server, switch to orchestration mode, and restart components to activate the relationship.
5. Basic Use of Pyroscope
Access the UI at port 4040. In Single View select an application to see flame graphs or tables for a chosen time range. Comparison View lets you compare different periods, and Diff View highlights differences, which is useful for diagnosing CPU spikes or memory leaks.
Conclusion
Pyroscope can also be combined with Jaeger and integrated into the Jaeger UI.
Reference Links
Pyroscope: https://pyroscope.io/
Rainbond Quick Install: https://www.rainbond.com/docs/quick-start/quick-install/
Jaeger UI Integration: https://github.com/pyroscope-io/jaeger-ui
Java Architecture Diary
Committed to sharing original, high‑quality technical articles; no fluff or promotional content.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.