Feature flags
Deploy the code dark, release it with a switch.
Feature flags separate deploying from releasing. The new code ships to every server switched off, and a flag decides at runtime which users get the new path. Turning it up, down or off is a config change that takes effect on the next request, with no deploy, no pods restarting and no rollback. You can also see this as blue-green or canary applied inside your code.
0.0s / 15s
Step 1 of 5: v2 is deployed, but dark. The new code shipped earlier with its flag off. Every request runs the old code path (indigo dots), even though the pods run v2.
- Availability
- 100%
- No downtime
- Pods running
- 1.00×
- Peak 1.00× of normal
- Blast radius
- —
- Inject a bug to measure
- Time to recover
- —
- No incident
Old code pathNew code path (flag on)StartingUser with flag onSucceededFailed
Trade-offs
More filled is better for you- Uptime during deploy
- 4 out of 4.No deploy needed to release
- Low infra cost
- 4 out of 4.No extra infrastructure
- Rollback speed
- 4 out of 4.Kill switch, next request
- Small blast radius
- 3 out of 4.Exactly the users you target
- Simplicity
- 2 out of 4.Flag service and flag debt
- One version at a time
- 1 out of 4.Many code paths live at once
Pros and cons
Pros
- Release and roll back in seconds without touching infrastructure.
- Precise targeting: by user, account, plan, region, ring or percentage.
- Enables trunk-based development. Unfinished work merges dark.
- Product and support teams can control releases without a deploy.
Cons
- Every flag doubles a code path. Too many of them make code hard to reason about and test.
- Stale flags are technical debt, and occasionally a landmine.
- The flag service becomes critical infrastructure. Decide what happens if it's unreachable.
When to reach for it
Use it when
- Almost always, for user-facing behaviour changes.
- Long-running work you want to merge early.
- Gradual releases, betas, entitlements and kill switches for risky dependencies.
Avoid it when
- Infrastructure changes such as runtime or library upgrades. A flag can't hide a new JVM.
- Anything where both paths can't safely coexist, like one-way data migrations.
How to do it
import { OpenFeature } from "@openfeature/server-sdk";
const flags = OpenFeature.getClient();
export async function checkout(cart: Cart, user: User) {
const useNew = await flags.getBooleanValue("new-checkout", false, {
targetingKey: user.id, // same user → same answer
plan: user.plan,
});
return useNew ? newCheckout(cart) : legacyCheckout(cart);
}Gotchas
- Always have a safe default for when the flag service is down. Usually that's off.
- Give every flag an owner and an expiry, and delete it once it's at 100%.
- Never reuse a flag name for a different feature. Old code still reading it may wake up.
- Test both paths in CI, at least for the flags that are live.