Performance testing

On this page 8

Performance testing is the practice of measuring how a software system behaves under a defined workload, in terms of response time, throughput, resource consumption and stability, and comparing the results with explicit goals. In testing within programming, it answers a different question from functional tests: not whether the system produces the correct result, but whether it produces it fast enough, for enough users, for long enough.

Performance testing is an umbrella term. It covers load testing, stress testing, soak testing, spike testing and benchmarking, each of which applies a different workload pattern to reveal a different class of problem. Done well, it turns vague complaints such as “the site feels slow” into reproducible numbers that engineers can act on.

How a performance test is built

Every performance test combines four elements: a workload model, a test environment, a measurement setup and pass or fail criteria. If any of these is vague, the results cannot be trusted or compared between runs.

The workload model describes what virtual users or clients do: which requests they send, in what proportions, with what think time between steps and with what data. A realistic model is usually derived from production traffic logs rather than guessed. The load generator then executes this model with tools such as JMeter, Gatling, k6 or Locust.

The test environment should resemble production in hardware, configuration, data volume and network topology. A database with a thousand rows behaves very differently from one with fifty million, so undersized test data is one of the most common reasons performance tests miss real problems.

Finally, acceptance criteria are stated before the run, for example “95th percentile response time below 300 ms at 500 requests per second with an error rate under 0.1 percent”. Criteria written after seeing the results tend to rationalize whatever happened.

Types of performance testing

The type of performance test is defined by the shape and duration of the load, and each type targets a specific risk. Teams rarely need all of them for every release, but they should know which risk each one covers.

TypeLoad patternQuestion it answers
Load testingExpected peak load, held steadyDoes the system meet its goals at normal peak?
Stress testingLoad increased beyond capacityWhere and how does the system break?
Soak testingModerate load for many hoursDo leaks or slow degradation appear over time?
Spike testingSudden sharp jumps in loadDoes the system absorb and recover from bursts?
Scalability testingLoad and resources raised togetherDoes capacity grow in proportion to resources?
BenchmarkingFixed, repeatable micro or macro workloadIs this version faster or slower than the last?
Main types of performance testing

Load testing is the most frequently run type and has its own detailed treatment as a separate term. Soak tests are especially valuable for services that run continuously, because memory leaks, connection pool exhaustion and growing log files often surface only after six to forty-eight hours of operation.

Metrics that define performance

Performance results are meaningful only when expressed through well-defined metrics with percentiles, never through a single average. Averages hide the slow requests that real users actually notice.

The table below lists the core metrics, their usual units and what each one reveals.

MetricTypical unitWhat it reveals
Response time percentilesMilliseconds (p50, p95, p99)User-perceived speed, including tail latency
ThroughputRequests or transactions per secondWork completed per unit of time
Error ratePercent of requestsFailures and timeouts under load
ConcurrencyActive users or open connectionsParallel demand the system sustains
Resource utilizationCPU, memory, disk and network percentWhich resource saturates first
Saturation indicatorsQueue length, thread pool usageWhether work is waiting rather than running
Core performance testing metrics

The 95th and 99th percentiles matter most for user experience. A service with a 120 ms median and a 4-second p99 still frustrates one request in a hundred, and in a page that makes dozens of backend calls, tail latency compounds into a noticeable share of slow page loads.

Where performance testing fits among other tests

Performance testing is a non-functional testing discipline, so it complements rather than replaces unit tests, integration tests and end-to-end tests. Functional suites confirm correctness; performance suites confirm that correctness survives realistic volume and concurrency.

PracticeMain focusTypical frequency
Performance testingSpeed, capacity and stability under loadBefore releases, nightly or on demand
Unit testCorrectness of a small code unitEvery commit
End-to-end testCorrectness of a complete user flowEvery merge or release candidate
Regression testingUnchanged behavior after modificationsEvery release
ProfilingWhere time and memory go inside codeDuring diagnosis, not as a gate
Performance testing compared with related testing practices

Many teams now add performance regression checks to the CI pipeline: short, repeatable benchmarks that fail the build when a key operation becomes, for example, more than 10 percent slower than the stored baseline. Full-scale tests still run less often, because they need a production-like environment.

Planning and running a reliable test

A reliable performance test follows a repeatable cycle: define goals, model the workload, prepare the environment, run, analyze and retest after each change. Changing several variables at once makes it impossible to tell which change caused an improvement or a regression.

  1. Derive measurable goals from service level objectives or business requirements.
  2. Build the workload model from production logs, including data variety and think time.
  3. Warm up caches and runtimes before measuring, then use a steady ramp-up.
  4. Monitor both the load generators and the system under test, so that client-side bottlenecks are not mistaken for server limits.
  5. Repeat each run at least three times and compare distributions, not single values.

Observability is essential during the run. Application metrics, traces and database statistics turn a symptom such as rising latency into a diagnosis such as lock contention on a single table.

Common mistakes in performance testing

Most misleading performance results come from unrealistic conditions rather than faulty tools. The following table lists frequent mistakes, their effects and how to avoid them.

MistakeEffect on resultsRemedy
Reporting only averagesTail latency stays hiddenReport p95 and p99 alongside the median
Tiny test databaseQueries look fast thanks to cachingUse production-scale anonymized data
Overloaded load generatorGenerator becomes the bottleneckMonitor and scale the load generators
Coordinated omissionSlow responses are undercountedUse open workload models or corrected tools
Testing once before launchRegressions slip in laterAutomate recurring baseline comparisons
Frequent performance testing mistakes

Coordinated omission deserves special attention: when a closed-loop generator waits for each slow response before sending the next request, it silently sends fewer requests during slowdowns, so reported latency looks far better than reality.

The idea in brief

Performance testing checks whether software stays fast and steady when many people use it at once. A program can work perfectly for one person and still slow to a crawl when ten thousand people arrive together.

It is similar to testing a new bridge with heavy trucks before opening it to traffic. Engineers do not just confirm that it stands; they measure how it behaves under the expected weight, under extra weight and over a long period. The goal is to find weak points before real users do.

A practical scenario

An online ticket retailer expects about 20,000 concurrent visitors when sales for a popular concert open. Two weeks before the event, the engineering team runs performance tests in a staging environment that mirrors production and holds a full copy of the anonymized event database.

A load test at the expected peak shows a p99 checkout time of 6 seconds, far above the 1-second goal. Traces reveal that every checkout locks the same seat-inventory row. A spike test from 500 to 20,000 users in one minute also shows the connection pool running out after 40 seconds.

The team switches to row-level seat reservations and enlarges the pool. On the retest, p99 checkout time drops to 700 ms with an error rate below 0.05 percent, and the real sale runs without an outage.