What is load testing and how do you design effective load tests?

Answer

Load testing verifies system behavior under expected and peak production load. Designing effective load tests: (1) Define SLAs: what response time and error rate are acceptable under load? (p95 < 200ms, error rate < 0.1%). (2) Realistic traffic patterns: use production access logs to model real user behavior (which endpoints, which request sequences, realistic data). (3) Ramp-up/ramp-down: gradually increase load — sudden spikes reveal different issues than gradual build-up. (4) Think time: add realistic pauses between user actions. (5) Data variety: use realistic, varied data — avoid testing only one user ID (may hit cache for all requests). (6) Test environment: production-like hardware/configuration — results from a dev laptop mean nothing. (7) Baseline first: establish baseline performance, then test changes against it. (8) Monitor everything: CPU, memory, DB connections, GC, application metrics — not just response time. (9) Isolate bottlenecks: use flame graphs and profilers when load tests reveal slowdowns. Tools: k6 (JavaScript scripting, great DX), Gatling (Scala DSL, excellent HTML reports), JMeter (GUI, widely used).