Skip to main content

What is a feature flag?

A feature flag is a mechanism that lets you turn certain application features on or off without changing the code and without a new release. It gives the team control over who sees new functionality and when.

How it works

  • In the code, the new feature is wrapped in a condition:

    python
    if feature_flag("new_ui"): show_new_interface() else: show_old_interface()
  • The flag is stored in configuration (a file, a database, or a service like LaunchDarkly, Unleash).

  • Developers or product managers can turn on the feature selectively - for example, for only 10% of users or a specific group.

Why feature flags are needed

  1. Safe rollout A new feature can be enabled gradually (rollout), while tracking metrics and errors.
  2. A/B testing One flag, different interface variants for different users.
  3. Fast shutdown of problematic features If a new feature causes bugs, it can be turned off instantly without rolling back the release.
  4. Release flexibility Development and deployment are decoupled: the code can be in production but "asleep" until the flag is turned on.

Usage examples

  • A "dark theme" is enabled only for internal testers.
  • A new recommendation algorithm is enabled for 20% of users.
  • After a release, a failed feature is turned off with one click.

Conclusion

A feature flag is a "switch" inside the product that lets you manage functionality without new releases or risk. It makes the system more flexible, safer, and better suited for Continuous Delivery.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.