KatInterview

Diagnosing a Latency Spike in a Distributed Ingestion Pipeline

System DesignModel answer
MediumModel answerSystem Designobservabilityincident-responsedistributed-systems

Last updated

Walk through a systematic incident investigation: triage customer impact, correlate observability signals across service tiers, and separate root causes from cascading symptoms.

Scenario

You are the on-call engineer for a high-volume event ingestion platform. Connected edge devices stream sensor readings through a pipeline that includes an API gateway, a message broker, a pool of processing workers, a search cluster, and a relational metadata database.

At 14:15 UTC you receive a page. The gateway's p99 latency has jumped from ~40ms to over 6,000ms. Downstream consumers are seeing a flood of 504 Gateway Timeout errors. Simultaneously, alerts fire for elevated CPU across the worker pool and growing connection-pool backpressure.

Your Task

Describe how you would methodically investigate this incident, identify the true root cause, and distinguish it from the secondary failures it triggered.

Address each of the following in your answer:

  1. First Response — Impact and Containment: Which signals do you look at in the first five minutes to understand customer impact? What actions can you take to reduce harm before you know the root cause?

  2. Tracing the Bottleneck Through the Stack: How do you combine per-tier RED metrics (Rate, Errors, Duration), distributed trace spans, and structured logs to locate where in the call chain latency first diverged?

  3. Proving Cause, Not Just Correlation: CPU saturation, thread-pool exhaustion, and connection timeouts are typically consequences, not causes. Walk through a concrete example of how you would confirm or rule out a database lock, a bad deployment, or a sudden traffic surge as the origin of this incident.

  4. Closing the Incident and Preventing Recurrence: What measurable criteria tell you the system has fully recovered? What safeguards would you recommend to reduce the likelihood of a similar event?

Hints

Hint 1

Start by checking the change log against the incident timestamp before digging into metrics — most production outages are caused by something that changed recently, and this is the cheapest high-value check you can do.

Hint 2

To find which tier originated the problem, plot Duration for every hop on the same time axis. The tier whose latency rose first is the likely source; everything upstream is just waiting on it and will show the spike slightly later.

Hint 3

High CPU and pool exhaustion are saturation signals, not root causes. Ask: what are threads blocked waiting on? If DB query duration exploded while DB CPU is low, look for lock contention rather than compute pressure.