HACKER Q&A
📣 rozenmd

Does your team use feature flags?


Particularly interested in how people use feature flags on the frontend.

Does your team use them? If not, why not?


  👤 drclau Accepted Answer ✓
Worked for a bigtech well known name, large and extremely important project, literally the core of a service serving an enormous number of users, and feature flags were mandatory, no exceptions.

I can't imagine working without feature flags. Being able to enable new features in particular deployment rings (canary, dogfood, various production rings or regions), or per users / user groups, enabling gradually (percentage) and so on, is invaluable. I really can't overstate this.

Heck, we went as far as using feature flags for risky bugfixes even.

We had also internal tools to easily work with and track feature flags. A downside is that although normally you'd want to remove old feature flags that become obsolete, this hasn't been done very often.

What I suggested and we started doing was to tag the feature flags with the name of the author and the date at which they were added, and the same for the config updates, and usually ticket number and title for both case. This did help with tracking obsolescence, but obviously there was still a need to plan and do the actual work. Automating this process further was out of the question, due to the high risks involved.

Edit: added the last paragraph.


👤 fian
Yes.

Put simply it disconnects merge and deploy from launch. This is very useful when your changes rely on other teams or third parties having gone live. Having a feature flag (we call them toggles) lets you get it into production turned off, without having to coordinate deploys with other systems.

The downsides are it is extra development overhead and adds tech debt (you should go back in and remove the toggles after a successful launch). Generally we try to devise a solution that can be deployed safely without a feature flag but they are often required.


👤 politelemon
Not anymore. We do still have the ability. Some teams have found that it introduced an overhead (moving part, point of failure) and long lived staleness into certain parts of the codebase, which is actually reflective of our teams' priorities. Feature flags bring an overhead that teams should be aware of an acknowledge the management required, before introducing it into a tech stack.

👤 ford
A different question - how do teams that don't use feature flags accomplish the things feature flags enable? Namely:

1) Validating you can handle production-scale

2) Ensuring integrations/environment-related issues don't happen when you deploy

3) Alpha/Beta groups of users

4) Quick reversions when something does not work as expected

Similar to other commenters I can't imagine not using feature flags. Some of these might have work-arounds like an artificial load tester, but nothing beats true production traffic & patterns.


👤 aerovistae
Extensively. Nearly every single change to the codebase is flagged. Even switching copy is behind a flag sometimes if the copy is across multiple places. I find it excessive and irritating; it feels like cargo cult programming to me.

👤 Minor49er
Yes. I've worked at a few places that have used them similarly. Some do call them "feature flags", others call them "permissions". As others are noting in the comments here, they are great to perform partial rollouts of new features, or to selectively grant users (both for a client or just for our own in house purposes) the ability to see how a feature will run in a real world scenario.

One company created a category of feature flags that they give customers the ability to opt into themselves from their settings page if they want. This lets users selectively try out new features if they want. It's helpful to gauge interest and to get feedback before rolling out to everyone too. Though, that's a relatively small portion of the flags that are generally created

One problem that is typically encountered is setting up and executing a plan to remove the feature flags when they're no longer needed. Once you roll a new feature out to everyone (assuming there isn't someone who doesn't want the change), you should remove the flag and any code that's checking for it to keep things clean.


👤 jasonpeacock
Not just feature flags, but "knobs" - we use a percentage (of requests or customers) instead of a boolean to enable features so we can dial them up/down.

This let us slowly roll out new features to a subset of users in case there are any issues.

Using feature flags also requires testing the default (not enabled state), ensuring you have a robust realtime configuration manager to control the knobs, and metrics for everything - not just how many requests/customers are opted-in, but also the progress & state of the configuration change.

It does no good to first enable a feature at 1% if only 1% of your servers have received the updated configuration - that's only .01% impact. It also tells you when your rollback is complete - you want to be sure when you disable something that there's not some stuck server with the feature still enabled...


👤 alexfromapex
Yes, the main problem I have with actual "feature" flags is they increase complexity because you have to test multiple variants of features together with integration and unit tests. I like the idea of wrapping a whole release in a release flag instead because you have a set of released features that should all work together.

👤 BossingAround
How do folks implement feature flags? Do most people use feature flags as "remove/add code from/to my application at compile time"? Or do people also use some kind of a runtime check system that enables them to toggle functionality while the application is running with some partial reloads or fast restarts?

👤 jpollock
Every developer makes a rollback-worthy mistake every x changes. This means your probability of having a clean release is (1-1/x)^NumDevs EDIT - Assuming everyone submits 1 change/release.

Let's give it 1/100 bad code change, and 100 devs. The probability of a clean push is:

(1-1/100)^100 = 0.36. That's worse than a coin flip.

for 10 devs = 0.90. Still not great, one push in 10 will be bad.

When you're trying to push daily (or even more frequently), this will kill the team's velocity. It's even worse when there are interleaving changes making rollback and re-release impossible before the next release. Rollback and freeze is a problem when you're trying to meet deadlines (either marketing or regulatory).

Feature flags allow the code to go in and each change to be rolled back independently. This lets the rest of the team to make progress while the bug is debugged.

Short release pipelines could be a solution, but they're aren't necessarily sufficient. Time to recovery when there isn't a feature flag is also problem.

For example, some bugs take days/weeks to reveal themselves (think month end), so a "30 min build and full push" is not enough of a guarantee. Time to recovery needs to consider the time to find the change and roll it back, including dealing with any interleaving changes that happened in the meantime.


👤 candiddevmike
No, we do monthly releases instead and make sure they're stable or fix them with a follow up bug fix if they're not. If a feature isn't ready yet, it doesn't get into the release (or develop branch).

I personally think feature flags are useful if you're deploying very frequently, but they just add confusion to software that's meant to be released/stable, especially for those developing it (what's with all the half done code and TODOs everywhere?)


👤 SkyPuncher
We simply have a column on a few our of models called "features". Just an array with plaintext values. It's just branching logic on the FE/BE.

The biggest thing with feature flags is using them at an appropriate level of granularity for the stage of company you're at. Branching logic adds complexity.

Consider starting with an entire feature/route/page set to keep the branching logic consolidated and simple. Only move to more granularity as you need it.


👤 srirangr
Not all projects are of the same duration or complexity. Most of the features get developed in a 2 week sprint, but from time to time, there are projects that take a month or so. When there are multiple teams with different working schedules, feature flags add a lot of value during deployments and reduce the dependencies on other teams. The business/product benefits that arise from feature flags are equally valuable.

👤 dabeeeenster
Also biased! [0], we use them a lot, mainly on the front end. Most of the new features we are working on are gate-able via front end UI elements, and so we push out pretty much all our new features using our own platform.

We are also doing interesting stuff like controlling what features are in our Open Source Docker container via flags in the platform that are baked into our Docker images when they are built.

Once you start using and relying on flags, it's hard to go back, and helps with a bunch of 'good' engineering processes and patterns.

Another interesting aspect is that once you have gated a feature based on a flag, you can then AB test that feature, almost for free, as you have a way of bucketing users and showing or hiding the feature using most feature flag platforms.

[0] https://flagsmith.com/ & https://github.com/Flagsmith/flagsmith


👤 bluefirebrand
We rarely use them where I work although we've recently had some devs who are trying to get us to adopt it.

Personally I think they should be used sparingly for things where you have to be able to configure the same software on different environments differently, for purposes of A/B testing or other such things.

Using them a lot increases your code complexity and is basically just tech debt imo. The gain is that you don't have to run a deployment to turn on a feature? If you invest the time to make your build/deploy process not suck, this isn't a very big win.

I'm honestly surprised to see so much love for them here. I'm going to take some time to read this thread, see if there are compelling reasons to take on the extra complexity that I haven't considered.


👤 citrusx
We do. But, depending on your project, you may need to do extra work to corral the complexity that can grow up around them. We wrote a library for using them in our web apps that allows us to use them, and remove them, easily.

Some possible failures that can happen with feature flags: 1) "Accidentally perpetual" - Since feature flags are a part of the code, it's easy to create multiple dependencies on the flag value, which makes it difficult to remove from the code without mysterious null exceptions happening where you didn't expect them. 2) Cross-scope - Using multiple feature flags carelessly can result in situations where one flag value change doesn't do what's expected unless another flag's value is present or set to a certain value. Flags should always be independent from one another, even if they're controlling the same code. Instead of two flags whose values affect each other, you would instead create more flags (4, in the case here if using Boolean flags) to reflect each combined state. 3) Fallback - What happens if the systems or SaaS that supplies your feature flags becomes unavailable? Always consider this.

Feature flags are a great tool, and enabling your team to be able to "test in production" with them can be amazing. However, do watch out for the footguns.


👤 gostsamo
Yep. Some features are complex and cannot be completed in one sprint. On the other hand, we have constantly changing front-end code and leaving code in a branch too long might make it drift and might get broken in a lower-layer change because constantly syncing gets annoying. The other case is when the front-end is ready but the back-end is not or there is a public announcement that is scheduled for a later date.

👤 jpthurman
Feature flags became essential when we began to open our offering as various configurations with varying features that align with business packaging. We use them as an easy way to toggle features per environment and end-user-configuration. Certain features are turned on/off for our Cloud version vs. OSS vs. Self-host. It's conceptually easy to understand across the team and easy to control.

👤 mcv
I haven't seen them used on any of the projects I've worked on. HN is really the only place I regularly hear about feature flags, actually.

👤 malthauser
Haha. Yes!

I've now worked at 3 different companies that built feature flags both internally and as a core part of their external product offering. I'm currently at Flagsmith (open source too).

Here are some of the more popular front-end feature flag use cases:

1. Gradual Roll Out: Build a feature and release it to 5% of your users, then increase as you see that it isn't "breaking anything". You might even do this AFTER a successful A/B Test concludes. 2. Test in Production: Build a feature and release it to only your internal team (or QA Team) to see how it works in a real production setting. 3. Feature Gating: Managing access to specific features based on a targeting condition. I've seen people do this for BETA features with key customers pretty often.

Most common reason people don't use them: 1. They are concerned about feature flag creep. Managing them if they aren't deprecated can be a problem worth thinking through ahead of time. 2. They worry about giving access to important parts of their product in production. Thinking about your environment set-up and access control is smart.

Hope this helps!


👤 wmij
Yes. The ability to turn features on and off, especially on demand is an important part of the applications and services my team is responsible for. We have a few different levels where features can be enabled or disabled ranging from configuration injected into applications, configuration stores to lookup settings giving us the ability to expose/hide features.

To support per user or group settings we have a `canary` role that can be set to allow access to new features that have been integrated but not available to the general users. The nice thing about having something tied to roles is that the changes can take effect immediately without the need for redeploying, or reinitializing applications in our footprint. Also, the role based model can be made as fine or coarse grained suited to the app's and user's being served.

We tend to avoid encoding feature flags into URLs because users can bookmark them, revisit via history or navigate from old emails, messages, etc. and we'd rather not expose these flags or have them memorialized anywhere.


👤 karmakaze
My recent experience working with feature flags:

- enable percentage rollout only after validating for specific test accounts/ids

- when using percentage rollout, also have a 'killswitch' flag that can negate belonging to the enabled group

- if you don't need to test specific accounts/ids first, you can use only a 'killswitch' rollout flag starting at 100% and decreasing. enabling still possible to remove particular id's from feature enabled group

- best experience was making a helper that everything goes through rather than query feature flag name directly. This lets you test things like what happens in CI/CD if I hard-code that return value to fully enabled. This gives you test coverage using the flag for all the tests that don't mention it at all. The helper can also do any combination of required flags/killswitches for something to be meaningfully active.

- and for expired flags, have a recurring nag mechanism, e.g. Slack post by team/channel owner


👤 worg
We use them not as an A/B testing tool as I saw it suggested in a comment but more like a way to have controlled rollouts of features. As our team uses trunk based development we don't have a "development" branch so everything goes to master (we have a staging env and manual judgement prior to production deployment tho)

👤 dr_dshiv
Do you use any tools, like LaunchDarkly, for the feature flagging?

👤 didip
Feature flag is inevitable for all large software projects.

1. To hide not-yet-ready features that have production dependencies.

2. To route special users to a different code path.

3. To test new ML code on a fraction of users.

4. After a refactor to a different language or a micro service, you may need feature flag to route requests.

I could go on and on, it's simply mandatory.


👤 rognjen
Perspective from a small startup: we used feature flags mainly for two types of features: 1. complex and 2. affects money.

Complex: when you roll out a complex feature, it's best to not make it available to all. Instead, focus on a small trusted subset of savvy users who will be easier to train. At the same time, you can use their experience with it to simplify it and make it easier for the rest of the userbase.

Money: we ran a marketplace so dealt with clients' money. We quickly realized that changes to the way payments are processed needed extensive feedback. Even if we assumed something was alright, chances are there would be objections. Rolling out changes in stages would allow our team to handle complaints and feedback without being overwhelmed.


👤 outsidetheparty
Midsize SaaS here -- we switched from feature branches to feature flags a couple of years ago; major improvement in our process. Once or twice we've been tempted into foolishly "just this once" working on something out of a feature branch instead, and it always always always leads to messy merge conflicts.

Our React app just uses a simple home-rolled set of keys in localStorage; we have a "secret" route that lets users turn their own flags on or off, and we encourage developers to duplicate big chunks of code while working behind a flag instead of mixing old and new, to make cleanup easier.

(And yeah, someone does have to stomp around every few months and remind everyone to clean up their dead code again. Still worth it.)


👤 neebz
Yes. Feature flags changed the mindset of my whole team. I absolutely love the fact that it pushes the whole team towards release-small-release-often mentality. It's a technical solution with many benefits but I love the cultural impact the most.

👤 jhhh
Not frontend but I use them extensively now in backend + REST endpoints. I still think they are necessary to prevent having to hotfix builds when something breaks with a new feature, however I don't think they are purely good. Too many feature flags add a lot of complexity to the testing surface of a project and if the test suite isn't well adapted to test all the configurations then people will end up unit testing their feature flag (if they do at all) and not doing any kind of integration testing of the specific combination of flags that production may find itself in. You need to have a well thought out test suite.

👤 timgl
Biased [0], but we use feature flags a ton. It means that as an engineer we can throw new ideas at the wall, turn them on for ourselves and then a small group of trusted customers and super quickly iterate until we have a feature that works well and that we can safely release to the rest of the world.

We mostly use frontend feature flags for this, so we'd only show the link in the menu or the specific component if the feature flag is turned on.

[0] https://posthog.com/docs/user-guides/feature-flags


👤 timothyfcook
Recently worked at a mid-sized learning technology company. Feature flags were transformative for our product delivery to fully decouple deploys from releases, reduce risk, and offer tons of control over feature rollouts. Really can't imagine releasing without them.

In my new role, I'm curious what teams do with feature flags post-release. Do you have a good process for cleaning them up? Do they have long term usefulness as a failsafe or for customer/user configuration? Is it really an issue if they just stay in the code forever? Does this cause issues for you?


👤 karka91
Our team uses them extensively. It's also tied to our A/B and QA testing infrastructure as it performs a similar function of "turn this/that on/off for these particular users". This enables us to do continuous deployment (dead/unfinished code goes to live all the time) and running QA for features on live infrastructure that has actual production loads.

It's also a life saver when issues arise, though the correct term for this is "operational toggles". Flip a switch when functionality is causing issues and it's gone.


👤 quaffapint
I know you said frontend, but we use them for both FE and BE. They work fine, but our problem comes with DB migrations. We just haven't found a good way to deal with DB changes and flags.

👤 gwbas1c
At my previous job we used them. Sometimes it was to enable/disable features for customers that were part of a beta program. These could eventually evolve to be controlled by ad admin as we rolled out the feature to all customers.

The product was a desktop file synchronization client. We had an API that we would get administer-controlled settings. Feature flags were usually part of that API.

We don't use them at my current job, but it's a much smaller company with many less customers.


👤 TeeWEE
Feature flags are core to CI/CD Darklaunches of features, slow rollouts, all require feature flags, or at least canary releases, slow rollouts using k8s

👤 preordained
Yes, we do, not in the way a lot of people are describing here (push without disruption, a/b testing). We deploy on prem applications that can be managed from the cloud, so when we add a new feature that involves said applications we have to observe which features the deployed application can use (til upgraded) and only display the appropriate ones from the cloud UI.

👤 eranation
We do, not sure if we do it "right", but we do have flags (both in the backend and frontend) to enable features only on "dev" while they are being worked-in-progress, this allows us to not delay pushing to prod. We also have feature flags in our infrastructure-as-code actually (we use CDK, a typescript based infra-as-code framework)

👤 rubyist5eva
Yes. It’s the only way we’ve found to be able to deliver large features in a timely manner without a giant push at the end before launch because all functionality is tested internally and delivered by deployed in a dark launch. Separating deployment from launch was one of the biggest improvements to our ability to deliver value to the business.

👤 zbuf
Yes, it mostly decouples "launch" of a feature from accidental side effects of it.

I find that reduces the peak/emergency workload; important for small numbers of developers.

Also aids in developing the whole codebase cohesively -- instead of "don't touch the core to add the new feature". Or trying to wrangle separate branches that have a dependency.


👤 CSDude
Old company used to because deployment after merge took a day with hundreds of developers deploying a monolith. 1/3 of the incidents were related to misuse of feature flags. It definitely has its places, but letting turn into a hammer to apply it everywhere is wasteful and risk. Totally depends on the application and customer base though.

👤 dhagz
Yeah, my team doesn't do anything terribly complex with them, but when I'm developing services I always throw in a command-line flag to toggle debug mode - ups the log level and serves pprof data using Go's net/http/pprof module. So it's not a user-facing feature, but we haven't run into that need yet.

👤 upbeat_general
Yes. So damn many of them (on backend, don’t deal with frontend).

Everything new is throttled and feature flagged. A new feature rollout can have 10+ throttles to slowly ramp up. And yes, they’re difficult to keep track at times.

What we don’t have (but should) is better management of who experiences which combination of flags, since they’re done randomly by default.


👤 GnarfGnarf
I use them in my desktop software. They are invaluable in helping transition to new features without sitting on the code and waiting weeks to merge, or forking the code which comes with its own set of headaches and problems.

They allow us to work on new code in the debug version, while insuring stability and continuity in the production code.


👤 throw10920
This reminds me of this 3-year-old post about Oracle Database[1], where too many flags were used. Or perhaps the developers were just bad? Or maybe it was the mixing in of macros?

[1] https://news.ycombinator.com/item?id=18442941


👤 swah
I have been doing something similar in my React Native apps - major features are enabled in a env.js variable:

    {
       EnableBackgroundSync: true,
       EnableDebugLog: false,
       ...
     }

This also ends up helping find different parts of code that are related in live in multiple modules (eww, I know)...

👤 danzdance
I think they are a necessary evil. I haven't seen a better mechanism to allow dynamic changes to production, but they come with a big downside for operations.

The problem with feature flags is that (assuming a flag can only be "on" or "off") once you introduce the flags you have 2^n different possible states the system can be in. When you have a bug or a crash, you have to reason about all of those states. If you have even 10 flags, that's over 1,000 combinations!

Does anyone have a different way of enabling "experiments" or quickly rolling back bad changes?


👤 lifeplusplus
Yes, we wanna test something that is really in production. We implement it that it's behind very hidden url and regular path is blocked with feature flag then at launch date you just mark true to false and the working thing just also becomes available at main url

👤 archeantus
I worked at the biggest retailer in the world and we used them a ton. They got even more useful once we built the concept of a versioned flag that would allow us to be true or false, depending on the app version we were on. That kind of flexibility is a must.

👤 marcus_holmes
No, never used them in the past, but I'd like to give them a try for my next project.

Anyone got any good guides for building a feature flag system from scratch? ( I'm not interested in just importing a dependency, I want to properly understand how this works)


👤 iliaznk
We do. We have one React app running on multiple instances that service different customers and not all customers need the same set of features. Some of features are only supposed to work on our staging instance until they're ready for production.

👤 graupel
Quite literally, we had a CMS that could have been named "FEATURE FLAG" - every single element of it was tucked away in it's own feature flag. Had upsides and downsides but we made it work.

👤 Glyptodon
We have them, but they're not that elegant and often add more complexity than it seems like they should. But they can be very useful/valuable. Just wish they created less complexity.

👤 gman2093
Seems like a lot of folks here and at spotify do, as do we at my gig. Where do you keep your feature flags? Do you have to perform a reset to update them or do you cache them for X minutes?

👤 NicoJuicy
Yeah.

It's almost a requirement to do continuous deployment and working without long living branches.

Don't forget to clean them up with you don't need one anymore. There's work involved with that too.


👤 buster
I used them in multiple projects and i'm constantly discussing the benefits with other teams. Implemented correctly (don't forget to remove them!), they are awesome.

👤 janglezz
All the time. We use Optimizely which allows us to roll features out to subsets of users and run experiments.

It also allows us to keep PRs smaller and roll stuff out to prod confidently.


👤 skillpass
Yes, use them on frontend, backend, and mobile. They feed into an AB experimentation system which is the gate for shipping features and catching regressions.

👤 dboreham
Yes. But you don't need a SaaS service for this: it's just a field in a table and a bit of code to parse the values you store there.

👤 palijer
Yeah. We use them to facilitate testing in production, and controlled rollouts for anything we lack confidence in.

👤 jsiaajdsdaa
Yes, it is good to have the ability to merge without being forced to deploy change x, but not blocking change y.

👤 lovetocode
No -- to me they are a code smell.

👤 Taylor_OD
No. I've never worked at a company that has uased them. But we probably should.

👤 Thristle
Yes. some features are just best tested incrementally

👤 itake
yes. Critical for rolling out features by country or region. Some teams even use them for i18n translations.

👤 gameswithgo
We use them a lot, but in my case mostly on the back end. We have a 24/7 service that runs and our customers depend on our service being up to make money. So if a new feature or change goes out that has any risk, we feature flag it so that if there are any problems we can flip the new feature off immediately rather than have to wait for a fix and deploy, or wait for a rollback.

Our feature flags are nice to work with in that you can just add them in code. If the flag doesn't exist in the DB, it is created with a default value. This makes them pretty painless to work with for us.

You can activate feature flags one server at a time as well to roll things out gradually if you want.

We have a simple web ui in our admin site where you can see them, what they are set to, when last updated etc. A good idea which we haven't done yet, is to log who changed it each time, and why as well.

Being able to find flags that haven't changed in a long time is useful to identify ones you can clean up.


👤 NikolaeVarius
The team uses them. Outside of looking for bugs I still have not been convinced that it is useful to check if blue versus green button has useful conversion rates.