What is a feature flag?
A feature flag is a conditional in your code. Instead of shipping a finished feature to every user immediately, you wrap the new behavior in a flag. If the flag is on, users see the new feature. If it is off, they see the old behavior.
if feature_enabled("new_dashboard"):
show_new_dashboard()
else:
show_old_dashboard()
The new dashboard code is already live, but it is only visible when the flag is on. This separates deployment — getting code onto servers — from release — making it available to users.
Why use flags?
Feature flags make software releases less scary. They let teams:
- Ship faster: Merge code even if the feature is not finished.
- Test in production: Try the feature with a small audience before everyone sees it.
- Roll back instantly: If something breaks, turn the flag off instead of redeploying.
- Target groups: Enable the feature only for beta users, employees, or a percentage of traffic.
The downside is that flags add complexity. Old code paths stay in the codebase while the flag exists. Teams track flags and remove them once a feature is fully launched.
Gradual rollouts
A common pattern is to roll a feature out in stages:
- Enable only for internal team members.
- Enable for 1% of real users and watch metrics.
- Increase to 10%, 50%, and eventually 100% if everything looks good.
- Remove the flag once the old code path is no longer needed.
This is safer than launching to everyone at once because problems affect a small audience and can be stopped quickly.
Simulate a rollout
Toggle the feature on for different audiences and watch the rollout grow. If an alert fires, use the kill switch to turn it off for everyone.
Approx. rollout: 5% of users
Quick quiz
1. What does a feature flag separate?
2. Why is a gradual rollout safer than launching to everyone?
3. What is a common downside of feature flags?
Keep learning
Feature flags help you control release, but how do you know whether the release is healthy? Metrics and analytics are next.
Part of the “Product Management & Decisions” series.