Order API Spikes from 80ms to 4s: Three Thread Pool and Timeout Traps That Looked Normal
A single slow dependency can take down an entire order service without a single red metric, and the fixes that feel intuitive often make things worse. Any team running JVM-based microservices will eventually hit these same failure modes, so the concrete patterns here are directly applicable.
A Java backend order service saw response times jump from 80ms to 4 seconds while CPU, memory, and GC all looked healthy. The root cause chain began with a single shared thread pool used for all remote calls. When one downstream (coupon) slowed down, its slow requests occupied every thread, and because `newFixedThreadPool` uses an unbounded queue, the entire JVM died. Isolating thread pools per dependency seemed like a fix, but throughput dropped 15%: the team had bumped threads to 50 while the HikariCP database pool still had 20 connections, adding only context switching and lock contention.
The second fix—aligning thread and connection pools—uncovered the nastiest trap. During a load test, the gateway's 2-second timeout on the order endpoint forced retries while downstream timeouts were set at 5 and 8 seconds. Each retry spiraled into more coupon calls, creating a retry storm that took the coupon service down entirely. The article walks through how a positive feedback loop forms when every layer retries independently, then prescribes three principles: isolate shared resources with bulkheads and bounded queues, treat timeouts as a decreasing budget across layers, and put circuit breakers on failure propagation.
The three pitfalls are not independent bugs but progressive symptoms of one design flaw: unbounded resource sharing and failure propagation. Fixing one without addressing the underlying boundary principle just moves the damage downstream.
Green dashboards give a false sense of safety when the real risk sits in unbounded queues, absent retry budgets, and silent thread contention that never trips conventional alerts.
The most counterintuitive correction is that more threads and bigger connection pools can degrade throughput, contradicting the common instinct to scale up horizontally when latency rises.