Stress Testing: Finding Breaking Point and Load Limits
Your site crashes under a flash crowd? We pinpoint the breaking point before your users do. Stress testing is a load test that deliberately exceeds normal peak values. For an e‑commerce store before a sale, we simulate up to 10,000 virtual users to see at which RPS errors appear.
Stress tests reveal bottlenecks: database, CPU, memory, network. The output is concrete numbers: p95 latency, error rate, maximum RPS. This prevents downtime and can save up to 40% of infrastructure budget. Based on our practice (over 100 projects), clients cut server costs by 30–50% after optimizing from stress test results. For instance, one e-commerce client saved $12,000 per month on AWS costs after we identified and fixed a database bottleneck. Typical stress test projects start at $2,000 and can go up to $10,000 depending on complexity.
Problems We Solve
Sudden latency spikes. During a campaign, response times jump from 200ms to 5s. We identify the exact bottleneck – slow database queries, misconfigured caches, or insufficient connection pools.
Out‑of‑memory crashes. Under moderate load, the application dies with ENOMEM. We trace memory leaks and fix process limits.
Slow recovery after load. Even if the system survives a peak, a slow return to normal (over 2 minutes) indicates poor connection pool settings or memory leaks. We always test recovery.
How We Do It
We use k6 – a tool that consumes 5x fewer resources than Apache JMeter and outperforms it by 5x. k6 is written in Go and supports JavaScript scripts, making it ideal for CI/CD. The process has four stages:
- Baseline. Run a normal load (50–70% of expected peak) and record p95 latency, error rate, CPU/memory.
- Stepwise increase. Raise load by 10–20% every 2–5 minutes until errors or critical delay appear.
- Find breaking point. Continue until error rate >5% or latency >5× baseline.
- Recovery. Remove load and measure time to return to normal.
Below is a k6 scenario for a stress test with gradual ramp to 1600 virtual users:
// tests/stress/breaking-point.js
import http from 'k6/http'
import { check, sleep } from 'k6'
import { Rate, Trend, Counter } from 'k6/metrics'
const errorRate = new Rate('errors')
const requestsPerSecond = new Counter('requests_per_second')
export const options = {
stages: [
{ duration: '2m', target: 50 },
{ duration: '3m', target: 50 },
{ duration: '2m', target: 100 },
{ duration: '3m', target: 100 },
{ duration: '2m', target: 200 },
{ duration: '3m', target: 200 },
{ duration: '2m', target: 400 },
{ duration: '3m', target: 400 },
{ duration: '2m', target: 800 },
{ duration: '3m', target: 800 },
{ duration: '2m', target: 1600 },
{ duration: '3m', target: 1600 },
{ duration: '5m', target: 50 },
{ duration: '3m', target: 0 },
],
thresholds: {
http_req_duration: [
{ threshold: 'p(95)<2000', abortOnFail: false },
],
errors: [
{ threshold: 'rate<0.1', abortOnFail: false }
]
}
}
const BASE_URL = __ENV.BASE_URL || 'http://localhost:3000'
export default function() {
const responses = http.batch([
['GET', `${BASE_URL}/api/products?limit=20`],
['GET', `${BASE_URL}/api/categories`],
])
responses.forEach(r => {
check(r, { 'status 2xx': (r) => r.status >= 200 && r.status < 300 })
errorRate.add(r.status >= 400)
})
requestsPerSecond.add(2)
sleep(0.1)
}
export function handleSummary(data) {
const stages = analyzeStages(data)
return {
'stress-results.json': JSON.stringify(data, null, 2),
stdout: generateReport(stages)
}
}
function generateReport(stages) {
return `
=== STRESS TEST REPORT ===
Breaking Point Analysis:
${stages.map(s => ` VUs: ${s.vus} | p95: ${s.p95}ms | Errors: ${(s.errorRate*100).toFixed(1)}%`).join('\n')}
`
}
For a marketplace, the system was stable at 500 RPS but took 4 minutes to recover after load was removed. Diagnostics revealed misconfigured PostgreSQL connection pools. After optimization, recovery time dropped to 30 seconds and throughput increased to 1500 RPS.
Process and Estimation
Our work follows these steps:
- Gather data – application architecture, expected traffic, endpoints to test.
- Audit/Analysis – review infrastructure, identify likely bottlenecks.
- Design test plan – define metrics, load profile, success criteria.
- Estimate – provide time and cost based on complexity.
- Execute stress test – run the scenario, collect metrics.
- Deliver report – breaking point, recommendations, recovery time.
- Retest – after fixes, validate improvements.
Typical projects start at $2,000 and can go up to $10,000 depending on complexity. Each project is evaluated individually.
Timelines
A standard stress test with the described scenario takes 2–3 business days. Complex architectures or multiple endpoints may require more time.
Common Mistakes & Checklist
- Ignoring recovery time. A system that survives load but recovers slowly may collapse under repeated spikes. Always measure recovery.
- Testing only happy path. Stress tests must include realistic user scenarios – searches, filters, checkouts.
- Not monitoring during test. Without parallel monitoring of CPU, memory, database connections, you cannot correlate symptoms with causes. We always run monitoring scripts.
Monitoring script for stress test
#!/bin/bash
# scripts/monitor-stress-test.sh
TARGET_HOST="app-server-ip"
INTERVAL=10
while true; do
TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ)
ssh $TARGET_HOST "
echo -n '$TIMESTAMP '
echo -n 'cpu:'; top -bn1 | grep 'Cpu(s)' | awk '{print \$2}'; echo -n ' '
echo -n 'mem:'; free | grep Mem | awk '{print \$3/\$2 * 100}'; echo -n ' '
echo -n 'load:'; cat /proc/loadavg | awk '{print \$1}'
echo -n 'conns:'; ss -s | grep -o 'estab [0-9]*' | awk '{print \$2}'
"
ssh $TARGET_HOST "
PGPASSWORD=pass psql -U app -d appdb -t -c \"
SELECT 'active_queries:', count(*) FROM pg_stat_activity
WHERE state = 'active' AND query NOT LIKE '%pg_stat%';
SELECT 'long_queries:', count(*) FROM pg_stat_activity
WHERE state = 'active' AND query_start < NOW() - interval '5 seconds';
SELECT 'locks:', count(*) FROM pg_locks WHERE NOT granted;
\"
"
sleep $INTERVAL
done | tee stress-monitor.log
Analyzing Results with Prometheus and Grafana
We stream k6 metrics to Prometheus via Remote Write and build dashboards in Grafana. Example PromQL:
# RPS in real time
rate(k6_http_reqs_total[30s])
# Error rate over time (find degradation moment)
rate(k6_http_req_failed_total[30s]) / rate(k6_http_reqs_total[30s])
# p95 latency in real time
histogram_quantile(0.95, rate(k6_http_req_duration_seconds_bucket[30s]))
Python script to automatically find the breaking point:
# analyze_stress_results.py
import json
import pandas as pd
def analyze_breaking_point(results_file):
with open(results_file) as f:
data = json.load(f)
metrics = data['metrics']
analysis = {
'max_rps_before_errors': find_max_sustainable_rps(metrics),
'error_threshold_rps': find_error_threshold(metrics),
'latency_degradation_point': find_latency_degradation(metrics),
'recovery_time_seconds': find_recovery_time(metrics),
}
print("=== Breaking Point Analysis ===")
print(f"Max sustainable RPS (< 1% errors): {analysis['max_rps_before_errors']}")
print(f"Error threshold RPS: {analysis['error_threshold_rps']}")
print(f"p95 > 1s at RPS: {analysis['latency_degradation_point']}")
print(f"Recovery time after load removal: {analysis['recovery_time_seconds']}s")
if analysis['max_rps_before_errors'] < 100:
print("\n[!] LOW capacity. Consider: DB connection pooling, caching, horizontal scaling")
elif analysis['recovery_time_seconds'] > 120:
print("\n[!] SLOW recovery. Consider: circuit breakers, graceful degradation")
return analysis
What's Included in the Work
- Documentation of the breaking point (RPS, latency, error rate)
- Grafana dashboards with test history and metric correlation
- Prioritized optimization recommendations (critical / desirable)
- Retesting after changes are applied
- Recovery time report
- Guaranteed delivery within 2 business days
When to Stress Test?
We recommend stress tests after every major release, after architecture changes (e.g., migration to new hosting or adding caching), and quarterly to monitor performance degradation. This helps prevent downtime during peak loads.
Typical Bottlenecks and Diagnostics
| Symptom | Likely Cause | Diagnostics |
|---|---|---|
| Latency grows, CPU low | DB locks or slow queries | pg_stat_activity, slow query log |
| CPU 100%, few errors | Computational bottleneck | top, profiler |
ENOMEM errors |
Memory leak or OOM | free -m, /proc/meminfo |
| Connection refused | Pool exhausted | pgBouncer stats, netstat |
| 502 Bad Gateway | Workers overloaded | Nginx error log, worker processes |
Tool Comparison
k6 is 5x better than JMeter for stress testing in terms of resource efficiency and automation.
| Tool | Resources | Scripting | Integration |
|---|---|---|---|
| k6 | 5x lighter than JMeter | JavaScript, Go-like | Prometheus, Grafana, Datadog |
| Apache JMeter | Heavy | GUI, XML | Plugins |
| Locust | Medium | Python | InfluxDB |
k6 wins in performance and automation simplicity. We use it on all projects. Our certified engineers have over 10 years of experience in load testing, allowing us to quickly identify bottlenecks and give precise recommendations.
Order a stress test and receive a detailed report with recommendations. We guarantee a comprehensive report within 2 business days. Or contact us to discuss your project.







