Skip to content
BIASED
Back to topic

Optional

One artifact through stages

Promote an immutable image digest staging→canary→prod; forbid rebuild on promote.

Version
v1
Minutes
~20
Evidence
Self-check in the notebook

Until platform auto-check exists, compare cell output with the expected numbers in the notebook. This is not a debt and does not affect mastery.

Download .ipynb

Download the notebook and run it locally. Its environment requirements are listed inside.

Notebook contents

Readable on your phone. The code below has not been executed in the browser; download the notebook to run it.

DevOps · Canary sample math / математика canary

Activity version: 1 · Seed: n/a · Данные: digest промоут staging→canary→prod; мощность выборки.

Один immutable digest; rebuild на промоуте запрещён. Canary на доле pp при RPS λ\lambda: запросов за tt минут =p⋅λ⋅60t= p\cdot\lambda\cdot 60 t.

Ожидаемые числа
Quantity Value Tolerance
stages 3 exact
same digest across stages True exact
requests in 5 min at 5% of 200 RPS 3000 exact
SE of rate at n=3000n=3000, p=0.01p=0.01 p(1−p)/n\sqrt{p(1-p)/n} 10−1210^{-12}
Самопроверка в ноутбуке

Не влияет на mastery.

import numpy as np
 
digest = "sha256:" + "a" * 64
stages = ["staging", "canary", "prod"]
promoted = {s: digest for s in stages}
assert len(stages) == 3
assert len(set(promoted.values())) == 1
 
# Forbid rebuild: a "rebuild" would change digest — detect mismatch.
rebuilt = digest[:-1] + "b"
assert rebuilt != digest
 
p_canary = 0.05
rps = 200
minutes = 5
n = int(p_canary * rps * 60 * minutes)
assert n == 3000
 
base_err = 0.01
se = np.sqrt(base_err * (1 - base_err) / n)
# Rough: 2-SE band around 1% ≈ ±0.0036 — a +1pp regression (to 2%) is ~2.8 SE away.
z = (0.02 - base_err) / se
 
print("n", n, "se", se, "z_for_+1pp", z)
assert abs(se - np.sqrt(0.01 * 0.99 / 3000)) < 1e-12
assert z > 2.5
print("OK: canary promote math")
 
Самопроверка в ноутбуке
  • один digest на staging/canary/prod
  • n=3000n=3000 за 5 мин при 5% × 200 RPS