Skip to main content
When prescale investigate diagnoses a failure, it classifies the bottleneck into one of several distinct types. Each type has a unique signature — a combination of latency behaviour, error kinds, throughput patterns, and infrastructure signals — and a specific set of fixes. Understanding which type you’re dealing with is the difference between guessing and knowing what to change. The classifier is fully local and deterministic — no LLM, no network calls. It runs active probes against the culprit route (baseline vs loaded latency, static-vs-dynamic comparison, error/header forensics) and uses a first-match rule set to arrive at a verdict.

Bottleneck classes

What it meansYour application ran out of connections to a downstream dependency — most commonly a database connection pool, a Redis pool, or an HTTP client pool to an upstream API. Under load, threads or async workers pile up waiting for a free connection, which manifests as 5xx errors or request timeouts while the rest of your infrastructure remains healthy.How it’s detectedPreScale identifies this class when either:
  • 5xx errors dominate under load and a static asset (CSS, JS) continues to respond normally at the same user level — meaning the bottleneck is inside the app, not at the network or server level.
  • Requests time out while the static probe holds — indicating that something behind the app (a DB or upstream service) is blocking request completion.
How to fix it
  • Increase the pool size in your application config (e.g. DATABASE_POOL_SIZE, pool_size= in SQLAlchemy, max in node-postgres).
  • Add a connection pooler such as PgBouncer (for PostgreSQL) to multiplex many app connections onto fewer server connections.
  • Check that connections are always released after a request — connection leaks shrink your effective pool over time.
  • Audit the connection checkout timeout; a tight timeout causes cascading failures when the pool is briefly full.
  • If you run gunicorn, increase --workers. If you run uvicorn, run it under gunicorn -k uvicorn.workers.UvicornWorker -w N.
What it meansYour server has a fixed number of threads, workers, or coroutine slots — and under load, you hit that ceiling. New requests queue behind busy workers, which is why latency climbs steeply while throughput flattens: the server is processing requests as fast as it can, but there are more arrivals than capacity.How it’s detectedPreScale identifies this class when:
  • Throughput plateaued (throughput stopped rising even though virtual users kept increasing) and latency climbed — the classic queuing-theory signature of a saturated server.
  • Alternatively: no saturation was detected, but loaded p95 latency is 3× or more the baseline p95 at a single user, with no dominant error class pointing elsewhere.
How to fix it
  • Raise the worker or thread count for your server process — extra users are literally queuing.
  • Check for a global lock or a serialised resource (e.g. a Python GIL-bound sync path in an async framework) that prevents true parallelism.
  • If a single process can’t go wider, scale out: put multiple instances behind a load balancer and distribute traffic.
  • For gunicorn: increase --workers (and optionally --threads). For uvicorn: use gunicorn -k uvicorn.workers.UvicornWorker -w N.
What it meansThe server (or the OS) has a hard limit on the number of simultaneous TCP connections it will accept, and you hit it. Unlike a connection pool (which is an application-layer limit), this is a network or OS-level ceiling: somaxconn, listen backlog, worker_connections, or an upstream load-balancer concurrency cap.How it’s detectedPreScale identifies this class when:
  • Connection refusal or network errors dominate under load — "connection refused" or generic "network" errors.
  • Or timeouts dominate and the static-asset probe also degrades — meaning the ceiling is before the app, at the server or load balancer layer.
Confidence is high when static assets degrade too (unambiguous infra-level signal) and medium when only the culprit route suffers.How to fix it
  • Raise the server’s TCP connection limit: for nginx, increase worker_connections; for the OS, tune net.core.somaxconn and the application’s listen backlog.
  • Add instances behind a load balancer to spread connections across multiple origin servers.
  • If a CDN is in front, the ceiling is likely at your origin — investigate origin capacity separately.
What it meansA rate limiter is returning 429 Too Many Requests under load. This could be intentional (your own rate limit protecting the service) or a surprise (a third-party API, an upstream service, or a gateway you forgot was configured).How it’s detectedPreScale identifies this class when 429 responses are the dominant error type under load. Confidence is high — the HTTP status code is unambiguous.How to fix it
  • Confirm whether the limiter is intentional. If it’s yours, decide whether the limit should be raised for the expected load, or whether you need to handle 429 gracefully in your client code.
  • If the limiter is on internal or health-check traffic, exempt those routes or source IPs.
  • For third-party rate limits, implement request queuing with exponential back-off rather than flooding the upstream.
What it meansA proxy or load balancer in front of your application is shedding load — returning 503 Service Unavailable rather than forwarding requests to the origin. This happens when the LB’s queue fills up, its upstream health checks fail, or a connection timeout fires before the origin responds.How it’s detectedPreScale identifies this class when 503 responses appear under load. Confidence is high — a 503 from a proxy is a clear load-shedding signal.How to fix it
  • Add origin capacity or enable auto-scaling so the LB has healthy upstreams to route to.
  • Tune the LB’s queue depth or connection timeout to shed later, giving the origin more time to respond during traffic spikes.
  • Investigate whether your origin health checks are too aggressive (false negatives under load).
What it meansThe culprit route is slow even with a single virtual user — before any contention or queuing. This points to an application-level problem: a slow database query, an N+1 query loop, missing indexes, or a synchronous computation on the request path. Every concurrent user makes the problem worse by amplifying the already-high base latency.How it’s detectedPreScale probes the culprit route at exactly 1 virtual user (baseline measurement). If p95 at 1 user is ≥ 800 ms, the endpoint is classified as slow_endpoint with high confidence — the baseline measurement is unambiguous.How to fix it
  • Profile the endpoint directly — this class is diagnosed before any load is applied, so the problem exists regardless of scale.
  • Check the database query plan for the route; look for sequential scans, missing indexes, or N+1 patterns (e.g. with EXPLAIN ANALYZE).
  • Add caching for expensive computations or frequently-read data.
  • Move heavy work off the synchronous request path (background jobs, async tasks).
  • Add pagination if the route fetches unbounded result sets.
What it meansThe target degraded under load, but the combination of signals — error kinds, latency profile, throughput curve, static probe — doesn’t match any of the known bottleneck patterns. This usually means the failure is subtle, intermittent, or involves a combination of factors that individually don’t cross a diagnostic threshold.How it’s detectedunknown is the fallback class when none of the other classifiers fired. Confidence is always low.How to fix it
  • Re-run with --repeat 3 to pool multiple ramps and get a tighter read on the failure point.
  • Try --stage-seconds 10 to give each load level more time and reduce measurement noise.
  • Inspect the per-route breakdown in verdict.stages[].routes to see which route degrades fastest.
  • Check application logs and database/connection metrics around the onset_users level — the signal you need may not be visible from the outside.
What it meansJourneys only. The step serves one request at a time; everyone else waits in line. Typically a lock on one shared row (one product’s stock in a flash sale, a counter, an account balance), a global lock or mutex, or a single worker or queue consumer.How it’s detectedPreScale counts how many requests the step serves at once, with Little’s law: the most it completed per second at the level where it broke, times how long one takes with a single user. It only counts when the step’s own requests queued (under load they took at least 3× their 1-user time), its completions held steady from the level before the break to the break (neither rising nor collapsing), and PreScale’s own machine kept up. It’s skipped under --max-rps, where the cap would be what stopped them. A cheap step that just completes at the pace of a busier step before it never queues, so it’s never called serialized. About one at a time is serialized; high confidence when the journey’s other steps held. For any other class the count is in the evidence too (“~25 requests served at once”), which is often the size of the pool or worker count you’re hitting.How to fix it
  • Find what the step locks: a SELECT ... FOR UPDATE or a transaction on one row, a mutex, or a single worker.
  • Hold it for less: do slow work (payments, emails, rendering) outside the lock.
  • Lock less: an atomic UPDATE ... SET stock = stock - 1 WHERE stock > 0 instead of read-then-write, or split the hot row (stock in shards, counters per worker).
What it meansJourneys only. The step works for one user, but under load it answers something the journey doesn’t expect: a 4xx such as 409, 401 or 403, or a response missing a value a later step needs. Usually users are conflicting over shared data (a row several users change at once, a lock, a unique constraint), or sessions and tokens stop holding up under load.How it’s detectedThe step’s most common failure under load is an unexpected 4xx or a missing extract. Confidence is medium: PreScale sees the answer, not the reason behind it.How to fix it
  • Check the app’s logs for this step under load. A 409 or a unique-constraint error points at rows several users change at once: lock them, or retry. A 401 or 403 points at a session store or token cache that doesn’t keep up.
  • Make sure each virtual user’s data is its own. A journey where every user changes the same account or item can conflict by design.

Confidence levels

Every diagnosis includes a confidence field — "high", "medium", or "low" — that tells you how certain PreScale is about the classification. When you get low confidence, the most useful next steps are:

Bottleneck classes are stored in result.investigation.bottleneck_class in the saved JSON. The values match exactly what you see here — so you can filter saved runs by class, build CI gates around specific types, or pass the field directly to another tool. See the Result Schema for the full shape of the investigation object.