Stress Testing Guide for Nginx On Ubuntu VPS
2025-06-28 23:19:53 - Rao Ashish Kumar
β Objective
To evaluate how our API /api/testendpoint handles different levels of concurrent user loads and request volumes on our VPS environment.
π οΈ Tools Used
- Apache Benchmark (ab) β Simple HTTP load testing tool.
- Netdata β Real-time system monitoring during tests.
π₯ Step 1: Install Apache BenchmarkOn Ubuntu VPS:
sudo apt install apache2-utils -y
π¦ Step 2: Running the Stress TestsπΈ Test 1 β Moderate Load:
- Command:
ab -n 500 -c 50 http://<server-ip>/api/testendpoint
- Purpose: Simulate 50 concurrent users making a total of 500 requests.
- Observation:
- Avg response ~1.3 seconds.
- No failed requests.
- CPU spiked to 100% during the test.
πΈ Test 2 β Lighter Concurrency:
- Command:
ab -n 200 -c 25 http://<server-ip>/api/testendpoint
- Purpose: Simulate 25 concurrent users with 200 total requests.
- Observation:
- Avg response ~594ms.
- No failed requests.
- CPU usage stayed moderate.
πΈ Test 3 β High Volume, Low Concurrency:
- Command:
ab -n 5000 -c 50 http://<server-ip>/api/testendpoint
- Purpose: Sustain 50 concurrent users over a long session (5000 requests total).
- Observation:
- Avg response ~1.3 seconds.
- Throughput ~38 requests/sec.
- Stable performance without failures.
π Step 3: Monitoring with Netdata
- During each test, Netdata was used to monitor:
- CPU Utilization β Observed spikes to 100% during high concurrency.
- RAM Usage β Stayed stable; no leaks.
- Disk I/O β No significant bottlenecks.
- Network I/O β Spikes matched request throughput.
- PostgreSQL Metrics β Connections and query throughput were stable.
π― Observations Summary Test Concurrency Avg Response RPS Failures CPU Impact 1 50 1.3s ~38 0 100% spike 2 25 594ms ~42 0 Moderate 3 50 1.3s ~38 0 100% spike π Recommendations
- β Current setup comfortably handles up to 25 concurrent users with response time under 600ms.
- β οΈ 50 concurrent users causes CPU saturation, leading to ~1.3s response time consistently.
- π₯ Immediate optimizations:
- Cache API responses for repeated queries.
- Scale VPS CPU from 1 core to 2-4 cores.
- Optimize PostgreSQL queries (check for N+1, indexing).
π₯ Request Flow During ab Test:
ab tool β NGINX β PHP-FPM (Laravel) β PostgreSQL (if DB involved)
β Conclusion
- System is stable under heavy load.
- No memory leaks or server crashes observed.
- Performance bottleneck is primarily CPU-bound, especially with Laravel app logic and database interactions during concurrent load.
- Netdata proved highly effective in real-time monitoring and bottleneck diagnosis.
This document serves as the record for how we conducted our stress testing, what was observed, and the actionable outcomes.