What it is
Load testing is generating controlled, synthetic traffic against a system and measuring how it behaves: latency distribution, throughput, errors and resource use. The umbrella term covers several test types, each answering a different question:
| Test | Shape of traffic | Question |
|---|---|---|
| Smoke | Very light | Does the test setup work at all? |
| Load | Expected and peak traffic, often ramped in plateaus | Do we meet our latency and error targets at peak? |
| Stress | Beyond expected peak, until it breaks | Where is the ceiling, and how does it fail? |
| Spike | Sudden jump to extreme load, then back | Do we survive a burst, and do we recover? |
| Soak (endurance) | Realistic load for hours or days | Do we degrade over time (leaks, growth, fragmentation)? |
Why it exists
Capacity estimates on paper miss things: a lock nobody knew about, a connection pool that is too small, a GC setting, a slow query that only appears with production-sized data. Load tests turn “should be fine” into measured numbers before users find the limits for you, and they give you a baseline to catch performance regressions between releases.
How it works
Workload model. Decide how the generator issues requests. In an open model requests arrive at a set rate (for example Poisson arrivals at 200 per second) regardless of how fast the system answers, like independent users on the internet. In a closed model a fixed number of virtual users each send a request, wait for the answer (and maybe think), then send the next; the arrival rate falls when the system slows down. Most public-facing services are better described by the open model. Many tools default to closed-loop virtual users; most also offer arrival-rate executors.
Coordinated omission. When a closed-loop generator waits on a stalled system, it stops sending, so the requests that would have arrived during the stall (and suffered most) are never issued and never measured. The recorded percentiles look far better than what users experience. Remedies: an open-model executor, or measuring each request’s latency from its intended send time (as wrk2 and HdrHistogram’s correction do).
Ramping and the knee. Increase load in plateaus long enough to reach steady state and record throughput and latency percentiles per plateau. Throughput grows with load until saturation; latency stays roughly flat and then bends upward as utilisation gets high, because queueing delay grows non-linearly (in the simplest queueing model, proportional to 1 ÷ (1 − ρ)). The point where it bends is the knee. Usable capacity is below the knee, not at the maximum.
Reading results. Use percentiles (P50, P95, P99, P99.9) from the full distribution, always with the request rate they were measured at. Percentiles cannot be averaged across servers or time slices; merge histograms instead. Look at error types (fast 503s and timeouts mean different things) and at resource metrics on every tier, so you know what saturated.
When to use it
- Before launches, large marketing events and expected seasonal peaks.
- In CI or nightly runs on a smaller scale, to catch performance regressions per release.
- After architecture changes (new database, new cache, new region), to re-establish capacity numbers.
- To validate autoscaling, rate limits, load shedding and timeouts under realistic pressure.
When not to
- As a substitute for production observability: synthetic traffic never matches real behaviour perfectly.
- Against shared or third-party systems without permission (payment providers, partner APIs): stub them or use their sandboxes.
- When the environment differs so much from production (size, data volume, network) that the numbers cannot be transferred; at least state the differences.
Trade-offs
| Choice | You gain | You pay |
|---|---|---|
| Production-sized staging | Transferable numbers | Cost of a second full environment |
| Testing in production (shadow or synthetic traffic) | Real infrastructure and data | Risk to users; needs careful isolation and kill switches |
| Open-model generator | Honest latency under stalls | Can overwhelm the system quickly; needs a cap |
| Long soak tests | Finds leaks and slow degradation | Hours of environment time per run |
| Stubbed dependencies | Repeatable, isolates your service | Misses the dependencies’ real limits |
Alternatives
- Capacity models: Little’s law and queueing estimates give first numbers before any test.
- Canary releases with careful monitoring catch regressions with a slice of real traffic.
- Traffic replay / shadowing: copy real production requests to a test system for a realistic mix.
- Chaos and game days test failure behaviour rather than capacity; combine with load for realism.
Failure modes
- Testing the cache: one URL with one ID always hits the cache; production misses would hit the database.
- The generator is the bottleneck: a saturated load machine caps the rate and adds its own latency. Watch its CPU and network, or distribute it.
- Coordinated omission: closed-loop tools hide stalls, making percentiles look healthy.
- No steady state: ramping too fast or measuring during warm-up (cold caches, JIT compilation, autoscaling still reacting).
- Unrealistic data: tiny tables fit in memory; production tables do not.
- Averages: reporting mean latency, or averaging per-server percentiles, hides the tail that users feel.
In production
Teams commonly use tools such as k6, Gatling, JMeter, Locust or wrk2, with results stored as histograms. Define the question and pass/fail criteria first (for example: P99 < 300 ms and < 0.1% errors at 1.5× forecast peak). Run from outside the system under test, preferably from several machines. Monitor every tier during the run (CPU, memory, connection pools, queue depths, GC) so the test identifies the bottleneck, not just the symptom. Keep runs reproducible: same data, same script versions, recorded environment.
Common misconceptions
- “It handled the max RPS, so we are fine at that load.” At the maximum you are past the knee; latency is already poor.
- “Average latency is good enough.” The tail decides user experience, especially when one page makes many calls.
- “More virtual users means more load.” In a closed model, a slower system automatically receives less load.
- “A one-hour test proves stability.” Leaks and growth may take a day to surface.
Interview angle
Expect to be asked how you would verify a design’s capacity claims. Describe the test types and when each applies, ramping to find the knee, judging on P99 at a stated rate against an SLO, and an open-model generator to avoid coordinated omission. Mentioning realistic data and a non-bottlenecked generator shows experience.
Model assumptions
Simplified model, not a benchmark. The load generator sends open-loop (Poisson) traffic through a round-robin load balancer to two app servers, each with 4 workers, a 25 ms mean service time with a long tail (lognormal, cv 0.8) and a queue of 40 requests before it answers 503; together they handle about 320 requests per second. Plateaus last a few seconds of simulated time, so steady state is approximate. The soak test’s leak is modelled by lowering App 1’s speed every 3 seconds (hours compressed into seconds). The open-loop stall slows both servers 20× for 600 ms. The closed-loop virtual user is a scripted illustration: the engine’s clients are always open-loop. Numbers are illustrative.