Part 16 / Topic 1 of 6
Staged rollout
Flipping a switch for all twelve dispatchers at once means any problem hits everyone at once — including Ravi, whose skepticism you just spent four weeks converting. Roll out in stages instead: a pilot group (one or two friendly dispatchers, feedback collected daily), then a percentage rollout, then everyone — with a feature flag so "off" is a config change, not a deploy.
The one technical subtlety: assignment must be stable. Hash the user, don't roll dice per request:
# examples/02_percentage_rollout_with_stable_hashing_feature.py
import hashlib
def in_rollout(user_id: str, feature: str, percent: int) -> bool:
bucket = int(hashlib.sha256(f"{feature}:{user_id}".encode()).hexdigest(), 16) % 100
return bucket < percent
dispatchers = [f"dispatcher-{i:02d}" for i in range(1, 13)]
for pct in [10, 50, 100]:
on = [d for d in dispatchers if in_rollout(d, "new-dashboard", pct)]
print(f"{pct:3d}%: {len(on):2d} of 12 -> {', '.join(on) if len(on) < 12 else 'everyone'}")
print("stable for the same user:", all(in_rollout("dispatcher-03", "new-dashboard", 50) ==
in_rollout("dispatcher-03", "new-dashboard", 50) for _ in range(5)))
# 10%: 1 of 12 -> dispatcher-10
# 50%: 3 of 12 -> dispatcher-03, dispatcher-08, dispatcher-10
# 100%: 12 of 12 -> everyone
# stable for the same user: True
Hashing feature:user means dispatcher-03 sees the new dashboard on every request once included — a user flickering between old and new UIs files the weirdest bug reports of your life. Note also the honest small-numbers effect: 50% of 12 gave 3, not 6; with a dozen users, percentages are approximate and the pilot-group stage matters more than the dial.
🧪 Quick quiz — answer from memory, then check.
- Why hash the user ID for a percentage rollout?
Show the answer
Each user stays in the same group on every request, so their experience is consistent. dispatcher-03 got the same answer on every check. (verified against the example output above)
Done here? The practice set for Part 16 — 4 exercises with solutions — is on the part page.