Load, stress, soak; tools, metrics, bottlenecks
Practise these as flashcards. One or two lines each; the ones you miss come back first.
Start freeLoad testing measures system performance under expected traffic, while stress testing pushes the system beyond its limits to find breaking points. Load tests help ensure the system can handle normal usage, and stress tests reveal how it behaves under extreme conditions.
p95 and p99 latency show how the slowest 5% or 1% of requests perform, which is crucial for user experience. Focusing only on average latency can hide outliers that impact real users, so these percentiles give a more accurate picture.
Two popular tools are JMeter, which offers a GUI and extensive plugins, and k6, which uses JavaScript scripting and is easy to integrate into CI pipelines.
Soak testing runs a system under sustained load for an extended period to uncover issues like memory leaks, resource exhaustion, or performance degradation that only appear over time.
I define goals based on business needs and technical requirements, such as throughput (requests per second), latency percentiles (like p95 < 200ms), and error rate (<0.1%). These metrics help determine if the API meets user expectations under load.
I'd analyze production logs to determine typical user flows, request types, and concurrency. For example, I'd simulate a mix of browsing (GET), adding to cart (POST), and checkout (PUT), with realistic think times and peak traffic patterns.
APM tools like Datadog or New Relic can trace requests, measure latency, and highlight slow database queries or code paths. During tests, I use them to correlate spikes in latency or errors with specific components, helping pinpoint bottlenecks.
Integrating performance tests in CI/CD allows early detection of regressions, ensures new code doesn't degrade performance, and automates quality checks. It helps maintain high standards and prevents issues from reaching production.
A spike in error rate usually indicates the system is overloaded or hitting a resource limit, such as CPU, memory, or database connections. I investigate logs and APM traces to identify the root cause and recommend scaling or optimization.
Test environment fidelity ensures results are valid and comparable to production. If the environment differs in hardware, software, or network, test results may not accurately predict real-world performance.
I consider scripting needs, scalability, integration with CI, and reporting features. For example, k6 is great for JavaScript scripting and CI, while JMeter is good for complex scenarios with its GUI and plugins.
Latency percentiles like p95 and p99 show how most users experience the system, especially during peak load. High percentiles indicate slow responses for a subset of users, which can impact satisfaction even if average latency is low.