Performance testing · Load testing · QA · Backend

Performance Testing Guide: Load, Stress and Spike Tests Done Right

The differences between load, stress, spike and soak testing, the metrics that matter (p95, error rate, throughput) and how to design realistic scenarios.

Sander Yazıcıoğlu Published: 4 min read Türkçe oku

While building the interface of a cloud load-testing platform at Loadium, I saw how hundreds of teams set up their tests and read their results. The most common mistake is not choosing the wrong tool; it is asking the wrong question. This guide helps you start performance testing with the right ones.

First, the question: what do you want to learn?

"How many users can our site handle?" is not a good question, because the answer depends on what users do. Better questions:

  • When 2,000 orders a minute arrive on campaign day, does checkout stay under 2 seconds?
  • At 3x normal traffic, which component becomes the bottleneck first?
  • Under moderate load for 8 hours, is there a memory leak?

Each question maps to a different kind of test.

Test types

TypeWhat it doesQuestion it answers
Load testApplies expected trafficDo we meet targets on a normal and a busy day?
Stress testRamps load until something breaksWhere is the limit, and how does it fail?
Spike testApplies a sudden, short surgeWhat happens on a campaign, push notification or TV ad?
Soak (endurance)Holds moderate load for hoursMemory leaks, exhausted connection pools?
Capacity testIncreases load step by stepHow many servers do we need to hit the target?

The right metrics

Averages lie; use percentiles

A system with a 400 ms average response time may still make 5% of users wait 4 seconds. Look at p95 and p99: "95% of requests completed under X ms".

The core four

  1. Response time (p50, p95, p99)
  2. Throughput: requests or transactions per second
  3. Error rate: HTTP 5xx, timeouts, wrong content
  4. Resource usage: CPU, memory, database connections, queue length

When load goes up but throughput stops rising and response time climbs fast, you have hit the saturation point. Knowing that point is the basis of capacity planning.

Write targets up front

Before the test, write down the success criteria: "The payment API keeps p95 < 800 ms and error rate < 0.5% at 2,000 orders per minute." Without a target, every result looks "not bad".

Designing realistic scenarios

Model user journeys

Real users don't just refresh the homepage: they search, browse products, add to cart, and some buy. Pull journey ratios from your analytics (say 60% browsing, 30% search, 10% checkout) and build the scenario to match.

Think time and ramp-up

  • Add think time between steps, or 100 virtual users behave like 1,000 real ones.
  • Ramp up load gradually rather than all at once. A sudden start measures nothing but an accidental spike test.

Test data

Thousands of requests with the same user and the same product make the system look faster than it is, thanks to caching. Use parameterised data: different users, products and search terms.

Choosing a tool

  • Apache JMeter: mature, a large plugin ecosystem, scenarios can be built in a GUI. Large loads need distributed runs or a cloud platform.
  • k6: scenarios in JavaScript, easy to add to CI/CD, light on resources.
  • Gatling: code-based scenarios with detailed reports.
  • Cloud platforms: for generating load from several regions, watching results live and sharing them across teams.

A simple k6 scenario:

import http from 'k6/http';
import { check, sleep } from 'k6';

export const options = {
  stages: [
    { duration: '2m', target: 200 },
    { duration: '10m', target: 200 },
    { duration: '2m', target: 0 }
  ],
  thresholds: {
    http_req_duration: ['p(95)<800'],
    http_req_failed: ['rate<0.005']
  }
};

export default function () {
  const res = http.get('https://staging.example.com/api/products?page=1');
  check(res, { 'status 200': (r) => r.status === 200 });
  sleep(Math.random() * 3 + 1);
}

With thresholds, the test fails when targets are missed, which gives you an automatic quality gate in CI.

Reading the results

  • Make sure the load generator isn't the bottleneck: if its CPU is above 80%, you are measuring the test machine, not your system.
  • Line up application metrics (APM, slow database query logs) with the test timeline. The answer to "why did p95 jump at 14:32?" is usually there.
  • Compare each run with the previous one. A single result is no substitute for a trend.

Conclusion

Performance testing starts before the tool: with the right question, realistic scenarios and targets written in advance. To improve perceived speed in the browser, see the Core Web Vitals article; for real-device mobile testing, see the Appium guide.

All articles →