Video in progress
What do feature flags give you in system design, and how do they turn into a source of risk?
A feature flag separates deploy from release: the code is on prod, but the feature is switched on with a flag — by percentage, by segment, and turned off instantly if there's a problem. The risks are that stale flags clutter the code, combinations go untested, and the flag service itself becomes a critical dependency.
📖 Answer
The benefits:
- Deploy ≠ release. You merge half-finished code into main and hide it behind a flag — no long-lived branches.
- A gradual rollout. 1% → 10% → 100%, or only internal staff, only one city.
- A kill switch. The new recommendation algorithm overloaded the DB — you turn it off in a second, without a deploy.
- Operational flags. "Temporarily disable heavy reports" — a load shedding tool during peak load.
if (flags.isEnabled("new-checkout", user)) {
return newCheckout.process(cart);
}
return legacyCheckout.process(cart);
The problems I've seen on prod:
- Debt. After a year, 300 flags, half of them at 100% and forgotten.
ifall over the code. Every flag should get an owner and a removal date, with automatic reminders about stale ones. - Combinations. 10 flags — 1024 states. You can't test them all; flags shouldn't depend on each other.
- When the flag service goes down. Asking over the network on every request creates a new single point of failure. The right way: the SDK caches the values locally and refreshes in the background; if the service is gone — the last known value or a safe default.
- Consistency. So a user doesn't see the new flow on one request and the old one on the next, the percentage split has to be deterministic, based on a hash of
userId.
And flag changes need an audit trail and monitoring just like deploys — "who turned on what, and when". Many incidents start not with code but with a flag change.
Sign up to mark studied questions and save your progress.