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
| Endpoint | Data Captured | Diagnostic Purpose |
|---|---|---|
/debug/pprof/profile?seconds=30 | CPU sampling profile | Identifying hot CPU functions and transmuxing bottlenecks |
/debug/pprof/heap | Heap memory allocations | Detecting memory leaks and unexpected heap allocations |
/debug/pprof/goroutine | Live goroutine stacks | Identifying leaked or deadlocked goroutines |
/debug/pprof/mutex | Mutex contention events | Measuring lock wait times on sync.RWMutex |
/debug/pprof/allocs | Cumulative allocations | Tracking 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=30Inside the interactive pprof shell:
text
(pprof) top20
(pprof) list RingBuffer.WriteFrameInteractive 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=30Capturing 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=1Continuous 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"]