When a new feature is ready, teams often have only one option: ship the release and hope everyone's experience goes well. If something breaks, the remedy is to redeploy the previous version, which means approvals, a build and a release, and takes tens of minutes rather than seconds. A feature flag separates shipping the code from turning the feature on: the code is live, but nobody sees the feature while a switch stays off. Turning that switch on first for a few users, then for more and more of them, is called gradual rollout.
This guide covers flag types, how to give each user a stable percentage bucket, how to build a gradual rollout plan, the criteria that stop a rollout, the risks that grow with the number of flags, flag debt, what happens when the flag service fails, and how to calculate payback. All figures are representative examples, not measurements of a real system.
What Is a Feature Flag?
A feature flag is a condition in the code: if the flag is on, the new behavior runs; if it is off, the old behavior runs. The flag's value is not stored in the code but in configuration read at run time, so changing it does not require a new release.
In an example dealer portal, a "bulk order approval" feature entered the code two weeks ago and reached production through three deployments, but no dealer saw it because the flag was off. On Monday the business team said "let's open it this week", and the change took effect through a setting. For the deployment pipeline, see our CI/CD guide; for environments, see our software environments article. Here the topic is who sees the live code, and when.
We recommend reading: Our custom software service
What Are the Types of Feature Flags?
Flags fall into four types by purpose, and the expected lifetime differs by type. A flag whose lifetime is not set at the start turns into permanent configuration clutter.
| Type | Purpose | Expected lifetime (representative) |
|---|---|---|
| Release flag | Roll out a finished feature gradually | Days to weeks; 30 days at most |
| Experiment flag | Compare two variants | Weeks; deleted when the experiment ends |
| Operational (kill-switch) flag | Quickly cut off a failing dependency or load | Long; can stay for years |
| Permission flag | Enable a feature for a plan or customer | Long; tied to the commercial model |
Long-lived flags need their access rules thought through separately: who may change which flag follows the least-privilege principle in our role-based access control article.
How Is a Feature Flag Evaluated?
A flag must give the same answer for the same user: a dealer who saw the new screen yesterday must see it today, and refreshing the page must not change it. The way to get this is not to draw a random number but to compute a stable bucket from the user ID.
The user ID and the flag name are joined, passed through a hash function, and the remainder of dividing the result by 10,000 gives a bucket from 0 to 9,999. The flag is on if the bucket is below the percentage × 100; for 5% the threshold is 500.
| User | Bucket | 1% (threshold 100) | 5% (threshold 500) | 25% (threshold 2,500) | 100% |
|---|---|---|---|---|---|
| Dealer 115 | 37 | On | On | On | On |
| Dealer 13 | 184 | Off | On | On | On |
| Dealer 3 | 2,174 | Off | Off | On | On |
| Dealer 1 | 7,013 | Off | Off | Off | On |
Two properties matter. First, raising the percentage never switches earlier users off: a dealer who is on at 5% is also on at 25%. Second, because the flag name goes into the hash, groups differ from flag to flag: Dealer 13 is in the 5% bucket range of the "bulk approval" flag, but another flag gives that dealer bucket 4,734, which is outside that flag's 25% range. If the name is left out of the hash, the same small group carries the risk of every flag.
In What Order Do Targeting Rules Run?
Besides percentages, you can write segment rules. Rules run from top to bottom and the first match wins, so the order is a safety matter. An example order: 1) internal staff: on; 2) excluded dealers: off; 3) pilot dealer list: on; 4) everyone else: percentage bucket. If the exclusion rule comes after the pilot rule, a dealer who is on both lists wrongly sees the feature.
How Do You Plan a Gradual Rollout?
The goal of a gradual plan is to keep the impact of a defect small while collecting enough data. Internal staff come first, then 1%, 5%, 25% and 100%; the waiting time and the stop criteria for each step are written down beforehand.
The amount of data sets the waiting time. In the example each user makes 10 requests a day, and we want to observe at least about 2,000 requests at every step (the reason is in the next section).
| Step | Users (out of 12,000) | Requests/day | Time to reach 2,000 requests | Planned wait |
|---|---|---|---|---|
| Internal + pilot | List | — | — | 1 working day |
| 1% | 120 | 1,200 | ≈ 1.67 days | 2 working days |
| 5% | 600 | 6,000 | ≈ 8 hours | 1 working day |
| 25% | 3,000 | 30,000 | ≈ 1.6 hours | 1 working day |
| 100% | 12,000 | 120,000 | Fast | 1 day of monitoring, then a plan to delete the flag |
The full rollout takes five working days. Small steps wait for data; larger steps still wait one full working day, because load and behavior change through the day. A pilot also surfaces usage problems that testing missed; for the testing side, see our test automation guide.
What Criteria Stop a Rollout?
A stop criterion is a numeric threshold written before the rollout; a feeling that "something looks off" delays the decision. The example uses three: the error rate on flagged traffic, the duration of slow requests (p95) and the order completion rate.
For the error rate, the baseline is 0.8% and the threshold is 1.5 times the baseline, 1.2%. To keep a normal step from crossing the threshold by chance, the baseline plus two standard deviations must stay below it: n × 0.004 ≥ 2 × √(n × 0.008 × 0.992). The solution is n ≈ 1,984, which is why we wait for roughly 2,000 requests per step. Seeing 200 requests at the 1% step and saying "no errors" proves little: that sample should hold only 1.6 errors.
The criteria should raise alerts automatically; for metric design, see our software monitoring article. The error budget link is simple: a system with 3,600,000 requests a month and a 99.5% success target has a budget of 18,000 failed requests. If a broken feature fails 30% of requests on traffic of 12,000 requests an hour, it produces 3,600 errors an hour at 100% (20% of the budget) but 180 errors an hour at 5% (1% of the budget). Gradual rollout cuts the budget cost of the same defect by a factor of 20.
What Happens as the Number of Flags Grows? Combinations and Overlaps
Every independent flag doubles the number of possible system states, so testing all combinations quickly becomes impossible.
| Flags (N) | States (2^N) | Single tests (N + 1) | Single + pairwise |
|---|---|---|---|
| 5 | 32 | 6 | 16 |
| 10 | 1,024 | 11 (1.1%) | 56 (5.5%) |
| 20 | 1,048,576 | 21 | 211 |
In practice you test all flags off, each flag alone on, and the pairs expected to work together (pairwise: 1 + N + N(N−1)/2). Some flags depend on each other: "B only makes sense when A is on". With 10 flags and three such pairs, each pair drops from 4 to 3 valid states and the total becomes 1,024 × (3 ÷ 4)³ = 432.
Overlap appears when two flags change the same screen. If both are on at 25% with independent buckets, out of 12,000 users 2,250 see only A, 2,250 see only B, 750 (0.25 × 0.25) see both and 6,750 see neither. All four interfaces must be tested. If the two should always open together, use one flag or an explicit dependency rule.
How Do You Prevent Flag Debt?
Flag debt is flags that have done their job but remain in the code; each is an extra branch, extra test load and a risk of unpredictable behavior.
Take an example inventory that built up over a year without oversight: 60 flags (38 release, 6 experiment, 10 operational, 6 permission). Of the release flags, 21 are at 100% and older than 30 days; the cleanup-candidate rate is 21 ÷ 38 ≈ 55.3% (21 ÷ 60 = 35% of all flags). Seven flags have no clear owner (11.7%) and 18 have no expiry date (30.0%). With an average of 3 code locations per flag, 21 flags mean 63 unnecessary branches; cleaning at 0.5 person-days per flag takes 10.5 person-days, or ₺94,500 (₺9,000 per person-day, representative).
The remedy has three parts: owner, type and expiry date are mandatory when a flag is created; when a release flag reaches 100%, the deletion task enters the list the same day (example rule: within 14 days); and the build pipeline warns about flags past their expiry. When deleting, remove the old branch and its tests too.
Where Is Flag Configuration Read From, and What If the Service Fails?
If every request asks a remote service for each flag, you add latency and a dependency. The fix is local evaluation from cached values.
The difference is clear: with 10 flags per request, asking a remote service at 15 ms each adds 150 ms; local evaluation at 0.02 ms totals 0.2 ms. In return, the cache time sets the shutdown delay. With 12,000 requests an hour (about 3.33 per second) and a flag that fails 30% of requests, a 30-second cache means a shutdown takes effect within 30 seconds at most: about 100 requests and about 30 errors. With a 5-minute (300-second) cache the numbers would be 1,000 requests and 300 errors.
| Flag type | Default if the service is unreachable | Reason |
|---|---|---|
| Release flag | Off | Don't open a new feature to everyone by accident |
| Permission flag | Off | Don't grant access that wasn't earned |
| Operational flag | Last known value | Don't reverse an emergency decision already made |
| Experiment flag | Control variant | Keep the old behavior without corrupting measurement |
The safe default is written in the code and the application keeps the last known values. Within a single request a flag's value is read only once; otherwise a value that changes mid-operation produces half-new, half-old behavior.
How Do You Manage Access, Audit and Data Changes with Flags?
Because a flag changes live behavior without changing code, it should not be left open like an ordinary setting.
- Access: The product and development team changes release flags, the on-call team changes operational flags; moving to 100% needs a second approval.
- Audit log: Record who, when, old and new value, and the reason for every change. 90 changes a month make 1,080 records a year; during an incident the question "what changed in the last two hours?" is answered in seconds (see our incident management article).
- Data changes: If the feature behind a flag changes the data schema, first add the new field (expand), turn on the flag, and remove the old field last (contract). In the example, 600 dealers at 5% enter 2 orders a day; in 2 days, 2,400 records are written in the new format. If the flag is turned off, the old code must be able to read those 2,400 records. For public APIs, see our API versioning article for the same logic.
How Do You Calculate the Payback of Feature Flags?
The gain comes from a shorter rollback and a smaller share of affected users; the cost is setup and per-flag effort. The assumptions are representative.
- 8 faulty releases a year; rollback by redeployment after a full release takes 45 minutes; the outage costs ₺1,500 a minute.
- With flags, 75% of incidents are caught at the 5% step and the flag is turned off in 1 minute; 25% are noticed only at 100% and are also turned off in 1 minute.
- 12 risky features a year get flags; 1.5 person-days of effort per flag; setup of 40 person-days; ₺9,000 per person-day.
| Item | Calculation | Amount |
|---|---|---|
| Incident cost without flags | 45 min × ₺1,500 | ₺67,500 |
| Expected incident cost with flags | 0.75 × (1 × ₺1,500 × 5%) + 0.25 × (1 × ₺1,500) | ₺431.25 |
| Saving per incident | ₺67,500 − ₺431.25 | ₺67,068.75 |
| Annual saving | 8 × ₺67,068.75 | ₺536,550 |
| Annual flag effort | 12 × 1.5 = 18 person-days × ₺9,000 | ₺162,000 |
| Annual net | ₺536,550 − ₺162,000 | ₺374,550 |
| Setup | 40 person-days × ₺9,000 | ₺360,000 |
Payback: ₺360,000 ÷ ₺374,550 ≈ 0.96 years, about 11.5 months. The result depends on incident count: covering the annual effort takes at least 162,000 ÷ 67,068.75 ≈ 2.4 incidents, and covering setup spread over three years takes (₺120,000 + ₺162,000) ÷ ₺67,068.75 ≈ 4.2 incidents. With 3 incidents a year the net is ₺39,206 and payback takes about 9.2 years; then use flags only for the riskiest features.
Which Metrics Should You Track for Feature Flags?
Three metrics are enough. Share of flagged releases: if 52 of 74 releases used flags, 52 ÷ 74 ≈ 70.3%. Shutdown time: from the decision to the effect ending; the target, including cache, is under 1 minute and is checked by drills. Old flag rate: the share of release flags that stay at 100% for more than 30 days (55.3% in the example); the target is below 10%.
We recommend reading: How to Manage Mobile App Versions and Forced Updates: Version Policy, Staged Rollout and Rollback Guide
We recommend reading: How to Set Up IT Change Management and Maintenance Windows: Risk Scoring, Approval and Rollback Guide
We recommend reading: How to Run an A/B Test: Hypothesis, Sample Size, Significance and Pitfalls Guide
Feature Flags with İnovabil: Custom Software and Controlled Release
At İnovabil our focus is building company-specific software from scratch. Our process page records the release and maintenance steps; we suggest settling who gets which feature and when during requirements work. A feature flag is a design choice and not needed in every project; it is worth evaluating for risky features with many users.
We built CRM, purchasing and mobile for Avcılar İnşaat; a purchasing system for İZBAN; logistics and shipment planning with wholesale order management for Karyak; and warehouse management plus a complaint and support management system for Sleepy. The figures in this guide are not measurements from these projects. Send us a short summary of your release and rollback expectations and we will assess them together in writing.
We recommend reading: Our software development process: step by step from analysis to release
Frequently Asked Questions
What is a feature flag?
A switch that puts new behavior behind a condition and takes its value from configuration read at run time. Even when the code is live, the feature stays hidden until the flag is turned on; turning it on or off needs no new release.
Are gradual rollout and a flag the same thing?
No. The flag is the mechanism; gradual rollout is the plan that uses it: steps such as internal staff, 1%, 5%, 25% and 100%, waiting times and stop criteria.
Why does the same user always stay in the same group?
The bucket computed from the user ID and the flag name is fixed. As the percentage rises, more users fall below the threshold, but those already on never switch off. Because the flag name enters the hash, groups differ from flag to flag.
What does the application do if the flag service fails?
It uses the safe default written in the code and the last known value. Release and permission flags fall back to off, operational flags to the last value and experiment flags to the control variant.
Why should old flags be deleted?
Every flag is an extra code branch, extra testing and a source of confusion. Owner, type and expiry date fields let you plan the deletion when the flag is created.