skip to content

reliability engineering for a collection product · lesson 3 of 6 · sources checked 2026-11-30

bulkheads, hedges, and graceful degradation

This lesson shows which internal reliability patterns help a collector, and which patterns add load on a target or heat on a pool.

purpose

A web service can use each reliability pattern against its own servers at no cost to others. A collector uses some of the same patterns against a site that is not its own. You must know which pattern protects your product and which pattern moves the cost to the target or to the proxy pool.

objectives

  1. Set a bulkhead for each supplier and each target class.
  2. Compute the added load of a hedged request from its delay.
  3. Write the rule for when not to hedge.
  4. Describe a degraded mode and the data grade of its records.
  5. Decide for each pattern if it helps the product or harms the target.

new terms

bulkhead
A separate pool of slots for one supplier or one target class, so that one fault cannot hold all slots.
hedged request
A second copy of a request that a client sends when the first is slow.

how it works

Each pattern of this page acts on a fault inside your own system: a slow supplier, a slow store, or a worker that stops. Each pattern has a gain for the product. Some patterns also add load on the target or heat on the pool.

bulkheads

A bulkhead is a separate pool of slots for one supplier or one target class. One slow supplier can then hold only its own slots.

For example, a collector has 8 slots. Provider 1 gets 3 slots for shop targets and 2 for news targets, and provider 2 gets 3 slots for shop targets. Provider 1 becomes slow on shop targets, and its 3 slots stay busy. The next shop job for provider 1 gets a fast refusal. The other jobs go on.

A cell is the same idea at a larger size: a full copy of the system for one group of targets. A fault in one cell does not stop the other cells.

hedged requests

A hedged request is a second copy of a request that a client sends when the first copy is slow. The client uses the first answer that comes back. A hedge shortens the tail of the latency.

The added load depends on the delay before the second copy. A hedge goes out only for the requests that are slower than the delay. For example, with a delay at the 95th percentile of the latency, at most 5% of the requests get a second copy. With a delay near the median, about half of the requests get one.

a hedge is load

status of this section: from a public source

claim of a company An article of one cloud company states that when an overload causes the failures, retries that add load can make the failure worse Amazon Builders' Library, source 1.

In my model, a hedge is a second copy of a request, thus it is load of the same kind. A slow answer can come from a receiver that is near its limit. Then a hedge with a short delay adds load at the worst time.

when not to hedge

I hedge only to my own services, for example the store or an internal API. The rule against a hedge has three parts:

  1. No hedge to a third-party target. Each copy is a second request at a site that is not yours. Through the proxy pool, it adds pool heat.
  2. No hedge after a refusal or a block. The outputs after a refusal are a slower pace, a volume cap, the declared path, or a stop.
  3. No hedge through a second exit or a second identity.

A cap on the hedges for each client also protects your own service from the added load. The hedge guard and the cap thus protect the site and the service.

degraded mode

A degraded mode uses a cheaper method when the normal method fails inside your own system. Each record of that mode carries a lower data grade. For example, the store of fresh results is slow, and the product serves the last stored copy with the grade "stored copy".

A degraded mode is for a fault of your own system. It is not an answer to a block of a site. A cheaper method can also show a different pattern to the target.

The output of the work is a decision for your own system. It names the patterns that the system uses and gives the reason for each choice.

the two sides

automation sidedetection side
A bulkhead keeps one slow supplier from a hold on the full fleet. A degraded mode keeps the product alive with a stated grade.A hedge gives the target two near-identical requests in a short window. A cheaper method can show a different pattern, and the defender sees a change of population.

design decisions

optiongaincostwhen it is correct
One shared pool of slotsAll slots serve each job.One slow supplier can hold all slots.Only with one supplier and one target class
A bulkhead for each supplier and target classOne slow supplier holds only its own slots.Some slots stay free while another pool is full.As the default
A hedge with a short delayThe shortest tail latencyThe added load can double, and the receiver can saturate.Never against a receiver near its limit
A hedge with a delay at a high percentileA shorter tail for a small added loadThe slowest requests still wait for the delay.Only to your own services
No hedgeNo added loadA slow tail of latencyFor each third-party target
A degraded mode with a data gradeThe product stays up.The records have a lower grade, and the method can look different.For a fault of your own system, with the grade on each record

diagram

A matrix of five patterns against three columns: the product, the target, and the pool. The bulkhead and the cell help the product with no added load or heat. A hedge to an own service helps the product with no effect on a target. A hedge to a third-party target adds load on the target and heat on the pool. A degraded mode keeps the product up, and the target and the pool can see a different method.

each pattern against its effect on the product, the target, and the pool
patternproducttargetpool
Bulkhead for each supplier and target classOne slow supplier holds only its slotsNo added loadNo added heat
Cell for a group of targetsOne fault stays in one cellNo added loadNo added heat
Hedged request to an own serviceShorter tail latencynonenone
Hedged request to a third-party targetShorter tail latencyAdded load, up to doubleAdded heat
Degraded modeStays up with a lower data gradeCan see a different methodCan see a different method
A bulkhead and a cell keep a fault inside one part. A hedge to a third-party target moves the cost to the target and the pool.source: My model of the reliability patterns of a collector

The second diagram shows the two extra costs that a collector pays for each such pattern.

the two extra costs of each reliability action in a collector

  1. The productThe gain: the action saves a request, a record, or the time of a customer.pass
  2. Load on the targetEach extra request reaches a site that is not yours, and counts against the limit of that host.fail
  3. Heat on the poolEach extra request through the proxy pool can raise the risk score of the pool.fail

An action is correct only when the gain is larger than the two extra costsno result

A web service pays for a reliability action one time. A collector pays two more times: at the target and at the pool.source: My model of the costs of a reliability action in a collector

code example

The example gives a bulkhead for each supplier and target class, and a hedge guard. The suppliers are "provider 1" and "provider 2", and the target classes are synthetic.

m56-x04-bulkhead.tstypescript

A bulkhead for each supplier and target class, and a hedge guard that refuses a hedge to a third-party target.

// A bulkhead for each supplier and target class, and a hedge guard.
// The names are synthetic. No request leaves the process.
type Key = string; // "<supplier>/<target class>"

class Bulkhead {
  private used = new Map<Key, number>();
  private limits: Record<Key, number>;
  constructor(limits: Record<Key, number>) {
    this.limits = limits;
  }
  acquire(key: Key): boolean {
    const limit = this.limits[key] ?? 0;
    const now = this.used.get(key) ?? 0;
    if (now >= limit) return false; // this pool is full; the other pools go on
    this.used.set(key, now + 1);
    return true;
  }
}

type Call = { kind: "own-service" | "third-party-target"; lastAnswer: "ok" | "slow" | "refused" };

// A hedge is a second copy of a slow request. It is load on the receiver.
function hedgeVerdict(call: Call, waitedMs: number, p95Ms: number, hedgesLeft: number): string {
  if (call.kind === "third-party-target") return "no hedge: third-party target";
  if (call.lastAnswer === "refused") return "no hedge: refusal";
  if (waitedMs < p95Ms) return "no hedge: not slow yet";
  if (hedgesLeft <= 0) return "no hedge: hedge budget used";
  return "hedge";
}

const pools = new Bulkhead({ "provider-1/shop": 3, "provider-2/shop": 3, "provider-1/news": 2 });
// provider 1 is slow: its shop slots stay busy, and new calls get no slot.
const asks: Key[] = ["provider-1/shop", "provider-1/shop", "provider-1/shop", "provider-1/shop",
  "provider-2/shop", "provider-1/news"];
for (const key of asks) console.log(`${key}: ${pools.acquire(key) ? "slot" : "no slot, refuse fast"}`);

const calls: [Call, number][] = [
  [{ kind: "own-service", lastAnswer: "slow" }, 120],
  [{ kind: "own-service", lastAnswer: "slow" }, 40],
  [{ kind: "own-service", lastAnswer: "refused" }, 120],
  [{ kind: "third-party-target", lastAnswer: "slow" }, 900],
];
for (const [call, waited] of calls) {
  console.log(`${call.kind}, waited ${waited} ms: ${hedgeVerdict(call, waited, 100, 5)}`);
}

output

One line for each slot request, and one hedge verdict for each of four calls.

provider-1/shop: slot
provider-1/shop: slot
provider-1/shop: slot
provider-1/shop: no slot, refuse fast
provider-2/shop: slot
provider-1/news: slot
own-service, waited 120 ms: hedge
own-service, waited 40 ms: no hedge: not slow yet
own-service, waited 120 ms: no hedge: refusal
third-party-target, waited 900 ms: no hedge: third-party target

The output shows that the slow pool of provider 1 refuses its fourth job, while the other pools give slots. It also shows that the guard sends a hedge only for a slow call to an own service, and never to a third-party target.

data

flow p99 latency against added load at the lab target, for three hedge delays

status of this figure: measured by me

flow p99 latency against added load at the lab target, for three hedge delays515698.75msadded load at target, % of base requests1. no hedge2. hedge after 25 ms3. hedge after 50 ms4. hedge after 100 ms

source: Lab result of this course: hedged requests to a lab target with a scripted tail; date 2026-11-13; sample of 20; condition: Lab target with 8 slots and a scripted tail, local processes, one shared host. Added load counts the extra requests that the target got, in percent of the base requests.

data table
flow p99 latency against added load at the lab target, for three hedge delays
seriesitemadded load at target (% of base requests)ms
no hedgerun 10418
no hedgerun 20520.5
no hedgerun 30342.3
no hedgerun 40373.3
no hedgerun 50338.7
hedge after 25 msrun 198.342772
hedge after 25 msrun 296.294624
hedge after 25 msrun 392.373376
hedge after 25 msrun 498.754646
hedge after 25 msrun 598.273874
hedge after 50 msrun 129.99972.6
hedge after 50 msrun 297.355156
hedge after 50 msrun 34.464214.5
hedge after 50 msrun 446.432647
hedge after 50 msrun 53.3173.4
hedge after 100 msrun 13.413294.4
hedge after 100 msrun 22.936268
hedge after 100 msrun 32.76278.9
hedge after 100 msrun 43.779319.7
hedge after 100 msrun 52.805222.2
Each point is one run at 40 flows/s. A hedge sends a second copy of a slow request. A delay of 25 ms doubles the load and the target saturates.

The chart is a lab result of this course, from a lab target with a scripted tail. It shows the mechanism of this page: a short delay sends a hedge for most requests, and the target saturates. A long delay adds a small load and still shortens the tail.

failure modes

problemcausecorrection
One slow supplier stops all jobs.All suppliers share one pool of slots.Set a bulkhead for each supplier and each target class.
The tail latency gets worse after a hedge goes in.The delay is short, so the hedges double the load and the receiver saturates.Set the delay at a high percentile of the latency, and cap the hedges.
A target gets two near-identical requests in a short window.The client hedges to a third-party target.Hedge only to your own services.
The pool gets heat after a refusal of a site.The client sends a second copy after the refusal.Send no copy after a refusal. Slow down, cap the volume, use the declared path, or stop.
A customer cannot see the difference between a stored copy and a fresh result.The degraded mode writes no data grade.Write the data grade on each record of the degraded mode.

check questions

  1. All suppliers share one pool of slots, and provider 1 becomes slow. What occurs?

    1. Only the jobs of provider 1 wait.
    2. The slow jobs of provider 1 can hold all slots, and the jobs of provider 2 also wait.
    3. The pool adds slots for provider 2.
    answer

    b. The slow jobs of provider 1 can hold all slots, and the jobs of provider 2 also wait.

    With one shared pool, the slow jobs of one supplier can hold all slots. A bulkhead for each supplier keeps the slow jobs in their own slots.

  2. A client sends a hedge after a delay at the 95th percentile of the latency. What share of the requests gets a second copy, at most?

    1. About half
    2. All
    3. 5%
    answer

    c. 5%

    A hedge goes out only for the requests that are slower than the delay. At the 95th percentile, that is at most 5% of the requests.

  3. Which call can get a hedged request?

    1. A slow call to the own result store
    2. A slow call to a third-party target
    3. A call that a site refused
    answer

    a. A slow call to the own result store

    A hedge goes only to an own service. A third-party target gets no hedge, and a refusal gets no second copy.

  4. Describe a degraded mode for a slow result store, and the data grade of its records.

    sample answer

    While the store is slow, the product serves the last stored copy. Each record of that mode carries a lower data grade, for example "stored copy".

  5. Which pattern adds load on a third-party target?

    1. A bulkhead for each supplier
    2. A cell for a group of targets
    3. A hedged request to that target
    answer

    c. A hedged request to that target

    Each copy of a hedged request is a second request at the target. A bulkhead and a cell add no load.

exercise

exercise Do this task on paper, for the synthetic collector below. Do not send a request to a site.

  • Suppliers: provider 1 and provider 2.
  • Target classes: shop targets and news targets.
  • Own services: a result store and an internal API.
  • Latency of the result store: median 20 ms, 95th percentile 80 ms.
  • A fault of your own system: the result store is slow for 10 minutes.
  1. Write the bulkheads that the collector uses.
  2. Write the hedge rule for the result store, with its delay.
  3. Write the added load of that hedge, at most.
  4. Write the hedge rule for the shop targets and the news targets.
  5. Write the degraded mode for the slow result store, with its data grade.
sample answer

The answer uses the synthetic collector of the task.

The collector uses four bulkheads: one pool of slots for each pair of a supplier and a target class. A slow provider 1 then holds only its own slots.

The result store is an own service. A hedge to it waits 80 ms, the 95th percentile. Thus at most 5% of the requests get a second copy, and the hedges have a cap for each client.

The shop targets and the news targets are third-party targets. They get no hedge, and no copy after a refusal.

While the store is slow, the product serves the last stored copy. Each record carries the grade "stored copy".

sources

  1. Timeouts, retries, and backoff with jitter, Amazon Builders' Library, article, read 2026-11-22
  2. My model of the reliability patterns of a collector and of the rule against a hedge to a third-party target, 2026-11 (not public).