← QA Library
Chapter 11 / 19 · 8 min read

Performance and load testing

Types of performance tests, the metrics that matter, how to design a realistic load test and how to read the results.

A feature that works for one user can collapse under a thousand. Performance testing answers three questions: how fast is the system now, how much load can it take, and what breaks first when it's overloaded.

Types of performance tests

TypeQuestionExample
LoadDoes it meet targets at expected traffic?500 concurrent users browsing and buying for 30 minutes
StressWhere is the breaking point and how does it fail?Increase users until errors appear
SpikeCan it survive a sudden jump?Traffic ×10 in one minute after a newsletter or game launch
Endurance (soak)Does it degrade over time?Steady load for 8–24 hours to find memory leaks
ScalabilityDoes adding servers help?Repeat the load test with 2 and 4 instances
Front-end performanceHow fast does a page feel to a user?Core Web Vitals on a mid-range phone over 4G

Metrics that matter

  • Response time percentiles: the average hides problems; look at p95 and p99 (95% / 99% of requests were faster than this)
  • Throughput: requests or transactions per second
  • Error rate: share of failed requests under load
  • Resource usage: CPU, memory, database connections, queue length
  • Front-end metrics: Largest Contentful Paint (main content visible), Interaction to Next Paint (responsiveness), Cumulative Layout Shift (visual stability)
Why percentiles matter: response time (ms)Average180p50120p95650p991900
The average looks fine, but one request in a hundred takes almost two seconds — those users notice.

Designing a realistic test

  1. Define goals with the business: for example, “p95 under 800 ms for search and checkout at 300 concurrent users, error rate below 1%”.
  2. Model real behaviour: use analytics to choose scenarios and their proportions — most users browse, fewer search, even fewer pay.
  3. Prepare data: enough products, users and orders; avoid every virtual user hitting the same record.
  4. Use a production-like environment: a test on a laptop-sized server says little about production.
  5. Ramp up gradually and keep the peak long enough to see trends.
  6. Monitor the servers during the test, not just the load tool's report.

A small k6 script

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

export const options = {
  stages: [
    { duration: '2m', target: 100 },  // ramp up
    { duration: '10m', target: 100 }, // hold
    { duration: '1m', target: 0 },    // ramp down
  ],
  thresholds: {
    http_req_duration: ['p(95)<800'],
    http_req_failed: ['rate<0.01'],
  },
};

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

Reading the results

Look for the point where response times start climbing steeply or errors appear, then match it with server metrics. Typical culprits are slow database queries without indexes, too few database connections, synchronous calls to slow external services, missing caching, and memory leaks that only show up after hours.

Tools

ToolStrength
k6Scripts in JavaScript, great for CI and developers
Apache JMeterMature, GUI, many protocols
GatlingHigh performance, readable reports
LocustScenarios in Python
Lighthouse / PageSpeed InsightsFront-end performance and Core Web Vitals
Performance is a feature. Test it before launch, and run a smaller load test regularly so a slow query doesn't sneak into production unnoticed.