Please enable JavaScript to use CodeHS

Product Management & Decisions

Feature flags & safe rollout

A feature flag is an on/off switch for a feature in code. It lets you ship new code to production while keeping the feature hidden, then release it slowly to a small group.

Release Management ~10 min High School / College Prep
The Big Idea

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.

Advantages

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.

Rollouts

Gradual rollouts

A common pattern is to roll a feature out in stages:

  1. Enable only for internal team members.
  2. Enable for 1% of real users and watch metrics.
  3. Increase to 10%, 50%, and eventually 100% if everything looks good.
  4. 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.

Interactive

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.

Internal team
Beta users (5%)
General users

Approx. rollout: 5% of users

Status: enabled for internal team only
Check Yourself

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.