HACKER Q&A
📣 hahnbee

How did you build feature flags?


I'm building feature flags and I feel like architecture decisions for this is a solved problem and would love to hear anecdotes. How did you go about building feature flags at your company?


  👤 3pt14159 Accepted Answer ✓
I work for Flagsmith these days, but formerly I was in charge of managing a lot of Trust and Safety related concerns for Clubhouse. This involved deleting a lot of records to appease regulators and creating custom features to handle stuff like CSAM and we used a lot of feature flags there to keep systems safe in case of an event.

The most important architectural decision that we made was pushing some of the feature flagging into the software layer. So, for example, every task had a module name and a task name that together would form the feature flag name. So out of the box any task could be disabled without adding further code. Combined with other good practices it went a long way. Another good option is to enable local evaluation mode[0] which allows a balance between keeping your feature flags up to date while avoiding API calls frequently.

[0] As an aside, I've worked on the implementation of local evaluation mode for one of our clients (I think Python?) at Flagsmith.


👤 worddepress
Easiest way is a DB entry / Environment Variable / Config that turns a feature on and off, some central class/object that reads it and is a source of truth and a bunch of "if" statements in the right place to hide the feature and make it unavailable via APIs if turned off.

👤 throwaway38375
Choosing a good solution heavily relies on whether your product is multi-tenant or not.

If multi-tenant things get complicated quite quickly. It may be worth looking into existing packages/libraries for your stack. I would be careful about using a third party service for this due to the latency it may introduce.

If not then just have a FEATURES constant. The value can be as primitive as an associative array, dict, hashmap, or struct. The keys are your flags and their values are booleans.

Not your forever choice, but very simple, quick, and easy to use.


👤 rtcoms
For Ruby on Rails there is: https://github.com/flippercloud/flipper

👤 lonelydriver77
Disclaimer: I work at Amplitude, where we offer a feature flagging and experimentation platform

Hey hahnbee, I echo a bunch of other folks sentiment that local evaluation mode is pretty important so you’re not constantly making network calls to figure out the state of your flags, that’s one of the biggest things.

The other thing I’d add is that it’s pretty important (esp as a homegrown system) to build user tracking into your flags so you know that for a given flag, which user saw which version at what time. This is so critical for debugging and issue resolution so you’re not left guessing (and doubly important for experiments where you want to run stats on different populations).

You probably will not be surprised to find out that we have this stuff built into our system, and that you can get started with our flags for free! So here’s my shameless plug to head over to Amplitude.com and check out our stuff


👤 willcipriano
If you don't need per customer configuration just throw it all in a configuration file and call it a day.

👤 bullcitydev
We at https://flipt.io are putting on a buy vs build webinar in a couple of weeks to discuss this very thing as it's a common question that engineering teams seem to have.

If you're interested in attending its taking place on LinkedIn on April 17: https://www.linkedin.com/events/buildvs-buy-pickingafeaturef...


👤 omgbear
I'm pretty happy with our setup, though we use flags mostly for feature releases and only have a few long-lived ones.

State kept in a database table indexed on customer. One row per customer/flag name, only there when the flag is set.

We keep active flags names as constants and put into an array for easy looping in our admin ux. This makes it easy to find usage and clean them up after launch.

These are passed to the browser so the frontend can check flags, and via grpc context to any downstream services.


👤 user7878
We have below setup.

There are Global, Org, Store, User level settings type of each. User has the highest priority over others and values are read of highest to least priority and one final set of flags are fetched. When page loads we fetch them from cache(Browser + Backend - Redis) OR DB.

This works well with two tables in DB, CRUD APIs, UI for settings on various level.


👤 jameshush
Don't build this in-house if you can help it.

I worked at an adtech company that had our own feature flag system built. Absolute pain to work with. To be fair, it had been built 6 years prior, and I worked there 4 years ago, so there were less off the shelve solutions at the time.

Switched to a company that used an off the shelve solution and it was 100x easier to work with.


👤 solardev

👤 aristofun
I don't think there can be 1 fits all solution. Feature flag is at its core is nothing but a piece of your product code.

There are millions variants to implement a product, even within the same environment/infra constraints.

If you elaborate your specific goals and products - that may be a very fruitful topic.


👤 giaco_hendel
Depending on you use-case you can also use https://vykee.co for this (project of mine) – setup is <5mins. Let me know if you need help.

👤 spiderfarmer
Laravel has it built in.

👤 taf2
Redis sets or hash’s work well