Rao Ashish Kumar 1 month ago
ashfouryou #development

Stress Testing Guide for Nginx On Ubuntu VPS

βœ… 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.

Redis Integration with Laravel: Setup, Configuration & Debugging Guide

Redis Integration with Laravel: Setup, Configuration & Debugging Guide

1753547848.jpeg
Rao Ashish Kumar
1 month ago
Backend Engineering Fundamentals

Backend Engineering Fundamentals

1753547848.jpeg
Rao Ashish Kumar
5 months ago
Netdata Installation & Monitoring Guide for VPS

Netdata Installation & Monitoring Guide for VPS

1753547848.jpeg
Rao Ashish Kumar
1 month ago

What We Tend To Forget About Writing Code in the Age of AI

1753547848.jpeg
Rao Ashish Kumar
2 weeks ago
video

Step By Step Create A Simple Scalable SaaS Waitlist With Lar...

ashfouryou
Rao Ashish Kumar
6 months ago