Operations 10 min read

Boost Kubernetes Microservice Performance with Pyroscope Continuous Profiling

This guide explains how to use the open‑source Pyroscope continuous profiler on Kubernetes to collect, store, and visualize performance data from microservices written in Go, Python, .NET, and more, enabling developers to pinpoint bottlenecks, reduce CPU and memory usage, and lower cloud costs.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Boost Kubernetes Microservice Performance with Pyroscope Continuous Profiling

Developers often need to locate performance bottlenecks in production applications, but traditional log‑based methods are time‑consuming and lack detail. A modern approach is continuous profiling, which highlights the slowest code paths that consume the most resources.

What Is Pyroscope?

Pyroscope is an open‑source continuous profiling platform composed of a server and agents. It collects, stores, and queries profiling data efficiently, allowing developers to diagnose performance issues, reduce CPU/memory consumption, and improve user experience.

Profiling measures memory usage, time complexity, and function call frequency/duration, providing data for optimization. A continuous profiler runs in production, continuously gathering code‑level performance data.

Available Continuous Profilers

Pyroscope

Parca

Datadog Continuous Profiler

Google Cloud Profiler

Pyroscope distinguishes itself by offering a purpose‑built storage engine and supporting language‑specific agents for Go, Python, Ruby, eBPF, Java, .NET, PHP, and Rust.

Why Use Pyroscope?

Compared with Datadog and Google Cloud Profiler, Pyroscope provides a low‑overhead, high‑efficiency storage engine (Badger) and supports both language‑specific and eBPF agents, delivering more readable profiles.

Installing Pyroscope on Kubernetes

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

After installation, the Pyroscope UI is reachable via the service URL provided by minikube service pyroscope.

Integrating Pyroscope with Google Microservices Demo

Modify each service’s Dockerfile to include the Pyroscope binary and start the application through it.

Python 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 Service

COPY --from=pyroscope/pyroscope:latest /usr/bin/pyroscope /usr/bin/pyroscope
ENTRYPOINT ["pyroscope", "exec", "-spy-name", "dotnetspy", "/app/cartservice"]

Go 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"),
    })
    // application code here
}

Build and push the Go image similarly.

Updating Kubernetes Manifests

Add the Pyroscope sidecar image and environment variables to each container, and grant the SYS_PTRACE capability.

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

Deploy the updated manifests:

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

Access the Pyroscope UI (e.g., http://192.168.49.2:30639) to view flame graphs and resource usage.

Resource Utilization

Pyroscope runs with minimal CPU overhead and stores data locally using Badger, making it cost‑effective for production environments.

Monitoring with Pyroscope

Flame graphs for different languages (Go, Python, .NET, etc.) illustrate hot paths and help pinpoint inefficient code.

Pyroscope resource utilization
Pyroscope resource utilization
Flame graph example
Flame graph example
Flame graph example 2
Flame graph example 2
Flame graph example 3
Flame graph example 3
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.

Performance OptimizationMicroservicesKubernetesPyroscopeProfilingContinuous 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.