On a Wednesday in April, a release we shipped in the afternoon broke the invoice preview for customers on one particular contract type. The bug affected only 11 customers, but one of them was right in the middle of month-end billing. We decided to roll back, and at that moment we came face to face with a painful truth: the same release contained two other major features people had been waiting three weeks for. The rollback took back those two perfectly good features along with the broken invoice preview. To fix one customer's problem, we pulled the features six hundred customers had just received right out of their hands. That day I learned, as the most expensive lesson of my first year as CTO at Wemosis, that a deploy and a release are not the same thing.
The Code Is Live, but the Door Is Closed
The essence of the feature flag idea fits in one sentence: code reaching the server and a feature being opened to users are separate events. A new feature goes live behind an if block, the flag is off, and nobody sees it. The decision to turn it on is independent of the deploy, instant and reversible. In this model, the April disaster would have ended like this: turn off the invoice preview flag, problem solved in two minutes, and the other two features stay right where they are. No rollback, no emergency release, no late night.
We looked at off-the-shelf services, but at the time they fit neither our budget nor our data sensitivity requirements. So we wrote our own infrastructure in two weeks and deliberately kept it boring: flags live in a single database table; application instances pull the flags every 30 seconds and keep them in memory; and each flag's scope is either everyone, a specific list of customers, or a percentage slice. For the percentage slice, a hash of the user ID and the flag name is reduced to the range 0-99. This determinism is critical: the same user lands in the same slice on every request, so the feature doesn't flicker in and out. In the first version, a teammate who didn't know this used a random number, and learned the lesson for good from a test user whose interface changed every time the page was refreshed.

The Month-End Saved by 5 Percent
The day the infrastructure paid for itself came in early September. We had rewritten the route optimization engine, a risky change whose calculation results could differ from the old engine's. In the old world, this would either have sat in staging for months or been switched on for everyone at once some night. In the new world, we first opened it to 5 percent. Within forty-eight hours, something odd showed up on the monitoring dashboard: in the 5 percent slice, average route time was shorter than expected, but three customers were complaining. The engine was miscalculating breaks on shifts that ran past midnight. We turned the flag off for those three customers, fixed the bug within a week, and walked the slice up through 25, 50 and 100. With the old approach, the same bug would have hit 600 customers on the same night. Progressive rollout doesn't eliminate bugs; it shrinks a bug's blast radius down to a negotiable number.

Whether you compute the percentage slice from the customer ID or the user ID isn't an innocent detail either. Because ours is an enterprise product, we chose the customer ID: two employees of the same company seeing different interfaces on the same screen would be a nightmare for the support line. In consumer products, the preference usually goes the other way.
The kill switch side also proved useful somewhere we didn't expect. When our external SMS provider's response times ballooned 30-fold one afternoon, we turned off the flag wrapping notification sending and kept the queue from choking, then turned it back on once the provider recovered. Flags aren't just a gate for new features; they also work as circuit breakers against external dependencies.
Let me also cover the performance side of the infrastructure, because in the first design draft we were making the classic mistake of going to the database on every flag check. An average request passes through 6-8 flag checks, which means 8 extra queries per request just to ask "is this feature on?" The 30-second in-memory cache brought that cost down to practically zero; a check is just a read from an in-memory map. The price is propagation delay: when you turn a flag off, the effect is complete within 30 seconds at most. Rather than trying to shorten this for emergencies, we accepted it honestly; the kill switch's 30 seconds is still fifty times faster than a rollback's 25 minutes. We also added evaluation logging: on every request, which flags returned which value gets written to the debug logs. The answer to "why does this screen look different for customer X?" is no longer a guess; it's a log line.
Welcome to the Flag Junkyard
Six months later, the table we'd been proud of started turning into a table of shame: there were 43 flags in the system, and at least 15 of them had long since been switched to 100 percent and were never going to be turned off again. In the code, each one lived on as a dead if branch, inflating the test matrix and forming archaeological layers that made every new developer ask "what happens when this flag is off?" We also got bitten once by a real bug caused by the interaction of two flags: the combination of A on + B off had never been tried in any test.
As a remedy, we made a birth certificate mandatory for every flag: each flag's owner, purpose and expiration date are written into its record in the table. Expired flags are read out to their owners in a weekly report, and cleanup is planned as sprint work. Since then, our flag count has held steady in the 20-25 range. Adding a flag takes one line; keeping it alive is debt with interest. Had we known that from the start, we would have written this rule on day one.
Within a year, flags turned out to have another unexpected use: operational switches. Putting the system into maintenance mode, making the reporting module read-only, or pausing a heavy background job used to mean a configuration change plus a restart; now each of these is a flag. As these switches multiplied, a need for auditing arose too. During a midnight incident in October, not being able to answer "who turned this flag off, and when?" was unsettling. We added a change log to the flag table, so every toggle is recorded with four fields: who, when, old value and new value. Like anything else that changes production behavior, flags need traceability. The price of instant power is record-keeping discipline.

A Measured Recipe for a Small Team
Our testing strategy evolved along with the flags. Testing every combination of forty-three flags is combinatorially impossible, so we accepted that and made a pragmatic agreement. In CI, the test suite runs with two profiles: all flags as they are in production, and flags currently being rolled out switched fully on. On top of that, writing at least one test that covers both sides of a flag is the responsibility of the developer who adds it. This isn't a mathematical guarantee, but since the April disaster, our only flag-related production bug came from an old flag added before that testing agreement existed. A flawed agreement that works beats a flawless matrix that can't be put into practice.
The year's accounting is clear: our rollbacks dropped from 9 a year to 1, risky changes reach production faster, and the "deploying on a Friday" debate has lost its meaning because the deploy itself has become a non-event. None of this took a SaaS contract or a complex platform. It took a table, a cache, a deterministic hash and, hardest of all, the discipline of flag hygiene. Feature flag infrastructure isn't the work of tools with fancy names; it's the work of boring consistency. If you'd like a similar starter recipe for your own team, get in touch, and I'll sketch out the schema of that first two-week version and send it over.