Interview Prep/Real-World Interview/Outages and incident response

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 →

  1. Confirm with database metrics and slow query logs that the job is the cause.
  2. Make the job gentler: process in small batches with pauses, add indexes for its queries, and limit its concurrency.
  3. Point read-heavy batch work at a read replica.
  4. Schedule it in the true low-traffic window for your users (midnight UTC may be peak somewhere else).
  5. Set a lower connection limit and statement_timeout for the batch DB user.
  6. 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.

All Real-World Interview questions Roadmap: Interview readiness

More on Outages and incident response