Kill Switches
A kill switch is a knob with values 0 and 1 that guards a risky code path so you can turn it off without a deploy. This guide walks a change through its whole life: introduce, roll out, revert if needed, stabilize, and remove.
1. Introduce
Section titled “1. Introduce”Add the knob read around the new path, with the safe value as its fallback:
if (reader.get_as<bool>("checkout:killswitch_new_path", false)) { return new_checkout(cart);}return old_checkout(cart);The fallback means a host that has no generation yet, or a name that isn’t
published, takes the old path. reader.lookup("checkout:killswitch_new_path", 0)
reports why, as a status such as MISSING or UNAVAILABLE.
2. Roll Out
Section titled “2. Roll Out”Turn it on for employees first, then a small slice of users. Publish this
definition for checkout:killswitch_new_path, as an operation in a
durable authority transaction:
{ "default": 0, "overrides": { "employees": 1 }, "rollout_pct": 1, "rollout_value": 1 }bool on = reader.get_as<bool>("checkout:killswitch_new_path", false, account_id, account_group);Ramp the percentage in steps while you watch error rates and latency. See Gradual Rollouts and Group Overrides.
3. Revert
Section titled “3. Revert”If anything looks wrong, publish the safe state. Leaving out overrides, rollout_pct and
rollout_value removes them:
{ "default": 0 }Every process takes the old path once its agent publishes the new generation, with no restart. Distribution is asynchronous, so plan for a short window where some processes have flipped and some haven’t.
4. Stabilize
Section titled “4. Stabilize”Once the new path is at 100% and has been healthy long enough, publish it as the default so hash-less callers get it too:
{ "default": 1 }5. Remove
Section titled “5. Remove”Knobs are debt. When the old path is no longer needed:
- Make the new path unconditional in code and delete the knob read.
- Deploy that everywhere.
- Delete the live definition: a
nullvalue in an authority transaction.
Doing it in that order means no running binary reads the knob after it’s gone and falls back to the old path.