Release Engineering: Scenario-Based Questions
84. How do you design and manage feature flags in a production system?
Feature flags allow you to ship code continuously but release features selectively. Theyβre key to controlled rollouts, A/B testing, and safe experimentation β when implemented thoughtfully.
π© Types of Feature Flags
- Release Flags: Turn features on/off post-deploy.
- Experiment Flags: Enable A/B testing or canary cohorts.
- Ops Flags: Temporarily disable behavior during incidents.
π§± Flag Implementation Options
- Boolean flags: Simple enable/disable.
- Targeting rules: Enable for specific users, groups, or conditions.
- Dynamic rollout: Gradually increase exposure by % or region.
π οΈ Tools & Services
- LaunchDarkly, Unleash, Flipt
- Homegrown flag services backed by Redis or config stores
- CI/CD plugins for toggling flags during deploy
β Best Practices
- Externalize flags (no redeploy needed to change state).
- Audit flag changes and restrict write access.
- Set TTL or cleanup plans for temporary flags.
- Use flag status metrics to detect partial failures or crashes.
π« Common Pitfalls
- Leaving stale flags β creating tech debt and complexity.
- Toggling flags without validating downstream dependencies.
- Flag logic deep inside business logic β hard to test or remove later.
π Final Insight
Feature flags turn code into controlled experiments. With safe toggling, metrics, and governance, they unlock continuous delivery without compromising safety.
