Performance profiling setup guide
Learn how to enable pprof and Pyroscope performance profiling in EasyAPI
Overview
EasyAPI offers two kinds of performance profiling:
- pprof (built-in): Best for ad-hoc diagnostics and offline analysis. Once enabled, you can collect CPU, memory, goroutine, and other profiles over HTTP endpoints.
- Pyroscope (optional): Best for continuous profiling in production with flame graph visualization. Profiling data is continuously sent to a Pyroscope server.
You can enable both at the same time without conflicts.
Features
- Zero-code integration: configured entirely through environment variables
- Works with Docker Compose and standalone deployments
- Ad-hoc diagnostics and continuous profiling can run side by side
- Optional authentication and per-instance labeling
pprof (built-in) setup
1. Configure environment variables
Docker Compose:
environment:
- ENABLE_PPROF=trueStandalone deployment:
export ENABLE_PPROF=true2. Restart the application
Restart the EasyAPI service to apply the changes.
# Docker Compose
docker-compose down && docker-compose up -d
# Standalone deployment
# Restart your EasyAPI application3. Verify
Once enabled, the pprof endpoints are usually available at /debug/pprof/ (depending on your deployment). The default listening port is 8005.
You can use go tool pprof to collect and analyze profiles, for example:
go tool pprof http://localhost:8005/debug/pprof/profile?seconds=30Security tip: In production, restrict access to the pprof endpoints and never expose diagnostic interfaces to the public internet.
Pyroscope setup
1. Prepare a Pyroscope server
Make sure the Pyroscope server is reachable and note its address (for example, http://localhost:4040).
You can deploy quickly with the official Pyroscope Docker image, or use Grafana Cloud Profiles.
2. Configure environment variables
Docker Compose:
environment:
- PYROSCOPE_URL=http://localhost:4040
- PYROSCOPE_APP_NAME=easy-api
- PYROSCOPE_BASIC_AUTH_USER=your-user
- PYROSCOPE_BASIC_AUTH_PASSWORD=your-password
- PYROSCOPE_MUTEX_RATE=5
- PYROSCOPE_BLOCK_RATE=5
- HOSTNAME=your-hostnameStandalone deployment:
export PYROSCOPE_URL=http://localhost:4040
export PYROSCOPE_APP_NAME=easy-api
export PYROSCOPE_BASIC_AUTH_USER=your-user
export PYROSCOPE_BASIC_AUTH_PASSWORD=your-password
export PYROSCOPE_MUTEX_RATE=5
export PYROSCOPE_BLOCK_RATE=5
export HOSTNAME=your-hostnameNote: If PYROSCOPE_URL is empty, Pyroscope reporting is disabled. Basic Auth credentials are only needed when the Pyroscope server has authentication enabled.
3. Restart the application
Restart the EasyAPI service to apply the changes.
4. Verify
- Open the Pyroscope UI
- Select the application matching
PYROSCOPE_APP_NAME(default:easy-api) - If
HOSTNAMEis set, you can tell nodes apart by instance
Troubleshooting
Profiling not working?
- Verify that the environment variables are set correctly
- Restart the application after changing variables
- Check network connectivity and authentication settings
- Make sure PYROSCOPE_APP_NAME is named consistently
Docker users:
docker exec <container-name> env | grep -E "PPROF|PYROSCOPE"Environment variable reference
| Variable | Required | Default | Description |
|---|---|---|---|
ENABLE_PPROF | No | false | Enable pprof profiling (listens on port 8005 by default) |
PYROSCOPE_URL | No | - | Pyroscope server address; leave empty to disable |
PYROSCOPE_APP_NAME | No | easy-api | Pyroscope application name |
PYROSCOPE_BASIC_AUTH_USER | No | - | Pyroscope Basic Auth username |
PYROSCOPE_BASIC_AUTH_PASSWORD | No | - | Pyroscope Basic Auth password |
PYROSCOPE_MUTEX_RATE | No | 5 | Mutex sampling rate |
PYROSCOPE_BLOCK_RATE | No | 5 | Block sampling rate |
HOSTNAME | No | easy-api | Instance identifier used to distinguish nodes |