Performance profiling setup guide

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=true

Standalone deployment:

export ENABLE_PPROF=true

2. 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 application

3. 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=30

Security 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-hostname

Standalone 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-hostname

Note: 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

  1. Open the Pyroscope UI
  2. Select the application matching PYROSCOPE_APP_NAME (default: easy-api)
  3. If HOSTNAME is 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

VariableRequiredDefaultDescription
ENABLE_PPROFNofalseEnable pprof profiling (listens on port 8005 by default)
PYROSCOPE_URLNo-Pyroscope server address; leave empty to disable
PYROSCOPE_APP_NAMENoeasy-apiPyroscope application name
PYROSCOPE_BASIC_AUTH_USERNo-Pyroscope Basic Auth username
PYROSCOPE_BASIC_AUTH_PASSWORDNo-Pyroscope Basic Auth password
PYROSCOPE_MUTEX_RATENo5Mutex sampling rate
PYROSCOPE_BLOCK_RATENo5Block sampling rate
HOSTNAMENoeasy-apiInstance identifier used to distinguish nodes