Skip to content

Performance monitoring

Python performance monitoring

Python web apps are usually limited by workers and the database, not raw CPU speed. Measure latency per route, worker saturation and where each request spends its time.

2 min read7 sectionsUpdated

On this page

What to measure

SignalSourceWorry when
p95 / p99 latency per routeTracesAbove target, or rising after a deploy
Error rate per routeTraces, error trackingAbove 1 to 2%
Busy workers vs totalServer metrics or logsAll workers busy for minutes
Database time per requestTracesMost of the request time
Celery queue length and task durationBroker and task spansQueue grows faster than it drains
Process memory (RSS)Infrastructure metricsGrows with every request; see Python memory usage

Typical Python bottlenecks

  • Too few workers for I/O-bound apps, or too many for the CPU and memory available. A common start for gunicorn is 2 × cores + 1 sync workers, adjusted from measurements.
  • CPU-bound work in the request (image processing, big JSON, report generation) holds the GIL; move it to a task queue or a process pool.
  • Blocking calls in async code: a synchronous database driver inside FastAPI blocks the event loop for every request.
  • ORM N+1 queries in Django and SQLAlchemy; see finding slow database queries.
  • Slow imports and cold starts in serverless functions.

Instrumenting

bash
pip install opentelemetry-distro opentelemetry-exporter-otlp
opentelemetry-bootstrap -a install
OTEL_SERVICE_NAME=billing-api OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 \
  opentelemetry-instrument gunicorn app.wsgi:application --workers 4

Framework guides: Python, Django, Flask, FastAPI. Python SDKs export protobuf, so a Collector forwards to VitalRix.

Frequently asked questions

Sync or async workers?

Async (uvicorn, gevent) helps when requests spend most time waiting on I/O and your libraries are async-friendly. For CPU-heavy or blocking code, sync workers with more processes are simpler and often faster.

Does OpenTelemetry work with Celery?

Yes. The Celery instrumentation traces tasks and links them to the request that queued them.

Check it now, free

  • PHP performance monitoring: Monitor PHP and Laravel apps: request latency, PHP-FPM worker saturation, OPcache hit rate, slow queries, external calls and errors.
  • Java performance monitoring: Monitor Java and Spring applications: JVM heap and GC, thread pools, JDBC connection pools, request latency from traces.
  • Best APM tools: Choose an APM tool in 2026: the criteria that matter, from OpenTelemetry support to pricing models, well-known options compared and how to run a fair trial.
  • What is APM (application performance monitoring)?: APM explained: what application performance monitoring measures, how traces and spans work, why p95 beats averages, a worked example and how to start.
  • IIS monitoring and IIS logs: Monitor Microsoft IIS: performance counters, request queues, application pool health and recycling, W3C log fields such as time-taken.
  • Go performance monitoring: Monitor Go services: goroutine counts, GC and heap, request latency per handler, pprof profiling in production and OpenTelemetry tracing with otelhttp.

Watch your own site and services with VitalRix

Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.