skip to content

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

retry budgets and the retry multiplier

This lesson shows how retries at many levels multiply the load on one target host, and how one retry level and a budget stop it.

status of this lesson: from a public source

purpose

A fault at a target can turn one request into many tries at that target. Each try is load on a site that is not yours, and each try through a proxy pool can add pool heat. You must know the count of tries before a fault comes, not after it.

objectives

  1. List each level of your own system that retries.
  2. Compute the retry multiplier of one request on one target host.
  3. Set a cap for each request and a ratio of retries for each client.
  4. Explain why a retry budget also protects the target.

new terms

how it works

A collector has many levels that can retry. Examples are the API, the queue, the worker, the browser driver, and the proxy gateway. Each level can have its own retry rule. A level that does not know the rules of the other levels retries the same failure again.

the retry multiplier

The retry multiplier is the product of the tries at each level that retries. For example, the API, the queue, the worker, and the proxy gateway each make 3 tries, and the browser driver makes 1 try. One request then gives 3 x 3 x 3 x 1 x 3 = 81 tries at one target host in a total fault.

To find the multiplier, write a retry map. The map has one row for each level and the count of tries at that level. The first diagram shows such a map.

retry at one level

claim of a company An article of one cloud company gives a call chain of five levels in which each level retries. It states that the load on the database then rises 243 times. It states that its best practice is to retry at a single point in the call chain Amazon Builders' Library, source 1.

I keep the retries at one level: the worker. The other levels send a failure up and do not retry. For example, the map of the first case then gives 1 x 1 x 3 x 1 x 1 = 3 tries.

the retry budget

A retry budget has two parts: a cap for each request and a ratio for each client. The cap limits the tries of one request. The ratio limits the retries of one client to a share of its first tries.

For example, a client has a ratio of 0.1. Then 100 first tries give at most 10 retries. In a total fault, the target gets 110 tries for 100 requests, thus 1.10 tries for each request. The second code example computes this value.

claim of a company The same article describes a local token bucket as a limit on retries. All calls can retry while the bucket has tokens. When the tokens are gone, the calls retry at a fixed rate Amazon Builders' Library, source 1.

retries during an overload

claim of a company The same article also states that when an overload causes the failures, retries that add load can make the failure worse. It states that such retries can delay the recovery Amazon Builders' Library, source 1.

A retry is a tool for a transport fault or a fault of your own system. For example, a worker stops in the middle of a job.

A refusal or a block from a site is not such a fault. After a refusal, the outputs are a slower pace, a volume cap, the declared path, or a stop. A new try through a different exit is not one of these outputs.

the target is a party of the budget

The retry budget is a part of the load budget for each host. Each retry counts against the same limit as a first try. For example, a host limit of 2 requests each second holds the first tries and the retries together. Thus the retry budget also protects the site from load. The limiter for each host is in Load on the target: rate limits, crawl delay, and back-off (not yet published).

The output of the work is a retry map with the multiplier before and after the change.

the two sides

automation sidedetection side
One retry level and a ratio for each client keep a fault from a multiplication of the load on one host.The target sees each retry as a new request from the same client class. A burst of retries after an error is a clear automation pattern, and it can raise the score of the pool.

design decisions

optiongaincostwhen it is correct
Retries at each levelEach level recovers from its own short faults.The multiplier is the product of all levels. A total fault sends the largest load to the target.Never in a collector
Retries at one levelThe multiplier is the count of tries at that level.The other levels must send each failure up.As the default
A cap for each request onlyOne request cannot make an endless count of tries.A fault on all requests still multiplies the load by the cap.Only with a ratio for each client
A cap and a ratio for each clientThe retries stay a small share of the first tries.The client gives up on some requests that a retry can save.For each client that sends to a third-party target
A local token bucket for retriesShort faults get retries. A long fault gets a fixed retry rate.One more limit to set and to check.When the retry rate must have a hard top

diagram

the levels of a collector that can retry, and the multiplier on one target host

  1. APIBefore the change: 3 tries. After the change: 1 try. A failure goes back to the customer.no result
  2. QueueBefore the change: 3 deliveries. After the change: 1 delivery.no result
  3. Worker3 tries before and after the change. This is the one level that retries.pass
  4. Browser driver1 try before and after the change.no result
  5. Proxy gatewayBefore the change: 3 tries. After the change: 1 try.no result

Retry multiplier on one target host: 3 x 3 x 3 x 1 x 3 = 81 before the change, 3 after the changepass

One level that retries brings the multiplier down from 81 to 3 for the same collector.source: My model of the retry map of a collector

The second diagram shows the two extra costs of each retry, and of each other action of this module.

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 first example reads a retry map from a JSON file and computes the multiplier. The file holds synthetic levels and counts.

m56-x01-retry-map.tstypescript

Read the retry settings of each level from a JSON file and compute the retry multiplier on one target host.

// Read a retry map from a JSON file and compute the retry multiplier.
// The argument is the path of a JSON file with synthetic retry settings, for example:
// {"api": 3, "queue": 3, "worker": 3, "browser": 1, "gateway": 3}
import { readFileSync } from "node:fs";

const path = process.argv[2] ?? "retry-map.json";
const retryMap: Record<string, unknown> = JSON.parse(readFileSync(path, "utf-8"));

let product = 1;
const retrying: string[] = [];
for (const [level, tries] of Object.entries(retryMap)) {
  if (typeof tries !== "number" || !Number.isInteger(tries) || tries < 1) {
    throw new Error(`level ${level}: tries must be a whole number of 1 or more`);
  }
  console.log(`${level}: ${tries} ${tries === 1 ? "try" : "tries"}`);
  product *= tries;
  if (tries > 1) retrying.push(level);
}

console.log(`retry multiplier on one target host: ${product}`);
if (retrying.length > 1) {
  console.log(`more than one level retries: ${retrying.join(", ")}`);
}

output

The tries at each level, the multiplier on one target host, and the levels that retry, for the synthetic map of the comment.

api: 3 tries
queue: 3 tries
worker: 3 tries
browser: 1 try
gateway: 3 tries
retry multiplier on one target host: 81
more than one level retries: api, queue, worker, gateway

The output shows the multiplier of 81 and the four levels that retry.

The second example applies a retry budget to a client in a total fault. Each retry must pass three gates: the cap of the request, the ratio of the client, and the time that is left.

m56-x02-retry-budget.tstypescript

Apply a retry budget with a ratio and a cap for each client, and pass a deadline down the call chain.

// A retry budget for each client and a deadline that passes down the call chain.
// All values are synthetic. No request leaves the process.
type Budget = { ratio: number; cap: number; firsts: number; retries: number };

const newBudget = (ratio: number, cap: number): Budget => ({ ratio, cap, firsts: 0, retries: 0 });

// The retry multiplier is the product of the tries at each level that retries.
function multiplier(map: Record<string, number>): number {
  return Object.values(map).reduce((product, tries) => product * tries, 1);
}

// A retry passes three gates: the cap of the request, the ratio of the client,
// and the time that is left before the deadline.
function mayRetry(b: Budget, tries: number, msLeft: number, msPerTry: number): string {
  if (tries >= b.cap) return "stop: cap of the request";
  if (b.retries + 1 > b.ratio * b.firsts) return "stop: ratio of the client";
  if (msLeft < msPerTry) return "stop: deadline";
  return "retry";
}

// Each try fails, as in a total fault of the lab target.
function send(b: Budget, deadlineMs: number, msPerTry: number) {
  b.firsts += 1;
  let tries = 1;
  for (;;) {
    const verdict = mayRetry(b, tries, deadlineMs - tries * msPerTry, msPerTry);
    if (verdict !== "retry") return { tries, verdict };
    b.retries += 1;
    tries += 1;
  }
}

// Each hop subtracts its own time and passes the rest to the next hop.
function passDown(deadlineMs: number, hops: [string, number][]): void {
  let rest = deadlineMs;
  for (const [hop, ms] of hops) {
    rest -= ms;
    console.log(`  ${hop}: ${ms} ms used, ${rest} ms passed down`);
  }
}

const before = { api: 3, queue: 3, worker: 3, browser: 1, gateway: 3 };
const after = { api: 1, queue: 1, worker: 3, browser: 1, gateway: 1 };
console.log(`multiplier before: ${multiplier(before)}`);
console.log(`multiplier after: ${multiplier(after)}`);

const client = newBudget(0.1, 3);
let atTarget = 0;
for (let i = 0; i < 100; i++) atTarget += send(client, 10_000, 100).tries;
console.log(`100 requests in a total fault: ${atTarget} tries at the target`);
console.log(`tries for each request: ${(atTarget / 100).toFixed(2)}`);

const open = newBudget(1, 3);
open.firsts = 50;
console.log(`one request, deadline 250 ms, 100 ms for each try:`, send(open, 250, 100));
console.log("deadline 2000 ms on its way down:");
passDown(2000, [["api", 40], ["queue", 300], ["worker", 160]]);

output

The multiplier before and after the change, the tries at the target, one stop at the deadline, and the deadline at each hop.

multiplier before: 81
multiplier after: 3
100 requests in a total fault: 110 tries at the target
tries for each request: 1.10
one request, deadline 250 ms, 100 ms for each try: { tries: 2, verdict: 'stop: deadline' }
deadline 2000 ms on its way down:
  api: 40 ms used, 1960 ms passed down
  queue: 300 ms used, 1660 ms passed down
  worker: 160 ms used, 1500 ms passed down

The output shows the multiplier of 81 and of 3, and 1.10 tries for each request with a ratio of 0.1. It also shows a retry that stops because the time before the deadline is too short.

data

requests at the lab target during a total fault, for three retry designs

status of this figure: measured by me

requests at the lab target during a total fault, for three retry designs110110110client rate 100 s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s12 s13 s14 s15 s16 s17 s18 s19 s20 s21 srequests/s at target1. retries at each level2. retries at one level3. one level and a ratio

source: Lab result of this course: retries at four levels of a lab stack, local processes; date 2026-11-13; sample of 15; condition: One client sends 10 requests/s. Local processes stand in for containers. Short backoff times, one target, one shared host. Lab teaching values, not values for a real service.

data table
requests at the lab target during a total fault, for three retry designs
seriessecondrequests/s at target
retries at each level0 s11
retries at each level1 s10
retries at each level2 s12
retries at each level3 s14
retries at each level4 s10
retries at each level5 s120
retries at each level6 s256
retries at each level7 s444
retries at each level8 s650
retries at each level9 s756
retries at each level10 s812
retries at each level11 s842
retries at each level12 s58
retries at each level13 s7
retries at each level14 s11
retries at each level15 s12
retries at each level16 s10
retries at each level17 s10
retries at each level18 s7
retries at each level19 s9
retries at each level20 s0
retries at each level21 s0
retries at one level0 s11
retries at one level1 s10
retries at one level2 s12
retries at one level3 s14
retries at one level4 s10
retries at one level5 s27
retries at one level6 s27
retries at one level7 s26
retries at one level8 s30
retries at one level9 s31
retries at one level10 s31
retries at one level11 s27
retries at one level12 s10
retries at one level13 s7
retries at one level14 s11
retries at one level15 s12
retries at one level16 s10
retries at one level17 s10
retries at one level18 s7
retries at one level19 s9
retries at one level20 s0
retries at one level21 s0
one level and a ratio0 s11
one level and a ratio1 s10
one level and a ratio2 s12
one level and a ratio3 s14
one level and a ratio4 s10
one level and a ratio5 s17
one level and a ratio6 s10
one level and a ratio7 s10
one level and a ratio8 s11
one level and a ratio9 s10
one level and a ratio10 s11
one level and a ratio11 s11
one level and a ratio12 s8
one level and a ratio13 s7
one level and a ratio14 s11
one level and a ratio15 s12
one level and a ratio16 s10
one level and a ratio17 s10
one level and a ratio18 s7
one level and a ratio19 s9
one level and a ratio20 s0
one level and a ratio21 s0
Each point is the median of 5 runs. The target fails all requests from 5 s to 12 s. Retries at each level multiply the load. One level with a ratio keeps it small.

The chart is a lab result of this course, from local processes on one host.

The chart shows the mechanism of this page. During the fault, retries at each level multiply the load at the target. One retry level with a ratio keeps the load small.

failure modes

problemcausecorrection
A small set of jobs makes many more tries than jobs.Each level that retries multiplies the tries on the supplier and on the target.Retry at one level, set a cap for each request, and make the supplier a party of the retry budget.
A retry at the worker, at the browser, and at the proxy gateway multiplies the load on one host.Each level has its own retry rule.Write a retry map, and compute the multiplier for each target host.
A fault at the target becomes an overload of the target.The retries add load while the target is overloaded.Set a ratio for each client, so that the retries stay a small share of the first tries.
The pool gets heat after a block of a site.The collector retries a refusal of the site.Do not retry a refusal. Slow down, cap the volume, use the declared path, or stop.
Retries use the full limit of a host.The retries do not count against the load budget of the host.Count each retry against the same limit as a first try.

check questions

  1. List the levels of a collector that can retry.

    sample answer

    The API, the queue, the worker, the browser driver, and the proxy gateway can each retry. Each level can have its own retry rule.

  2. Three levels of a collector each make 4 tries. The other levels make 1 try. What is the retry multiplier on one target host?

    1. 12
    2. 64
    3. 7
    answer

    b. 64

    The retry multiplier is the product of the tries at each level: 4 x 4 x 4 = 64.

  3. A client has a retry ratio of 0.1 and sends 300 first tries during a total fault. What is the largest count of retries that the budget gives?

    1. 30
    2. 300
    3. 3
    answer

    a. 30

    The ratio limits the retries to a share of the first tries: 0.1 x 300 = 30.

  4. Explain why a retry budget also protects the target.

    sample answer

    Each retry is a new request at the target and counts against the same limit as a first try. A retry budget keeps the retries a small share of the first tries. Thus a fault does not multiply the load on the site.

exercise

exercise Do this task on paper, with the synthetic retry map below. Do not send a request to a site.

leveltries before the change
API2
Queue3
Worker3
Browser driver2
Proxy gateway3

The client sends 200 requests during a total fault of the target.

  1. Compute the retry multiplier on one target host before the change.
  2. Keep the retries at the worker only, and compute the multiplier after the change.
  3. Add a ratio of 0.1 for the client and a cap of 3 for each request.
  4. Compute the tries at the target for the 200 requests after step 3.
sample answer

The answer uses the synthetic retry map of the task.

Before the change, the multiplier is 2 x 3 x 3 x 2 x 3 = 108. After the change, only the worker retries, thus the multiplier is 3.

With a ratio of 0.1, 200 first tries give at most 20 retries. Thus the target gets at most 220 tries, or 1.10 tries for each request.

sources

  1. Timeouts, retries, and backoff with jitter, Amazon Builders' Library, article, read 2026-11-22
  2. My model of the retry map, the retry multiplier, and the retry budget of a collector, 2026-11 (not public).