Video in progress
How do you organize releases with feature flags, and what are the risks?
I separate deploy from release: the code ships to production with the flag off, then it's turned on step by step for groups of users, and if there's a problem it's turned off without a redeploy. The risks are flags piling up, combinations exploding, test coverage, and the flag system itself failing.
📖 Answer
Different kinds of flags are managed differently:
- release flag: for gradually turning on a new feature, short-lived (weeks);
- ops flag / kill switch: switching off a heavy feature under load, long-lived;
- experiment: an A/B test;
- permission flag: depending on the plan or customer; really this is business configuration.
In Spring that's the OpenFeature SDK + a provider (Unleash, Flagsmith, LaunchDarkly), or in a simple case a database table and a cache.
if (flags.isEnabled("new-checkout", ctx(user))) {
return newCheckout.place(cart);
}
return legacyCheckout.place(cart);
The risks:
- Tech debt. Every release flag should have an owner and a removal date. Once the feature is at 100%, both the flag and the old code path are removed. Watch the count of stale flags in a metric; in practice they pile up very fast.
- Combinations. 10 flags means 1024 states, and you can't test them all. Flags shouldn't depend on each other.
- If the flag system goes down, the SDK should cache the last known value, and every flag should have a safe default.
- If the code behind a flag changes the schema, turning the flag off doesn't guarantee a rollback. Make the schema backward compatible with expand/contract.
- Audit: who changed which flag, and when. In production a flag change is as important an event as a deploy.
Sign up to mark studied questions and save your progress.