Skip to content

Gray failures: slow is not dead

Most designs assume that a component is either working or stopped. A stopped component is easy: connections are refused, a health check fails, a load balancer routes around it. The paper that named gray failure argues that the major availability breakdowns and performance anomalies of cloud systems tend to come from subtler faults than that. A component is degraded, slow, dropping some packets, or failing for some callers, and it is still up.

The paper defines it with two viewpoints. The system has an observer, such as a health check or a failure detector, and the applications that use it make their own observations, such as query latency. The system has a gray failure when at least one application sees it as unhealthy while the observer sees it as healthy. The authors call this differential observability, and it is why gray failures are hard: the part of the system that should react has no reason to. A crash is a case where both agree.

Mental model. A dead component announces itself by refusing. A gray one answers, late or wrongly, so everything that depends on it waits. The failure is not in the component alone: it is in the gap between what its checks measure and what its callers experience.

The database is healthy: its queries take 8 ms, and about a quarter of the requests need it. Press Slow dependency (not dead) and it becomes ten times slower, but it still answers. The API waits up to 300 ms for it and retries once.

Slow dependency (not dead)

The database is healthy, with its queries taking 8 ms and about a quarter of the requests needing it. You make it ten times slower: it still answers, only slowly, as it might under a heavy query, a lock or a failing disk. The API waits up to 300 ms for it and retries once. Watch what a dependency that is slow, but not dead, does to the system around it. Then compare with Kill the database.

The failure lab needs JavaScript. The healthy system is shown below.

1. Break it

The healthy system is shown first. When you press the button the failure strikes, and the run follows the 30 seconds after it.

What the failure does: The database still answers, but every query takes ten times as long.

0.3 ms0.2 ms0.5 ms0.5 msClientsHealthy<1%Load balancerHealthy<1%APIBusy75%CacheHealthy1%DatabaseHealthy20%
0.3 ms0.2 ms0.5 ms0.5 msClientsHealthy<1%Load balancerHealthy<1%APIBusy75%CacheHealthy1%DatabaseHealthy20%

Each dot stands for many requests. The numbers show the real rate.

No bottleneck: every component has headroom.

0 ms

Cause and effect

Each step leads to the next. A step that is changing right now is marked.

Metrics
ComponentStateUtilisationOffered (req/s)Served (req/s)Rejected (req/s)p50p95p99
ClientsHealthy<1%90090000 ms0 ms0 ms
Load balancerHealthy<1%90090000.03 ms0.15 ms0.23 ms
APIBusy75%900900014 ms60 ms93 ms
CacheHealthy1%81081000.14 ms0.6 ms0.92 ms
DatabaseHealthy20%25225205.5 ms24 ms37 ms
Traffic
900 req/s
Successful
900 req/s
Error rate
0%
Mean latency
24 ms

Illustrative values, not benchmarks of any real product.

Model notes

Assumptions

  • Requests arrive at random, as a Poisson process, at a constant average rate.
  • Each node is one queue, served first-come first-served by several identical slots (instances × concurrency).
  • Service times are random with the stated mean; by default they are exponentially distributed.
  • Each node is analysed separately, with the traffic it receives treated as Poisson.
  • The system starts healthy at 900 requests a second. Three API instances can serve 1,200 a second and the database about 1,250 operations a second. Nine in ten requests read through the cache, which answers four in five of those reads; the rest, and every write, go to the database.
  • A failure strikes at one instant and nothing repairs it during the run: no restart, no autoscaling, no operator. The load balancer notices a dead instance at once.
  • The instances of a component are identical, and each request is independent of the others.

Simplifications

  • Every query takes ten times as long, evenly. Real slowness often hits a few queries, because of a lock or a missing index, and spares the rest.
  • While it waits for the database, a real API instance would hold a worker, so a slow dependency would exhaust the API tier too. Here it does not (see the engine’s notes), so the damage to the API is understated.
  • A retry is a fresh, independent attempt with the same chance of failing as the last one. How long a real client library waits between attempts (backoff, jitter), and any retry budget or circuit breaker, are not simulated: attempts are counted, not scheduled.
  • A client gives up when its first timeout runs out, so the latency shown stops at what a client would wait: the timeout of the first hop, times its attempts. After that the request counts as a failure.
  • The cache's hit ratio is constant. Warming, stampedes and hot keys have their own labs.
  • Nothing here models garbage collection, connection pools on the client, DNS, TLS handshakes, CPU throttling, noisy neighbours or cold caches. A real system fails in more ways, and in messier ones, than this model does.
  • Above capacity there is no steady state. The model switches to a fluid approximation: the node serves at capacity, its queue grows until it reaches its limit, and further requests are rejected.
  • Percentiles assume an exponential tail. A service-time variability other than exponential changes the mean wait but not the shape of the tail.
  • A node frees its slot as soon as it has done its own work, before waiting on the services it calls. Real thread-per-request servers hold the slot, so a slow dependency exhausts them faster than this model shows.
  • A request calls its dependencies one after another. Parallel fan-out is not modelled.
  • When a caller times out and gives up, the callee still finishes the work, so abandoned requests keep consuming capacity.
  • Retries add load. Their backoff and jitter decide when that load arrives, which only the per-request simulation shows.
  • A caller’s timeout counts the mean time its dependencies take, not their full distribution.
  • Latency percentiles for a whole request are estimated, over every request, including those that are rejected and fail quickly. The mean is exact, and the percentiles come from a gamma distribution that has that mean and the variance of the time spent in each component.

Parameter values are illustrative. They are not benchmarks of any real product.

The first run has the same failure count as the dead database of the last lesson, 24% on average. Everything else is worse.

  • The database serves 10 ÷ 0.080, which is 125 queries a second, and about 250 are asked of it. That is two times its capacity, and with each query retried once, about 500 are asked, four times. The utilisation of the database goes from 75% to 403%.
  • The worst p99 is 1 s, against 92 ms when the database was dead. A dead database refuses at once, so the requests that fail do so quickly. A slow one keeps every caller waiting for the full timeout, and the calls to it multiply by ×2.
  • The queue at the database is full, with 100 requests waiting, and the failures become critical after 2.25 s.

So with the same share of requests failing, the damage is not the same. A dead dependency refuses and releases its callers. A slow one holds them, and that costs something the lab does not show.

In this engine an API instance gives up its worker while it waits for a callee. The requests that the cache can answer carry on, and the API tier is never exhausted. A real service often keeps a thread or a connection busy while it waits. The Little’s Law lesson gives the arithmetic: the work in progress is the rate times the time each request stays. About 252 queries a second go to the database, and each waits up to 300 ms for it. That is 252 × 0.3, about 76 requests in progress at the same time. The three API instances have 24 workers between them. If those workers were held, the API would not have enough workers for them, and the requests that never touch the database, the cache hits, would be stuck behind the ones that do.

That is the damage the notes of the lab call understated. A slow dependency can take the whole service down, where a dead one only takes down the paths that go through it. The lab shows you the first half of that cascade, a saturated database and doubled load, and leaves out the second.

Choose changes and run the same failure again. As ever, the fixes apply from the start of the run.

Change Requests that fail Busiest component Worst p99
None 24% 403% 1 s
Stop retrying the database 24% 202% 1 s
Shed load at the database: drop queries that waited too long 13% 350% 340 ms
Cache more of the reads 12% 209% 1 s
Give the database three times the connections 0% 75% 279 ms
Shed at the database and cache more 1.5% 141% 340 ms

Each fix protects something different. Without retries the database is asked once and its load is halved, but the failures are the same, because a database that is too slow is not helped by a second call. A deadline at the database refuses the queries that cannot be served soon, so the callers get a quick answer instead of a long wait, and the worst p99 falls to 340 ms. Caching more asks the database for less. More connections add capacity: at ten times the time, thirty connections serve 30 ÷ 0.080, which is 375 a second, above the 250 asked, and nothing fails. The last row shows that two partial fixes can add up.

The cost of the capacity fix is the interesting one. It was sized for a slowness nobody predicted, and if the slowness has a cause that capacity does not touch, such as a lock or a bad query, it only buys time.

The second lab removes the database from the picture and slows the network. The load balancer gives up on an API instance after 400 ms and retries once. The healthy system answers in 96 ms, so 400 ms looks generous. Press Introduce 500 ms latency, which adds 500 ms to the link between the load balancer and the API.

Introduce 500 ms latency

In this lab the load balancer gives up on an API instance after 400 ms, and retries once. The healthy system answers in about 100 ms, so 400 ms looks generous. You add 500 ms of latency to the network between the load balancer and the API tier. No component fails and none is slower. Watch what the timeout and the retry make of it.

The failure lab needs JavaScript. The healthy system is shown below.

1. Break it

The healthy system is shown first. When you press the button the failure strikes, and the run follows the 30 seconds after it.

What the failure does: The network between the load balancer and the API tier becomes 500 ms slower.

0.3 ms0.2 ms0.5 ms0.5 msClientsHealthy<1%Load balancerHealthy<1%APIBusy75%CacheHealthy1%DatabaseHealthy20%
0.3 ms0.2 ms0.5 ms0.5 msClientsHealthy<1%Load balancerHealthy<1%APIBusy75%CacheHealthy1%DatabaseHealthy20%

Each dot stands for many requests. The numbers show the real rate.

No bottleneck: every component has headroom.

0 ms

Cause and effect

Each step leads to the next. A step that is changing right now is marked.

Metrics
ComponentStateUtilisationOffered (req/s)Served (req/s)Rejected (req/s)p50p95p99
ClientsHealthy<1%90090000 ms0 ms0 ms
Load balancerHealthy<1%90090000.03 ms0.15 ms0.23 ms
APIBusy75%900900014 ms60 ms93 ms
CacheHealthy1%81081000.14 ms0.6 ms0.92 ms
DatabaseHealthy20%25225205.5 ms24 ms37 ms
Traffic
900 req/s
Successful
900 req/s
Error rate
0%
Mean latency
24 ms

Illustrative values, not benchmarks of any real product.

Model notes

Assumptions

  • Requests arrive at random, as a Poisson process, at a constant average rate.
  • Each node is one queue, served first-come first-served by several identical slots (instances × concurrency).
  • Service times are random with the stated mean; by default they are exponentially distributed.
  • Each node is analysed separately, with the traffic it receives treated as Poisson.
  • The system starts healthy at 900 requests a second. Three API instances can serve 1,200 a second and the database about 1,250 operations a second. Nine in ten requests read through the cache, which answers four in five of those reads; the rest, and every write, go to the database.
  • A failure strikes at one instant and nothing repairs it during the run: no restart, no autoscaling, no operator. The load balancer notices a dead instance at once.
  • The instances of a component are identical, and each request is independent of the others.

Simplifications

  • The delay is a constant 500 ms on every request that crosses the link. Real latency varies from request to request, and it often comes with lost packets.
  • While it waits for the slow link, a real API instance would hold a worker. Here it does not, which makes the model kinder than reality (see the engine’s notes).
  • A retry is a fresh, independent attempt with the same chance of failing as the last one. How long a real client library waits between attempts (backoff, jitter), and any retry budget or circuit breaker, are not simulated: attempts are counted, not scheduled.
  • A client gives up when its first timeout runs out, so the latency shown stops at what a client would wait: the timeout of the first hop, times its attempts. After that the request counts as a failure.
  • The cache's hit ratio is constant. Warming, stampedes and hot keys have their own labs.
  • Nothing here models garbage collection, connection pools on the client, DNS, TLS handshakes, CPU throttling, noisy neighbours or cold caches. A real system fails in more ways, and in messier ones, than this model does.
  • Above capacity there is no steady state. The model switches to a fluid approximation: the node serves at capacity, its queue grows until it reaches its limit, and further requests are rejected.
  • Percentiles assume an exponential tail. A service-time variability other than exponential changes the mean wait but not the shape of the tail.
  • A node frees its slot as soon as it has done its own work, before waiting on the services it calls. Real thread-per-request servers hold the slot, so a slow dependency exhausts them faster than this model shows.
  • A request calls its dependencies one after another. Parallel fan-out is not modelled.
  • When a caller times out and gives up, the callee still finishes the work, so abandoned requests keep consuming capacity.
  • Retries add load. Their backoff and jitter decide when that load arrives, which only the per-request simulation shows.
  • A caller’s timeout counts the mean time its dependencies take, not their full distribution.
  • Latency percentiles for a whole request are estimated, over every request, including those that are rejected and fail quickly. The mean is exact, and the percentiles come from a gamma distribution that has that mean and the variance of the time spent in each component.

Parameter values are illustrative. They are not benchmarks of any real product.

No component fails and none is slower. Yet 96% of the requests fail on average. The extra 500 ms is longer than the 400 ms the load balancer waits, so every request times out although the API answers each one correctly. The load balancer retries, the attempts go from ×1 to ×2, and the API has to do 1,800 requests a second of work for answers nobody reads. Its utilisation goes from 75% to 150%.

Try the fixes. Wait longer: raise the timeout to 1 s takes the failures to 0%, with a worst p99 of 573 ms: a slow answer is still an answer. Stop retrying brings the API back to 75%, and 96% still fail, because every attempt still times out. Double the API tier leaves 96% failing, at the doubled bill. Only the timeout was wrong, and only changing it fixed the failures. The price is that a real failure now takes a full second to notice, and 500 ms of extra latency is treated as normal.

What happens if the health check says healthy?

Section titled “What happens if the health check says healthy?”

In both labs a check that asks whether the database or the instance is up would pass. It would pass for a database that takes 80 ms for a query that used to take 8, and for an instance behind a slow link. The paper’s remedy is to close the observation gap: from a single failure detector, such as a heartbeat, to multi-dimensional monitoring of the signals applications see, like latency and errors. The authors also warn that probing too actively can burden a system that is already degraded. A health check that measures what the callers feel is the aim, and the health checks lesson covers the mechanics of what a balancer does with the result.

Test your sense of the three kinds of failure:

Challenge

Dead, slow or overloaded?

A component can stop, keep answering badly, or simply be asked for more than it can do. Each calls for a different response. Put each situation under the kind of failure it is.

Sorting needs JavaScript.

Categories

Stopped (fail-stop)
It refuses or does not answer, and a health check notices.
Slow or partial (gray)
It is up and answering, late or only for some callers, and its own checks pass.
Overloaded
Nothing is broken: more work arrives than the component can do.
  1. Line 1 of 7The API process crashed, and connections to it are refused at once.
  2. Line 2 of 7A disk is failing: reads still succeed but take ten times longer, and the health check, which only opens a connection, passes.
  3. Line 3 of 7A campaign sends ten times the usual traffic. Every component works as designed, and the queues fill.
  4. Line 4 of 7A link drops 2% of the packets. Most requests succeed, a few time out and are retried.
  5. Line 5 of 7A server loses power. Three health checks in a row fail and it leaves the pool.
  6. Line 6 of 7One of three instances dies, and the two that remain receive more than they can serve.
  7. Line 7 of 7A long lock slows only the queries that touch some rows. Other queries on the same database are fast.

Check your answers at least once before looking at the answers.

  • A gray failure is differential observability: at least one application sees the system as unhealthy while the system’s own observer sees it as healthy. A health check that asks only whether a component is up passes.
  • A database ten times slower serves 125 queries a second against 250 asked, and 500 with the retries: 403% utilisation. As many requests fail as with a dead database, 24%, but the worst p99 is 1 s instead of 92 ms.
  • The lab understates the damage: 252 × 0.3 is about 76 requests in progress against 24 workers, and a service that held its workers would be exhausted.
  • Fixes: capacity (three times the connections takes the failures to 0%), a deadline at the database (13%, 340 ms), a bigger cache (12%) and no retries (24%, half the load). Two partial fixes together reach 1.5%.
  • A timeout of 400 ms below a 500 ms delay fails 96% of requests with nothing broken, and the retry doubles the load. Raising the timeout to 1 s is the only fix that works.
  • The remedy is to measure what callers feel, not only whether a component answers.

Next: disaster recovery, RPO and RTO.

Your progress

Built by GhaziAlibi.

© ShardCraft. All rights reserved.