Mitigating a Cascading Failure Caused by Downstream Database Saturation
Scenario Prompt:
“During peak marketing hours, the primary PostgreSQL database hits 100% CPU. API latency jumps from 40ms to 12,000ms. Upstream microservices retry every failed request, creating an exponential retry storm. How do you stop the cascade and restore stability?”
Substantive Technical Concepts to Hit:
Load Shedding & Rate Limiting
Enable aggressive edge rate limiting and drop non-essential traffic (e.g. analytics, recommendations) at the API Gateway to give the database breathing room.
Retry Backoff with Jitter
Ensure client microservices use exponential backoff with full jitter to break synchronized retry pulses that repeatedly slam the recovery attempts.
Connection Pool Throttling
Lower maximum client connections in PgBouncer to prevent thousands of competing backend processes from thrashing database CPU cache lines.
Circuit Breakers
Trip circuit breakers on upstream calling services to fail fast and serve fallback cached responses rather than waiting 30 seconds for database timeouts.
- Can we immediately shed non-critical background batch jobs and analytics queries?
- Do our client services implement circuit breakers or are they retrying indefinitely?
- Is the database CPU spike caused by connection pool exhaustion or a specific unindexed query lockup?