All posts
Guide

How to Find API Bottlenecks Under Load (Step-by-Step Guide)

Find slow endpoints, database lock contention, and p95 latency regressions using a baseline, staged load, resource checks, and automated retesting.

How to Find API Bottlenecks Under Load (Step-by-Step Guide) illustration
API Test Lab3 min read

Use a repeatable baseline → load test → investigate → retest cycle. A bottleneck limits throughput for a particular workload. This guide focuses on capacity under concurrency; for a request that is slow by itself, start with why your API is slow.

Prerequisites and test contract

Use an authorized staging environment with realistic data, metrics, traces, and agreed stop conditions. Record deployment version, client region, request mix, authentication, cache state, and database size.

Define success first. An illustrative contract might be p95 below 500 ms and fewer than 1% failures at the required workload. These are example targets, not universal standards or API Test Lab results.

Baseline: establish correctness and normal variation

Send one request and verify its status and body. Run a low-concurrency baseline for a fixed period. Repeat three times after the same warm-up. Record request count, achieved requests per second, errors, and percentiles alongside CPU, memory, pool waits, and dependency timing.

Store a sanitized configuration. Baselines are not comparable if authentication, dataset, region, or payload changes.

Load test: increase demand in stages

Try 1, 5, 10, 25, 50, then 100 workers, only as authorized and supported by your plan. Hold stages long enough to observe steady behavior. Preserve pacing and request mix. See the 100 concurrent users tutorial.

Concurrency is not requests per second. In a closed workload, slower responses reduce each worker's request rate. Check generator CPU and network so its limits are not mistaken for server limits.

Stop at agreed error or latency limits or when resource usage threatens the environment. Retain failures and timeouts.

Investigate: correlate degradation with a resource

ObservationNext measurementPossible intervention to verify
CPU rises and throughput plateausHandler profile and event-loop delayRemove blocking work or expensive serialization
Pool wait rises but SQL stays fastActive connections and queueReduce query fan-out before raising limits
Query duration risesLocks, plans, rows scannedReduce contention or add a justified index
Upstream spans dominateDependency latency, retries, quotasBound retries and cache suitable responses
Client time rises but application time stays flatGateway queue, network, generatorInvestigate outside the handler

These are hypotheses, not automatic diagnoses. Correlate timestamps and inspect a slow trace. Use the Node.js instrumentation example for stage timing.

Retest: change one cause and preserve the workload

Repeat the baseline and failing stage after one change. Compare distributions and errors, not the fastest request. Then try the next stage if the threshold passes.

Illustrative record, not measured product performance:

Workload: GET /catalog, fixed dataset, 50 workers, same region
Before: p95 820 ms; errors 0.4%; database pool wait visible
Change: remove repeated category query from each response
After: p95 390 ms; errors 0.4%; response assertions pass
Decision: repeat twice; verify writes and next load stage

Track p95 performance regressions across releases

Once you fix a bottleneck, keep the baseline so future deploys do not silently reintroduce it. Comparing current load-test percentiles against a saved baseline makes regressions obvious before they reach production traffic:

{
  "endpoint": "GET /catalog",
  "concurrency": 50,
  "baseline": { "p50Ms": 140, "p95Ms": 390, "errorRatePct": 0.4 },
  "current":  { "p50Ms": 165, "p95Ms": 610, "errorRatePct": 0.4 },
  "regression": {
    "p95DeltaPct": 56.4,
    "status": "warning"
  }
}

When a release pushes `p95` up by more than your threshold—even while `p50` looks normal—pair load benchmarks in the Load Tester with Smart Uptime Monitoring latency alerts and Automated Test Suites in CI/CD so slow queries or lock contention are caught early.

Expected result and common errors

The outcome is a reproducible capacity boundary and evidence for a fix. It does not establish capacity for every workload.

Avoid changing autoscaling, cache state, and code in one experiment. Do not average p95 values across runs; retain per-run distributions or merge compatible samples. Review percentile calculations.

Use API Test Lab load testing to configure a workload, validate individual endpoints in the Online API Tester (or open the API Tester directly), and check plan limits before choosing concurrency and duration.

Share

Start testing your APIs

Try API Test Lab free. No credit card required.

Start free

More from the blog

Read 3 related articles from our latest posts.