Crocusoft | What Is a Feature Flag? A Safer Way to Release New Features
Diagram of a feature flag switch gradually rolling out a new feature
Business 9 MIN READ 12/1/2026 8:47:33 AM

What Is a Feature Flag? A Safer Way to Release New Features

A team spends weeks building a new feature, tests it, and then Deployment day arrives and everyone holds their breath. If something goes wrong, you need either a fast rollback or an urgent new release. A feature flag (also called a feature toggle) is an approach used to reduce that stress.

In this article we explain what a feature flag is, what types exist, when it's useful and how it turns into a problem if it isn't managed. The core framework comes from Martin Fowler's "Feature Toggles" article and Microsoft Learn documentation.

What Is a Feature Flag?

A feature flag is a condition placed in the code: the feature works only when the flag is "on." It separates shipping code to Production from showing the feature to users. The code can already be there while the feature stays hidden, and it's switched on through configuration when needed.

A simple example: an online store has a new checkout page ready. Instead of opening it to everyone at once, you show it first to the internal team, then to a small share of users. If a problem appears, you turn the flag off and the old page returns. No new Deployment is needed.

What Are Feature Flags Used For?

  • Low-risk releases. Even if a feature is unfinished, the code can be merged into the main branch because users can't see it. This reduces the merge problems caused by long-lived branches.
  • Gradual rollout. First 1%, then 10%, then everyone.
  • A fast off switch. If there's a problem, the feature is disabled within seconds.
  • Experiments. Users are split into groups for an A/B test. See: what is A/B testing.
  • Access for selected users. A premium plan, beta users, a specific country.

The Four Main Types of Feature Flags

Martin Fowler divides toggles into four categories by purpose. The split matters because each has a different lifespan and different management.

TypePurposeLifespan
Release toggleHide unfinished or risky code, gradual releasesShort, should be removed once the feature is fully on
Experiment toggleA/B or multivariate testingShort, until results are statistically significant
Ops toggleOperational control, for example switching off a heavy feature under loadShort to long, some can stay permanently
Permission toggleGiving specific user groups special featuresLong, sometimes a permanent part of the product

Fowler notes that with experiment toggles, a user should land in the same group on every request, and the test must stay unchanged long enough for the result to be statistically significant.

A Real Scenario: Gradually Opening a New Checkout Flow

  1. The new checkout flow is shipped to Production behind a flag. The flag is off.
  2. The team tests the flow in the Production environment with internal accounts.
  3. The flag is turned on for a small percentage of users. Payment success rate and error count are watched.
  4. If the numbers look normal, the percentage grows. If there's a problem, the flag is turned off.
  5. Once it's open to everyone, the old code and the flag are removed from the codebase.

Monitoring matters here. A flag only makes sense together with monitoring, because if you can't see the problem, you won't know to switch it off. See: monitoring and logging.

Where Are Feature Flags Stored?

The Microsoft Learn documentation describes managing feature flags separately from application configuration, making changes without redeploying the app, and applying targeting rules (for example, a percentage of users). Options:

  • A simple config file or environment variable. The simplest route, but a change often requires a restart.
  • A database or cache. Changes can apply immediately. Microsoft's data store overview gives key-value storage as an example for feature flags. See: Redis and caching.
  • A dedicated feature flag service. Provides targeting, an audit trail and an interface. The market has both open-source and paid solutions, and the choice depends on the team's needs.

Feature Flag Debt: The Biggest Risk

Fowler warns that flags can create toggle debt. Each flag means an extra path through the code, and as flags multiply, the system gets harder to understand and test. With 10 flags, the number of combinations is theoretically huge, and testing all of them isn't realistic.

Practical rules:

  • Give every flag an owner and an expiry date. A release flag should be removed once the feature is fully on.
  • Make removal routine. When you create a flag, open a ticket to remove it too.
  • Limit the number of flags. The team should agree how many flags can exist at once.
  • Test the key combinations. Tests should pass with the flag both on and off. See: manual vs automated testing.
  • Log flag changes. Who changed which flag and when. When something breaks, the first question is "what changed last?"
  • Don't scatter flags across the code. Keep the decision point in one place, otherwise the code becomes unreadable.

Feature Flag Security and Fallback Planning

  • Permissions. Who can change flags should be restricted. Turning off a Production flag by mistake is also an incident.
  • Default value. If the flag service is unreachable, what behavior does the system choose? Make the safest option the default.
  • Don't tie sensitive data to flags. Flag environments and targeting rules should not hold secret information.

Feature Flag vs Branch, Staging, Canary

  • Branch: keeps code separate. Long branches create merge problems. A flag keeps the code in the main branch and hides the behavior.
  • Staging: a test environment. Behavior can differ with real user traffic and real data. A flag lets you test on a small slice in the real environment.
  • Gradual rollout (canary): sending a new version to a small share of servers. A flag gives control at the user or feature level. They complement each other. See: CI/CD Pipeline.

When You Don't Need Feature Flags

  • On a small, rarely changing site or a single-developer project, a flag can add needless complexity.
  • If a change is simple and easy to roll back, a direct Deployment may be enough.
  • If the team lacks the discipline to manage flags, they can turn into technical debt.

Frequently Asked Questions

Are feature flag and feature toggle the same thing?
Yes, they are two names for the same approach.

Does a feature flag need a new Deployment?
Not to turn it on or off, if the value is stored outside the application. But the new feature's code itself must be deployed once behind the flag.

Is a feature flag different from an A/B test?
An A/B test is a goal: comparing variants. A feature flag is one of the mechanisms that makes it possible. In Fowler's classification, the experiment toggle serves this purpose.

How long should a flag be kept?
It depends on the type. Release flags should be short-lived. Permission flags and some ops flags can last long.

Do feature flags affect performance?
Each check means a little extra work. If flag values aren't cached or are read from a remote service on every request, it can become noticeable. Measure it in your own system.

What's the simplest way to start?
Create a simple release flag for one risky feature, use it for a short time, and remove the flag when the feature is fully on. Then expand the process.

Conclusion

A feature flag separates shipping code to Production from opening the feature to users, which makes releases safer. But that advantage holds only if flags are managed: without an owner, an expiry date, monitoring and a removal plan, flags turn into technical debt.

If you want to build a safe release process for your team and combine CI/CD with monitoring, read about our DevOps approach and get in touch with the Crocusoft team.

Sources: Martin Fowler, Feature Toggles; Microsoft Learn, feature flag documentation.