Definition
- Performance testing – Evaluates how a system behaves under concurrent load, measuring response time, throughput, and error rate.
- Load testing – Applies normal expected load to confirm the system meets its SLA targets.
- Stress testing – Pushes beyond normal load to find the breaking point and observe failure behavior.
- Spike testing – Applies a sudden sharp burst to check the system handles abrupt surges.
- Endurance/soak testing – Applies sustained load for hours or days to surface memory leaks and gradual degradation.
- Key principle – Each type answers a different question: fast enough, where does it break, survives a surge, stays healthy over time.
Functional testing asks whether the National Bank of India transfer works; performance testing asks whether it still works when thousands of customers transfer at once. Load testing is a normal busy day. Stress testing keeps piling on more until the bank buckles. Spike testing is the instant everyone logs in when salaries are credited. Soak testing keeps a steady stream for days to catch a slow drip that eventually floods.
Understanding the Concepts
What is performance testing?
Performance testing is a non-functional discipline that answers how well the system performs under concurrency. The core measurements are response time, throughput, and error rate.
// k6: basic performance test structure
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
vus: 100,
duration: '5m',
thresholds: {
http_req_duration: ['p95<200'],
http_req_failed: ['rate<0.01'],
},
};
export default function () {
const res = http.get('https://staging.nationalbank.in/api/accounts');
check(res, { 'status 200': (r) => r.status === 200 });
sleep(1);
}
What is load testing?
Load testing applies the normal and peak expected load and verifies the system meets its SLA.
// k6: load test at expected peak
export const options = {
stages: [
{ duration: '2m', target: 500 }, // Ramp to expected peak
{ duration: '10m', target: 500 }, // Hold for stable readings
{ duration: '2m', target: 0 }, // Ramp down
],
thresholds: {
http_req_duration: ['p95<200'], // SLA: p95 under 200ms
http_req_failed: ['rate<0.01'], // Error rate under 1%
},
};
What is stress testing?
Stress testing pushes beyond normal to find the breaking point.
// k6: stress test - keep increasing until it breaks
export const options = {
stages: [
{ duration: '2m', target: 500 },
{ duration: '5m', target: 500 }, // Hold at expected
{ duration: '2m', target: 1000 },
{ duration: '5m', target: 1000 }, // Push beyond
{ duration: '2m', target: 2000 },
{ duration: '5m', target: 2000 }, // Find ceiling
{ duration: '2m', target: 0 }, // Recover
],
};
// Watch: where does latency spike? Where do errors rise?
// Does it recover when load eases?
What is spike testing?
Spike testing applies a sudden sharp burst rather than a gradual ramp.
// k6: spike test - sudden burst
export const options = {
stages: [
{ duration: '1m', target: 100 }, // Normal
{ duration: '10s', target: 2000 }, // Instant spike!
{ duration: '3m', target: 2000 }, // Hold the spike
{ duration: '10s', target: 100 }, // Drop back
{ duration: '3m', target: 100 }, // Recover
],
};
// Tests: autoscaling reaction, queueing, cascading failures
What is endurance or soak testing?
Soak testing runs sustained moderate load for hours or days to catch problems that only appear over time.
// k6: soak test - 12 hours at moderate load
export const options = {
stages: [
{ duration: '5m', target: 300 },
{ duration: '12h', target: 300 }, // Sustained for 12 hours
{ duration: '5m', target: 0 },
],
};
// Watch for: memory leaks, connection leaks, disk growth,
// gradual latency increase, error rate drift
How do the types compare?
| Type | Load Pattern | Duration | Question Answered |
|---|---|---|---|
| Load | Normal peak | 10-30 min | Fast enough at expected demand? |
| Stress | Beyond peak | 20-40 min | Where does it break? Graceful? |
| Spike | Sudden burst | 5-10 min | Survives a surge? Recovers? |
| Soak | Sustained moderate | Hours-days | Healthy over time? Leaks? |
What server metrics should you monitor?
Always monitor the system under test, not just the client-side metrics.
Client-side: Server-side:
───────────── ────────────
Response time (p95) CPU utilization
Throughput (req/s) Memory usage / heap
Error rate DB connection pool
Requests completed Disk I/O
GC pause time
Thread count
Downstream latency
What should a senior engineer know?
- Define clear SLA targets before testing: "p95 under 200ms at 500 users with error rate under 1%."
- Run against a production-like environment and data volume.
- Report percentiles, not averages, because averages hide the slow tail.
- Treat performance testing as iterative: load, measure, diagnose, fix, re-test.
- Use all four types for a mature strategy.
// Java: define SLA programmatically
package com.bank.perf;
public class PerformanceSLA {
public static final long P95_LATENCY_MS = 200;
public static final long P99_LATENCY_MS = 500;
public static final double MAX_ERROR_RATE = 0.01;
public static final int TARGET_THROUGHPUT_RPS = 5000;
public boolean isMet(PerfResult result) {
return result.getP95() <= P95_LATENCY_MS
&& result.getP99() <= P99_LATENCY_MS
&& result.getErrorRate() <= MAX_ERROR_RATE
&& result.getThroughput() >= TARGET_THROUGHPUT_RPS;
}
}
What are common interview follow-up questions?
- "Which type should you run first?" Load testing, to establish the baseline before pushing beyond.
- "How often should you run soak tests?" Before major releases, or weekly for critical services.
- "What is the difference between load and stress?" Load validates at expected demand; stress pushes past it to find the ceiling.
Visual Overview
Performance Testing Types
─────────────────────────
Load (VUs) Stress Spike
──────────── ──────────── ────────────
┌──────┐ ┌──────┐ ┌─┐
│ │ ┌─┤ │ │ │
│ │ ┌─┤ │ │ ┌───┤ │
┌─┤ ├─┐ ┌─┤ │ │ ├─┐ ┌─┤ │ ├─┐
───┤ │ │ ├─── ──┤ │ │ │ │ ├─── ────┤ │ │ │ ├───
└─┘ └─┘ └─┘ └─┘ └─┘ └─┘ └─┘ └─┘
Normal peak Beyond peak Sudden burst
Soak
────────────────────────────────────────
┌──────────────────────────────┐
│ │
┌─┤ 12+ hours ├─┐
───┤ │ │ ├───
└─┘ └─┘
Sustained moderate load
Each Type Answers a Different Question ────────────────────────────────────── Load ──> "Is it fast enough at expected demand?" Stress ──> "Where does it break? Does it recover?" Spike ──> "Does it survive a sudden surge?" Soak ──> "Does it stay healthy over hours/days?"
Key Takeaway
Performance testing evaluates how a system behaves under concurrent load, measuring response time as percentiles, throughput in requests per second, and error rate. I always start from a defined workload model and clear SLA targets, run against a production-like environment, and report percentiles not averages.
There are four types, each answering a different question. Load testing applies normal expected demand to verify the SLA is met. Stress testing pushes beyond to find the breaking point and observe whether the system degrades gracefully or collapses. Spike testing applies a sudden burst to check survival under an abrupt surge like salary-credit day. And soak testing runs sustained moderate load for hours or days to surface memory leaks, connection leaks, and gradual degradation.
I treat the four types as complementary. A mature strategy uses all four: load for the baseline, stress for the ceiling, spike for surges, and soak for long-running health.
At the National Bank of India these mattered acutely because salary day and month-end settlement are predictable surges. I load-tested against the expected peak, stress-tested to find the ceiling, spike-tested the salary-credit burst, and ran a twelve-hour soak that caught a slow memory leak.
Remember one sentence: performance testing has four types, load for expected demand, stress for the breaking point, spike for sudden surges, and soak for long-running health, and a mature strategy uses all four.
---