Master Continuous Profiling on Kubernetes with Pyroscope: A Step‑by‑Step Guide
Learn how to use the open‑source Pyroscope continuous profiler to identify performance bottlenecks in Kubernetes‑deployed microservices, compare it with other profilers, and follow detailed installation, configuration, and integration steps for Python, Go, and .NET services, including Helm deployment and resource monitoring.
Developers often need to locate performance bottlenecks in production applications. Traditional log‑based debugging is time‑consuming and lacks detail. A modern approach is to use continuous profiling tools that highlight the slowest code paths consuming the most resources.
What is Pyroscope?
Pyroscope is an open‑source continuous profiling platform consisting of a server and agents. It efficiently collects, stores, and queries profiling data using a purpose‑built storage engine (Badger) and supports language‑specific agents for Go, Python, Ruby, eBPF, Java, .NET, PHP, and Rust.
Continuous Profiling
Continuous profilers run in production, gathering CPU and memory usage over time. They quickly reveal resource‑intensive functions after new code is deployed, helping reduce cloud costs and improve user experience.
Available Continuous Profilers
Pyroscope
Parca – eBPF‑based sampler for C, C++, Go, etc.
Datadog Continuous Profiler
Google Cloud Profiler
Why Use Pyroscope?
Compared with Datadog and Google Cloud Profiler, Pyroscope offers a low‑overhead storage engine, language‑specific agents, and eBPF support, providing more readable profiles with minimal CPU impact.
Installation on Kubernetes
Start a local Kubernetes cluster with Minikube: minikube start Add the Pyroscope Helm chart repository and install the chart:
helm repo add pyroscope-io https://pyroscope-io.github.io/helm-chart helm install pyroscope pyroscope-io/pyroscope --set service.type=NodePortVerify the installation:
helm list kubectl get allIntegrating Pyroscope with Sample Services
Modify Dockerfiles to include the Pyroscope binary and launch the application through the profiler.
Python Email Service
COPY --from=pyroscope/pyroscope:latest /usr/bin/pyroscope /usr/bin/pyroscope
CMD [ "pyroscope", "exec", "python", "email_server.py" ]Build and push the image:
docker build . -t beellzrocks/emailservice:latest
docker push beellzrocks/emailservice:latest.NET Cart Service
COPY --from=pyroscope/pyroscope:latest /usr/bin/pyroscope /usr/bin/pyroscope
ENTRYPOINT ["pyroscope", "exec", "-spy-name", "dotnetspy", "/app/cartservice"]Build and push the image similarly.
Go Product Catalog Service
import (
pyroscope "github.com/pyroscope-io/pyroscope/pkg/agent/profiler"
)
func main() {
pyroscope.Start(pyroscope.Config{
ApplicationName: os.Getenv("APPLICATION_NAME"),
ServerAddress: os.Getenv("SERVER_ADDRESS"),
})
// code here
}Build and push the Go image after adding the profiler start call.
Updating Kubernetes Manifests
Replace container images with the newly built ones and add the required environment variables and security context.
containers:
- name: server
image: beellzrocks/emailservice
env:
- name: PYROSCOPE_SERVER_ADDRESS
value: "http://pyroscope:4040"
- name: PYROSCOPE_APPLICATION_NAME
value: "email.service"
securityContext:
capabilities:
add:
- SYS_PTRACEApply the manifests:
kubectl apply -f https://raw.githubusercontent.com/infracloudio/microservices-demo-dev/master/release/kubernetes-manifests.yamlExpose the Pyroscope UI: minikube service pyroscope Open the displayed URL (e.g., http://192.168.49.2:30639) to view profiling data.
Resource Utilization
Pyroscope itself consumes very little CPU and memory while storing data locally in Badger. Screenshots show low CPU usage and efficient storage.
Flamegraph Examples
Flamegraphs for the Go product catalog, .NET cart, and Python email services illustrate how Pyroscope visualizes hot code paths per language.
Conclusion
Continuous profiling is essential for meeting end‑user performance expectations. Pyroscope provides low‑overhead, language‑aware profiling that helps developers diagnose issues early, optimize code, and reduce cloud infrastructure costs.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
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.
