Het Siddhapura’s Post

View profile for Het Siddhapura

California State University…3K followers

Most “Simple” APIs Fail the Same Way, Here’s What Actually Breaks First I took a minimal Flask API (one endpoint + PostgreSQL) and load tested it with k6 until it started to crack. The goal wasn’t to build a high‑performance system, but to understand how a typical service degrades under load and what scaling actually means. Setup: • Flask app with Gunicorn (4 workers) • PostgreSQL with a single indexed table • k6 running on a local machine • One endpoint: GET /data → simple SELECT query What Broke First (and Why): • CPU saturation - At ~350 req/s, CPU spiked to 100%. Response times increased linearly, why because the API logic itself request parsing, JSON serialization became the bottleneck before the database even saw the traffic. • Database contention - After increasing workers, the bottleneck shifted. PostgreSQL showed high wait events and connection queueing. Why? because Concurrent connections overwhelmed the database’s pool. Even simple reads slowed down under concurrency. Tradeoffs I Observed: • Caching → reduced DB load by ~70% but added ~200MB memory overhead • More workers → improved throughput until CPU became the limit again • Database indexes → lowered per‑query latency but didn’t solve concurrency spikes Have you load tested your own services? What was the first bottleneck you hit? #BackendEngineering #DevOps #SystemDesign #Performance #LoadTesting

To view or add a comment, sign in

Explore content categories