Skip to content

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.


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.


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.


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.


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 }

Knobs are debt. When the old path is no longer needed:

  1. Make the new path unconditional in code and delete the knob read.
  2. Deploy that everywhere.
  3. Delete the live definition: a null value 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.