Load testing

On this page 7

Load testing is a type of performance testing that applies a realistic, controlled workload to a software system and measures how its response time, throughput and error rate behave at the expected and peak levels of use. In software testing and programming practice, it answers a practical question: will the application meet its service level objectives when the anticipated number of users, requests or transactions arrives at the same time?

Unlike functional tests such as a unit test or an end-to-end test, which ask whether the system produces the correct result, a load test asks whether it produces that result fast enough and reliably enough at scale. It is usually run against a production-like environment, and its results guide capacity planning, infrastructure sizing and release decisions.

How a load test generates and measures traffic

A load test works by running a load generator that simulates many concurrent clients, each executing a scripted user journey such as logging in, searching and placing an order. The generator records the timing and outcome of every request, while monitoring agents on the servers capture CPU, memory, connection pools and database activity at the same time.

Two workload models exist, and choosing between them matters. In a closed model, a fixed number of virtual users loop through their scripts, so a slower system automatically receives fewer requests. In an open model, requests arrive at a fixed rate regardless of how the system responds, which reflects public web traffic more faithfully and exposes queueing collapse that a closed model can hide.

A typical run has distinct phases, and the table below shows what each phase contributes to a valid measurement.

PhasePurposeTypical duration
Ramp-upIncrease load gradually to the target level5 to 15 minutes
Steady stateHold the target load and collect metrics30 to 60 minutes
Ramp-downReduce load and observe recovery5 to 10 minutes
AnalysisCorrelate client metrics with server telemetryAfter the run
Phases of a typical load test run

Only the steady-state window should be used for pass or fail decisions, because ramp-up includes cold caches, just-in-time compilation and connection pool warm-up that distort the numbers.

Metrics that define a load test result

A load test result is defined by a small set of metrics that together describe speed, capacity and correctness under load. Reporting the average response time alone is a classic mistake, since averages conceal the slow requests that real users notice most.

MetricWhat it measuresTypical target example
ThroughputCompleted requests or transactions per second500 requests per second
p95 latencyResponse time below which 95% of requests fallUnder 300 ms
p99 latencyTail response time for the slowest 1%Under 1 second
Error rateShare of failed or timed-out requestsBelow 0.1%
Resource utilizationCPU, memory, I/O and pool usage on serversCPU below 70%
Core load testing metrics and their meaning

Percentile latencies matter because a page that triggers twenty backend calls is likely to hit at least one slow call; the tail therefore shapes the experience of most users. Teams should also watch for coordinated omission, a measurement flaw in which a stalled client stops sending requests and the tool silently records fewer slow samples than actually occurred.

Little’s law links the main figures: the average number of requests in the system equals throughput multiplied by average response time. This relationship helps testers derive a realistic number of virtual users from production analytics instead of guessing.

Load testing is one member of the broader performance testing family, and each member applies a different load shape to answer a different question. Confusing them leads to tests that look rigorous yet do not address the actual risk.

Test typeLoad shapeMain question answered
Load testExpected and peak production loadDoes the system meet its targets?
Stress testLoad beyond expected peakWhere and how does it break?
Spike testSudden sharp increaseDoes it absorb abrupt surges?
Soak testNormal load for many hoursDo leaks or degradation appear over time?
Capacity testStepwise increaseWhat is the maximum sustainable load?
Load testing and neighboring test types

A smoke test at very low load is often run first to confirm that the scripts work before an expensive full run. Load tests also complement regression testing: running the same scenario after every significant change turns performance into a tracked quantity instead of a surprise discovered in production.

Designing a credible load test

A credible load test reproduces the traffic mix, data volume and environment of production closely enough that its conclusions transfer. The most valuable input is real usage data: access logs and analytics reveal which endpoints dominate, how long users pause between actions and when daily peaks occur.

  • Model think time between steps; scripts without pauses generate unrealistic request rates per user.
  • Use parameterized test data so that thousands of virtual users do not hit the same cached record.
  • Size the database to production-scale volume, because query plans change dramatically with table size.
  • Run the generator on separate machines so that client saturation does not masquerade as server slowness.
  • Define pass criteria before the run, expressed as percentile latency, throughput and error thresholds.

The following decision table helps select the scenario that fits a given goal.

SituationRecommended scenarioReason
New release before launchPeak-load test at 1.5x forecastProvides headroom for forecast error
Seasonal sales eventSpike plus load testTraffic arrives in sudden bursts
Suspected memory leakSoak test of 8 to 24 hoursLeaks surface only over time
Infrastructure migrationSame scenario on old and new stackAllows direct comparison
Continuous delivery pipelineShort baseline load test per buildDetects regressions early
Choosing a load testing scenario

Widely used open-source tools include Apache JMeter, Gatling, k6 and Locust; they differ mainly in scripting language, resource efficiency and reporting, not in the underlying principle.

Limitations and common load testing mistakes

Load testing has inherent limits: it can only validate the scenarios that were modeled, and a passing result says nothing about traffic patterns nobody anticipated. Third-party services are often replaced with a mock or stub during the test, which removes a real source of latency and failure from the picture.

MistakeConsequenceCorrection
Testing a scaled-down environmentResults do not extrapolate linearlyTest at production parity or document the gap
Reporting averages onlyTail latency problems stay hiddenReport p95 and p99 percentiles
Ignoring warm-upMisleading early measurementsAnalyze the steady-state window only
Overloaded load generatorFalse bottleneck on the client sideMonitor generator CPU and network
No server-side telemetrySymptoms without root causeCorrelate with application monitoring
Frequent mistakes and how to correct them

Another misconception is that autoscaling removes the need for load testing. Scaling policies react with a delay of seconds to minutes, and databases, message brokers and licensed services frequently cannot scale horizontally at all, so the true bottleneck often sits behind the scalable tier.

Stripped to the essentials

Load testing is a rehearsal for a busy day. Before a shop opens for a big sale, the owner might invite many people to walk through at once to see whether the checkout lines move and the aisles stay clear. Load testing does the same for software: a program pretends to be thousands of users and watches how the application copes.

The goal is not to check whether buttons work, but whether the system stays fast and does not fail when many people use it together. If pages slow down or errors appear, the team learns where the weak spot is and can fix it before real customers arrive.

Where it is applied

An online ticketing platform expects about 40,000 visitors in the first hour after a popular concert goes on sale. Its engineers analyze last year’s logs, build a k6 scenario in which virtual users browse events, select seats and pay, and set pass criteria of p95 latency under 500 ms and an error rate below 0.5% at 1,200 requests per second.

The first run fails at about 800 requests per second: the seat reservation query locks rows and the database connection pool is exhausted. After adding an index, shortening the transaction and enlarging the pool, a second run sustains 1,500 requests per second with p95 latency of 310 ms. On sale day, the platform handles the real peak without an outage, and the test scenario remains in the pipeline as a baseline for future releases.