Q14 · What’s your approach to detecting and isolating slow services?
Back to 24 Architecture Questions.
The question is not “add APM”. The axis it turns on: whether slowness is measured at the caller or the callee, and who absorbs it. A service can look healthy in its own metrics while every one of its callers bleeds capacity waiting for it. Until something isolates the wait, the caller pays for it, in blocked workers and fired timeouts.
What the answer should contain
Measure at the caller, because that is where slowness becomes someone’s problem. The metric that matters is time spent per dependency at the call site: per-hop durations in distributed tracing, and blocked worker or connection counts. A callee reporting a healthy p99 of 200 ms can still be slow to a caller that only allows it 50 ms.
The p99 only means something against the timeout for that call. 300 ms is healthy inside a 1 s wait allowance on a background job and fatal inside 100 ms on the checkout path. Alert per dependency when the wait starts eating the timeout, and treat the timeouts firing as the confirmed case.
Detect with a trace, not with opinions. End-to-end traces with per-hop durations find the slow service in one look; per-service dashboards invite a debate about whose average looks worse. The argument usually ends when someone shows the trace.
Isolate the wait. A separate pool per dependency (bulkhead: slow drains only its pool), circuit breakers that trip on slow-response ratio, not just errors, and load shedding at the edge when the fleet is saturated. Retrying a slow dependency is adding load to the thing you are waiting on: never.
Absorb by buffering, where the interaction allows it. Convert the sync call to async and the queue absorbs the slowness: the caller is free, and the backlog’s depth and age become the alarm. This converts a latency crisis into a visible, measurable backlog, which is exactly the property you want during an incident.
Degrade around the slow panel. Serve the page without the slow optional dependency, marked, rather than letting it set the page’s latency for everyone.
Ideas worth mentioning out loud
- A dependency drifting from 40 ms to 200 ms is invisible on its own dashboard and an outage on the caller’s.
- One slow service in a shared pool is a denial-of-service attack on every other dependency sharing that pool. Bulkheads are the antidote.
- The three responses in order: stop waiting (timeout), stop calling (breaker), stop blocking (queue).
Follow-ups to expect
- How slow is slow? There is no absolute number. The alert sits at the caller’s timeout for that dependency: latency that starts eating the timeout is the signal.
- Slow versus down? Different failure modes, same isolation kit: the breaker handles both, what the user is shown differs, and retry is wrong for one of them and catastrophic for the other.
- What if the slow service is a database? Same discipline, plus moving the lag-tolerant reads off the primary before considering bigger hardware.
Red flags in an answer
- Only per-service CPU and latency dashboards, no per-dependency view at the call site.
- Retries against a slow dependency.
- One shared connection pool for every dependency.
- Slowness discovered by users before monitors.
Sources
- How it Works, Netflix Hystrix wiki: latency isolation per dependency through separate thread pools, the bulkhead argument from the system that popularized it. The wiki is in maintenance mode, which is itself a data point: the kit outlived the specific library.
- The Tail at Scale, Dean and Barroso, CACM 2013: one slow shard sets the latency of the whole fan-out, and the caller absorbs what nobody isolates. The hedging discussion is also the counterpoint to retries: you work around slowness, you never retry into it.
- Addressing Cascading Failures, Google SRE Book, chapter 22: the capacity absorption half of the axis.