Nguyen Le Phong

Feature Flags: Deploy Today, Release When You're Ready

Feature flags split deploy from release.

Release afternoon. The code is merged, the tests are green and the deploy window is open. Then someone says what everyone's been thinking: the new checkout touches payment, email, inventory and that one promo rule that broke twice last quarter. The old options were ship it all and hope, or delay it all and explain. A feature flag gives you a third one: deploy the code now, keep the feature off, and pick the moment users see it.

That third option is most of what flags are for. Below is how they work, where they help, and the bill they run up when nobody cleans them out.

Deploy and release are two different buttons

Deploying moves code into an environment. Releasing shows a behavior to users. When one button does both, every deploy carries the full weight of every feature inside it. Google's SRE workbook makes the same split: feature flag frameworks "allow you to separate feature launches from binary releases," so you can turn a feature off without waiting for a new build (Canarying Releases).

Once the buttons are separate, a lot gets easier. You ship smaller code changes more often. You turn the feature on for your own team first. You open it to more people step by step. And if something looks wrong, you switch it off in seconds instead of rebuilding.

A product and engineering team sits in a release meeting with laptops open while the new checkout feature stays switched off behind a flag.
The code is already in production. Whether users see it is a separate decision, made with the flag.

What a flag actually is

In code, a flag is a branch: if this condition is true, take the new path, otherwise take the old one. Pete Hodgson's long guide on Martin Fowler's site names the parts. The toggle point is the if in your code. The toggle router is the logic that decides the answer (Feature Toggles (aka Feature Flags)). His advice is to keep the two apart: the code should ask "should this happen?" and never know how the answer was reached. Then changing a rollout rule doesn't mean editing fifty if statements.

The condition can target almost anything: internal staff, one tenant, one country, 1 percent of traffic, a beta group. When I built the multi-tenant flag platform at NDSVN, which served 30+ tenants and about 40k users, the rules had priorities, percentage rollouts could target a tenant, a segment or an environment, the config lived in JSON, and evaluation was stateless, so every server gave the same user the same answer.

Hodgson also points out that flags aren't all the same kind of thing, and the kind decides how long one should live:

KindWhat it's forHow long it lives
Release toggleHide unfinished or not-yet-launched work.Days or weeks. Remove it once the feature is fully on.
Experiment toggleSplit users between variants for an A/B test.Hours to weeks, decided per request.
Ops toggleTurn off an expensive or risky behavior under load or during an incident.Mostly short, but some stay for good as kill switches.
Permissioning toggleGive certain users a feature: beta testers, premium plans, internal staff.Can be years. Treat it as product logic.

Roll out to the next small group

Staging is useful, but it's still a model of the world. Some bugs only show up with real traffic, real data shapes, real devices and real network timing. A flag lets you meet those conditions without betting every user at once. Instead of asking "is this safe for everyone?", you ask "is it safe for the next small group?"

Google calls the technique canarying: "a partial and time-limited deployment of a change in a service and its evaluation." The part that gets the change is the canary, and everyone else is the control you compare it against. The workbook suggests a short list of metrics, "perhaps no more than a dozen," starting with the clearest ones, like crashes and failed requests. Its worked example shows why small groups matter: if a canary on 5 percent of traffic throws errors on 20 percent of its requests, the service overall sees about 1 percent (Canarying Releases).

A typical path: your own team, then one friendly customer, then 5 percent, then wider as the numbers hold. Write the "go to the next step if..." rule before you start, so nobody makes it up halfway through a nervous afternoon.

A few engineers watch rollout dashboards together as a feature widens from an internal group to a larger share of production users.
Each rollout step is a small decision, and the team makes it from the dashboards on the wall.

Keep a kill switch within reach

Say a new recommendation panel slows the page, or a partner integration starts timing out. Turning off that one behavior is often safer than rolling back a whole deploy that also carries three unrelated fixes. Hodgson describes long-lived ops toggles that act as a manually managed circuit breaker. On Zalo PC, risky changes ship default off, behind kill switches and remote config.

A kill switch doesn't replace rollback, tests or incident response. It's one more lever. And like any lever you only pull in an emergency, try it once on an ordinary Tuesday, so you know it works and who's allowed to flip it.

Merge unfinished work without fear

Flags also help before release day. You can merge the backend change, then the UI, then the analytics, then the copy, all behind a flag that's off. Code joins the main branch early while the behavior stays hidden, so there are fewer long-lived branches and fewer painful merges. If your team is moving toward trunk-based development, flags are a big part of what makes a busy main branch feel safe.

Every flag is inventory

Each flag adds another version of reality. Both paths have to make sense. Tests may need to cover both. Support needs to know which customer saw what. Analytics has to tell old and new apart. Hodgson puts it plainly: "Savvy teams view their Feature Toggles as inventory which comes with a carrying cost." The habits he lists are cheap:

  • Add a removal task to the backlog the day you add a release toggle.
  • Give flags an expiry date. Some teams go further with "time bombs" that fail a test once a flag outlives its date.
  • Cap how many flags the system can hold, so adding one means removing one.
  • Don't test every combination. Test what you expect to run in production, the fallback with the new flags off, and maybe everything on.

The cautionary tale everyone cites is Knight Capital. According to the SEC order, as summarized by finance professor Jayanth Varma, Knight stopped using an old trading function called Power Peg in 2003, but never deleted or deactivated the code. In 2012 they repurposed the flag that used to switch it on. A technician didn't copy the new code to one of eight servers, so on that server the old flag woke up the old code. Over 45 minutes the system piled up more than 4 million executions, and Knight "lost over $460 million" (SEC order explains Knight Capital systems failure). Your stale flags probably aren't that dangerous. The lesson still holds: dead code behind a flag is still code.

An engineer reaches for a kill switch next to monitoring dashboards and a checklist for removing temporary flags.
The kill switch and the cleanup list belong together. One is for today, the other keeps next year's codebase readable.

A flag without data is just a button

When a flag is on for a group, you should see that group's error rate, latency, conversion and support tickets next to the control group. If the only feedback is someone in chat saying "looks fine," the flag isn't doing its job yet. At NDSVN we tracked rollout impact in PostHog for exactly this reason.

Some changes need more than a flag

A flag can hide a UI branch. It can't hide a new database column, a changed event format or a new permission model. For those, Danilo Sato describes parallel change, also called expand and contract (ParallelChange). First you expand: support both the old and the new shape. Then you migrate every client over, which is often the longest phase. Then you contract and remove the old shape. In database terms, both schemas live side by side during the migration. The flag decides who sees the new behavior. Expand and contract keeps the data safe either way.

Try this week

  • List the flags in your codebase and mark each one as release, experiment, ops or permissioning.
  • Pick one release flag that's been fully on for a month and delete it, both paths.
  • For your next risky feature, write the rollout steps and the "go to the next step if..." rule before you deploy.
  • Flip one kill switch in staging and time how long it takes to take effect.

Good flag practice looks boring on purpose: clear names, safe defaults, an owner on every flag, dashboards that split on and off, and old flags that actually get removed. Next time a release feels too big, ask whether you can deploy it dark, open it to your own team first, and widen it one small group at a time.

What did you think?

Frequently asked questions

What's the difference between deploying and releasing?
Deploying puts code into an environment. Releasing lets users see the new behavior. A feature flag separates the two: the code ships turned off, and you choose when and for whom to turn it on, without a new build.
What kinds of feature flags are there?
Pete Hodgson's guide on martinfowler.com names four: release toggles that hide unfinished work for days or weeks, experiment toggles for A/B tests, ops toggles that switch off risky behavior (some stay as kill switches), and permissioning toggles that give certain users a feature and can last for years.
How do you keep feature flags from turning into tech debt?
Treat every flag as inventory with a carrying cost. Add a removal task when you create a release flag, give flags an expiry date, cap how many the system can hold, and delete both the flag and the old path once a rollout is done.
How big should the first step of a gradual rollout be?
Small enough that a bad release hurts few people. Google's SRE workbook shows that a canary on 5 percent of traffic with a 20 percent error rate shows up as about 1 percent errors overall. A common path is your own team, one friendly customer, 5 percent, then wider as the metrics hold.
When isn't a feature flag enough?
When the change touches data: a new column, a changed event format or a new permission model. Use parallel change, also called expand and contract: support the old and new shapes, migrate every client, then remove the old shape. The flag only decides who sees the new behavior.