Turn features on or off with a switch, without deploying new code.
A feature flag (also called a feature toggle) is a switch in your code that turns a feature on or off while the app is running, without deploying new code.
Normally, deploying code and showing a feature to users happen at the same moment. Feature flags separate the two. You deploy the code with the new feature switched off. Later, you release the feature by changing the flag. The deploy is a technical step. The release is a business decision.
In the code, a flag is just an if: if the flag is on for this user, show the new way, otherwise show the old way. The flag value comes from a flag service or a config store, so you can change it at run time. A flag can be on for everyone, off for everyone, or on for some users: a percentage, a group, a country, or a named list.
| Kind | Purpose | How long it lives |
|---|---|---|
| Release flag | Hide a feature until it is ready, then roll it out | Short: days to weeks. Remove after 100%. |
| Experiment flag | Split users into groups to measure an effect (A/B test) | Short: until the test ends. |
| Ops flag (kill switch) | Turn off a risky or expensive feature during trouble | Long: kept as a safety control. |
| Permission flag | Give a feature to certain plans, customers or regions | Long: part of the product. |
Compute hash(flagName + userId) mod 100. If the result is less than the rollout percentage, the flag is on. The same user always lands in the same bucket, so the experience does not flip-flop. Including the flag name in the hash makes different flags pick different groups of users, so the same unlucky 10% do not get every new feature.
Targeting: everyone is eligible. Only the percentage decides.
The users are a fixed list of 100 (every 5th is in the beta group, countries rotate). The hash is FNV-1a, so results are the same every time. Raise the percentage and watch that users already on stay on. Switch to the same seed for all flags, then change the percentage of two flags: they pick the same users, so one group gets all the experiments. With only 100 users the numbers wobble around the target.
| Term | Meaning in easy words |
|---|---|
| Feature flag / toggle | A switch in the code that turns a feature on or off at run time |
| Kill switch | A flag whose job is to turn something off quickly in an emergency |
| Rollout percentage | The share of users who get the flag ON |
| Bucketing | Putting each user into a fixed bucket (0 to 99) by hashing their id |
| Targeting rule | A condition for who gets the flag: group, country, plan or a list |
| Flag service | The system that stores flags and their rules (home-made or a vendor) |
| Evaluation | Working out whether the flag is on for one user right now |
| Default value | What the code uses if the flag cannot be read |
| Dark launch | Deploying code that runs in production but is hidden from users |
| Flag debt | Old flags that stay in the code after the rollout is finished |
| Trunk-based development | Everyone merges small changes into the main branch often, using flags to hide unfinished work |
| Choice | We gain | We lose |
|---|---|---|
| Build a flag system yourself | Full control and low cost at the start | You must build rules, auditing, a UI and a fast SDK |
| Use a vendor service | Ready UI, audit logs, experiments, SDKs | Cost, and another outside dependency |
| Evaluate locally with cached rules | No extra delay per request, works if the flag service is down | Changes take a moment to arrive |
| Ask the flag service on every request | Always up to date | Slower, and a failure there hurts every request |
| Flag per feature | Fine control | Many flags to track and remove |
| Long-lived flags | Permanent controls (kill switches, plans) | Code that is always more complex |