Skip to content

Runtime Profiling with Go pprof ​

RUSEON Core integrates the standard Go runtime profiler (net/http/pprof), exposed on the metrics server port (default: :9090). Profiling enables real-time diagnosis of CPU bottlenecks, memory leaks, goroutine leaks, and lock contention on live production instances with zero downtime.


1. Profiling Endpoints Catalog ​

EndpointData CapturedDiagnostic Purpose
/debug/pprof/profile?seconds=30CPU sampling profileIdentifying hot CPU functions and transmuxing bottlenecks
/debug/pprof/heapHeap memory allocationsDetecting memory leaks and unexpected heap allocations
/debug/pprof/goroutineLive goroutine stacksIdentifying leaked or deadlocked goroutines
/debug/pprof/mutexMutex contention eventsMeasuring lock wait times on sync.RWMutex
/debug/pprof/allocsCumulative allocationsTracking GC pressure and total memory churn

2. Capturing & Inspecting Profiles ​

Capturing a 30-Second CPU Profile ​

bash
# Capture 30 seconds of CPU sampling from a running server
go tool pprof http://localhost:9090/debug/pprof/profile?seconds=30

Inside the interactive pprof shell:

text
(pprof) top20
(pprof) list RingBuffer.WriteFrame

Interactive Web UI & Flamegraphs ​

Launch an interactive web dashboard with SVG flamegraphs in your browser:

bash
go tool pprof -http=:8081 http://localhost:9090/debug/pprof/profile?seconds=30

Capturing Heap & Goroutine Profiles ​

bash
# Download heap profile to a local file
curl -s http://localhost:9090/debug/pprof/heap > heap.pprof

# Analyze in interactive browser UI
go tool pprof -http=:8081 heap.pprof

# Inspect all active goroutines in plaintext
curl -s http://localhost:9090/debug/pprof/goroutine?debug=1

Continuous Profiling (Pyroscope / Parca) ​

RUSEON Core's standard pprof endpoints are directly compatible with continuous profiling agents like Grafana Pyroscope and Parca:

yaml
# Example Pyroscope scraping config
scrape_configs:
  - job_name: "ruseon-profiling"
    static_configs:
      - targets: ["ruseon.internal:9090"]

Released under the MIT License.