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 sourcepurpose
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
- List each level of your own system that retries.
- Compute the retry multiplier of one request on one target host.
- Set a cap for each request and a ratio of retries for each client.
- 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 side | detection 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
| option | gain | cost | when it is correct |
|---|---|---|---|
| Retries at each level | Each 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 level | The 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 only | One 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 client | The 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 retries | Short 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
- APIBefore the change: 3 tries. After the change: 1 try. A failure goes back to the customer.no result
- QueueBefore the change: 3 deliveries. After the change: 1 delivery.no result
- Worker3 tries before and after the change. This is the one level that retries.pass
- Browser driver1 try before and after the change.no result
- 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
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
- The productThe gain: the action saves a request, a record, or the time of a customer.pass
- Load on the targetEach extra request reaches a site that is not yours, and counts against the limit of that host.fail
- 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
code example
The first example reads a retry map from a JSON file and computes the multiplier. The file holds synthetic levels and counts.
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, gatewayThe 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.
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 downThe 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
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
| series | second | requests/s at target |
|---|---|---|
| retries at each level | 0 s | 11 |
| retries at each level | 1 s | 10 |
| retries at each level | 2 s | 12 |
| retries at each level | 3 s | 14 |
| retries at each level | 4 s | 10 |
| retries at each level | 5 s | 120 |
| retries at each level | 6 s | 256 |
| retries at each level | 7 s | 444 |
| retries at each level | 8 s | 650 |
| retries at each level | 9 s | 756 |
| retries at each level | 10 s | 812 |
| retries at each level | 11 s | 842 |
| retries at each level | 12 s | 58 |
| retries at each level | 13 s | 7 |
| retries at each level | 14 s | 11 |
| retries at each level | 15 s | 12 |
| retries at each level | 16 s | 10 |
| retries at each level | 17 s | 10 |
| retries at each level | 18 s | 7 |
| retries at each level | 19 s | 9 |
| retries at each level | 20 s | 0 |
| retries at each level | 21 s | 0 |
| retries at one level | 0 s | 11 |
| retries at one level | 1 s | 10 |
| retries at one level | 2 s | 12 |
| retries at one level | 3 s | 14 |
| retries at one level | 4 s | 10 |
| retries at one level | 5 s | 27 |
| retries at one level | 6 s | 27 |
| retries at one level | 7 s | 26 |
| retries at one level | 8 s | 30 |
| retries at one level | 9 s | 31 |
| retries at one level | 10 s | 31 |
| retries at one level | 11 s | 27 |
| retries at one level | 12 s | 10 |
| retries at one level | 13 s | 7 |
| retries at one level | 14 s | 11 |
| retries at one level | 15 s | 12 |
| retries at one level | 16 s | 10 |
| retries at one level | 17 s | 10 |
| retries at one level | 18 s | 7 |
| retries at one level | 19 s | 9 |
| retries at one level | 20 s | 0 |
| retries at one level | 21 s | 0 |
| one level and a ratio | 0 s | 11 |
| one level and a ratio | 1 s | 10 |
| one level and a ratio | 2 s | 12 |
| one level and a ratio | 3 s | 14 |
| one level and a ratio | 4 s | 10 |
| one level and a ratio | 5 s | 17 |
| one level and a ratio | 6 s | 10 |
| one level and a ratio | 7 s | 10 |
| one level and a ratio | 8 s | 11 |
| one level and a ratio | 9 s | 10 |
| one level and a ratio | 10 s | 11 |
| one level and a ratio | 11 s | 11 |
| one level and a ratio | 12 s | 8 |
| one level and a ratio | 13 s | 7 |
| one level and a ratio | 14 s | 11 |
| one level and a ratio | 15 s | 12 |
| one level and a ratio | 16 s | 10 |
| one level and a ratio | 17 s | 10 |
| one level and a ratio | 18 s | 7 |
| one level and a ratio | 19 s | 9 |
| one level and a ratio | 20 s | 0 |
| one level and a ratio | 21 s | 0 |
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
| problem | cause | correction |
|---|---|---|
| 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
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.
Three levels of a collector each make 4 tries. The other levels make 1 try. What is the retry multiplier on one target host?
- 12
- 64
- 7
answer
b. 64
The retry multiplier is the product of the tries at each level: 4 x 4 x 4 = 64.
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?
- 30
- 300
- 3
answer
a. 30
The ratio limits the retries to a share of the first tries: 0.1 x 300 = 30.
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.
| level | tries before the change |
|---|---|
| API | 2 |
| Queue | 3 |
| Worker | 3 |
| Browser driver | 2 |
| Proxy gateway | 3 |
The client sends 200 requests during a total fault of the target.
- Compute the retry multiplier on one target host before the change.
- Keep the retries at the worker only, and compute the multiplier after the change.
- Add a ratio of 0.1 for the client and a cap of 3 for each request.
- 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
- Timeouts, retries, and backoff with jitter, Amazon Builders' Library, article, read 2026-11-22
- My model of the retry map, the retry multiplier, and the retry budget of a collector, 2026-11 (not public).