Cloud Native 10 min read

How to Use Pyroscope for Continuous Profiling of Kubernetes Microservices

This guide explains how to install and configure the open‑source Pyroscope continuous profiler on a Kubernetes cluster, integrate it with Python, .NET, and Go microservices, and visualize low‑overhead flame graphs to identify performance bottlenecks and reduce cloud costs.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
How to Use Pyroscope for Continuous Profiling of Kubernetes Microservices

What is Pyroscope?

Pyroscope is an open‑source continuous profiling platform that collects, stores, and queries profiling data with minimal CPU and memory overhead. It uses a server‑agent model and supports language‑specific agents for Go, Python, Ruby, eBPF, Java, .NET, PHP, and Rust.

Why Choose Pyroscope?

Compared with other continuous profilers such as Parca, Datadog Continuous Profiler, and Google Cloud Profiler, Pyroscope focuses on an efficient storage engine (Badger DB) and provides human‑readable profiles by supporting both language‑specific agents and eBPF.

Installation Steps

Start a local Kubernetes cluster with Minikube and add the Pyroscope Helm chart repository:

minikube start
helm repo add pyroscope-io https://pyroscope-io.github.io/helm-chart
helm install pyroscope pyroscope-io/pyroscope --set service.type=NodePort
helm list
kubectl get all

Verify the service URL with: minikube service pyroscope The UI is accessible at the displayed address (e.g., http://192.168.49.2:30639).

Integrating Pyroscope with the Google Microservices Demo

Modify each service’s Dockerfile to copy the Pyroscope binary and launch the application through it.

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 (
    "github.com/pyroscope-io/pyroscope/pkg/agent/profiler"
)

func main() {
    pyroscope.Start(pyroscope.Config{
        ApplicationName: os.Getenv("APPLICATION_NAME"),
        ServerAddress:   os.Getenv("SERVER_ADDRESS"),
    })
    // application code
}

Build and push the image after editing.

Updating Kubernetes Manifests

Replace the original container images with the newly built ones and add the required environment variables and capabilities:

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_PTRACE

Apply the manifests:

kubectl apply -f https://raw.githubusercontent.com/infracloudio/microservices-demo-dev/master/release/kubernetes-manifests.yaml

Resource Utilization

Pyroscope consumes very little CPU while storing data locally in Badger DB, making it suitable for production environments.

Monitoring with Pyroscope

After deployment, Pyroscope generates flame‑graph visualizations for each language, helping developers pinpoint hot paths and inefficient code.

Conclusion

Continuous profiling is essential for meeting user performance expectations. Pyroscope provides low‑overhead, language‑aware profiling that helps developers diagnose issues early, improve application speed, and reduce cloud infrastructure costs.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Cloud NativeMicroservicesKubernetesPyroscopePerformance MonitoringContinuous Profiling
MaGe Linux Operations
Written by

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.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.