Terminology (6)Terms used in this lesson
Term on the front, definition on the back. Paste with tabs between fields and a new line between cards, or import the download in Anki as Basic.
- Percentage
- A proportion written per hundred: 3 errors in 200 requests is 1.5%.
- Denominator
- The whole a percentage is a share of. Here, all requests in the window, not only the successful ones.
- Window
- The set of events a rate is computed over, such as the requests one canary served in ten minutes.
- Percentage point Also pp
- The unit of a difference between two percentages: from 1.5% to 3% is +1.5 pp.
- Relative change
- A difference divided by the earlier value, written as a percentage: from 1.5% to 3% is +100%. Undefined when the earlier value is zero.
- Baseline
- The earlier or control window a change is measured from.
Why this matters
Rollout gates, cache dashboards and growth reports all compare percentages. “Errors up 1.5%” and “errors up 100%” can describe the same canary, and a policy written in one unit will make the wrong call if fed the other. Counting errors without their requests can make a smaller window look healthier than it is.
This lesson assumes the earlier rates lesson: a count only means something over its window. The counts here are supplied; how requests are classified as errors upstream is outside the calculation.
Three quantities behind a percentage comparison
A percentage expresses a part as a share of a specified whole, multiplied by 100. The whole is its denominator. For an error percentage, that whole is all requests in the window, including successes and errors. An empty window has a zero denominator and no rate.
Percentage points measure the difference between two percentages. Relative percentage change compares that difference with the starting percentage, then multiplies by 100. Relative change requires a nonzero starting rate. A policy must state which change it limits.
01Define the quantities
Two windows of requests
The baseline errored on 1.5% of requests and the canary on 3%. One dashboard says +1.5%, another says +100%, and a third compares 210 errors with 120. Before a rollout gate acts, decide which denominator each number divides by.
A service sends a small share of traffic to a canary build. The gate compares the canary’s errors with a baseline window of the current build.
| Window | Errored | Succeeded | Requests |
|---|---|---|---|
| Baseline | 120 | 7,880 | 8,000 |
| Canary | 210 | 6,790 | 7,000 |
02Name the denominator
A rate divides by the whole window
Errors divided by successes is a ratio of two parts, sometimes called odds. It is close to the rate when errors are rare and far from it when they are common: 1 error and 3 successes is a 25% rate but a ratio of 33%. An empty window has no rate at all; 0 of 0 is not 0%.
Counts are integers, and integer division is where the languages part ways. Predict this one.
const errors = 1;
const total = 6;
console.log((errors * 100) / total);
03Two kinds of change
Percentage points and relative change
type Window = { errors: number; successes: number };
const before: Window = { errors: 120, successes: 7880 };
const after: Window = { errors: 210, successes: 6790 };
const rate = (w: Window) => (100 * w.errors) / (w.errors + w.successes); // %
const r0 = rate(before);
const r1 = rate(after);
console.log(`before ${r0}%`);
console.log(`after ${r1}%`);
console.log(`change ${r1 - r0} pp`);
console.log(`relative ${(100 * (r1 - r0)) / r0}%`);
Each version prints the two rates, the 1.5-point change and the 100% relative change. Both statements are true; they answer different questions. Points say how much of the traffic moved. Relative change says how large the move was compared with where it started, so the same 1.5 points would be a 10% rise from a 15% baseline.
04Apply the policy’s unit
Compare a limit with the change it names
A rollout policy states its unit. “Halt if the error rate rises more than 1 percentage point” limits Δ; “halt if it rises more than 120% relative to the baseline” limits the relative change. Equality does not halt: the policy says more than.
05When a change has no value
When a change has no value
A new error path can appear from nothing: 0 errors in 4,000 baseline requests, then 6 in 3,000 canary requests. The point change is +0.2 pp. The relative change would divide 0.2 by 0, which has no value. A relative policy cannot decide this case, and treating the missing value as 0% would let the rollout continue silently. A points policy can decide.
An empty window is worse: with no requests there is no rate, so neither change exists and any policy must report that it cannot decide. Say unknown, not 0%.
06Vary inputs, then decide
Vary one input at a time, then decide
| Canary rate | Change (pp) | Relative | Halt above 1 pp? | Halt above 120%? |
|---|---|---|---|---|
| 3% (210 of 7,000) | +1.5 | +100% | halt | continue |
| 3.5% (245 of 7,000) | +2 | +133.3% | halt | halt |
| 2.5% (175 of 7,000) | +1 | +66.7% | continue (equal) | continue |
| 1% (70 of 7,000) | −0.5 | −33.3% | continue | continue |
07Gate the canary
Build one rollout gate
Start with one window’s rate, then the change between two windows, then the policy decision. Each level keeps the earlier working helpers, and the complete program, its types and its reader are visible.
A canary rollout
Rate a window, measure the change, then apply the policy.
In the frontend Formatting changes in Next.js and Svelte Optional
Intl.NumberFormat with style: "percent" multiplies its input by
100, so pass a fraction such as 0.015, not 1.5. By default it shows no fractional digits,
so 1.5% would display as 2%. A change in percentage points is not a percentage of anything:
format it as a plain number and label it pp.
The Next.js component and the Svelte component share the same formatters and arithmetic.
Svelte recomputes the change with $derived; React recomputes on render.
These excerpts receive known rates from nonempty windows. The caller must show a
missing-rate state for an empty window, rather than passing zero.
const percent = new Intl.NumberFormat("en", {
style: "percent",
maximumFractionDigits: 1
});
const points = new Intl.NumberFormat("en", {
maximumFractionDigits: 1,
signDisplay: "exceptZero"
});
// Rates are fractions: 0.015 is 1.5%.
type Props = { before: number; after: number };
export function ErrorRateDelta({ before, after }: Props) {
const change = (after - before) * 100; // percentage points
const relative = before === 0 ? null : (after - before) / before;
return (
<p>
{percent.format(after)} errors, {points.format(change)} pp
{relative === null
? ", relative change undefined (zero baseline)"
: `, ${percent.format(relative)} relative`}
</p>
);
}
Check this idea later
Sources
- NIST SP 811: percent and quantity values
- Go: integer division truncates
- Rust: integer division
- C++: multiplicative operators
- ECMA-402: percent formatting
The request counts and policies are a worked model, not measured traffic.
Sign in to keep your read marks on every device. Sign in
Was this helpful?