Every night at midnight a batch job hammers the shared database and the API slows down for 30 minutes. How do you fix it?
IntermediateScenarioOutages and incident response
Answer
Situation read → Batch and online workloads are competing for the same resources. Reduce, move or isolate the batch load.
What I'd do →
- Confirm with database metrics and slow query logs that the job is the cause.
- Make the job gentler: process in small batches with pauses, add indexes for its queries, and limit its concurrency.
- Point read-heavy batch work at a read replica.
- Schedule it in the true low-traffic window for your users (midnight UTC may be peak somewhere else).
- Set a lower connection limit and
statement_timeoutfor the batch DB user. - Long term: move analytics or bulk processing to a separate data store fed by CDC.
Why → Throttling and isolation protect user-facing latency without cancelling the batch job.
Interview tip → Ask whose midnight it is; global traffic patterns make "off-peak" ambiguous.
More on Outages and incident response
You're on call and get paged at 3 AM: "Checkout error rate 25%". What do you do in the first 15 minutes?BeginnerA major outage involves four teams and everyone is talking at once. You're asked to be incident commander. What do you do?IntermediateHow do you prove your platform survives the loss of a whole Availability Zone?AdvancedOn-call gets 300 alerts a day and people have started ignoring them. How do you fix alerting?IntermediateA customer told you about an outage on social media before your monitoring did. How do you fix detection?BeginnerDuring an incident, you can roll back or push a forward fix the developer says is ready in 10 minutes. How do you decide?Intermediate