Live data from Hacker News

It's OK to hardcode feature flags

code.mendhak.com

61–70 of 111 posts

Re: It's OK to hardcode feature flags

#61
Just put your flags in environment variables.

Depending on your infra, that can already make them toggleable without a redeployment: a restart of the apps/containers on the new envvars is enough.

Having them in a separate file would be useful if you need to be able to reload the flags upon receiving SIGUSR1 or something.

Re: It's OK to hardcode feature flags

#62
post #5

The single biggest value add of feature flags is that they de-risk deployment. They make it less frightening and difficult to turn features on and off, which means you'll do it more often. This means you can build more confidently and learn faster from what you build. That's worth a lot . I think there's a reasonable middle ground-point between having feature flags in a JSON file that you have to redeploy to change a…

Seriously. This is one of those cases where rolling your own really does make sense. Flags in a DB table, flags in a json file, all super simple to build and maintain, and 100x faster and more reliable than making the critical paths of your application's request cycle depend on an external provider.

We did this. Two tables. One for feature flags, with name, desc, id, enum (none, defaultToEnabled, overrideToDisabled). One for user flag overrides, with flagId, userId, enum (enabled, disabled).

The combination of these two has been all we've ever needed. User segmentation, A/B testing, pilot soft launch etc are all easy.

Re: It's OK to hardcode feature flags

#63
post #48

Earlier quoted context omitted.

How do you push the files to all of your containers? I’ve done this in the past with app specific endpoints but never found a solution I liked with containers.

We keep a JSON blob in Google Secret Manager for our flags. The service running in the container will reload the secret anytime it changes

Ah that’s a super nice feature. I’m mostly familiar with AWS who don’t have a neat way of doing this, you end up with a bespoke solution either with lambdas pushing to shared volumes or just polling s3 for updates.

Re: It's OK to hardcode feature flags

#64
post #5

The single biggest value add of feature flags is that they de-risk deployment. They make it less frightening and difficult to turn features on and off, which means you'll do it more often. This means you can build more confidently and learn faster from what you build. That's worth a lot . I think there's a reasonable middle ground-point between having feature flags in a JSON file that you have to redeploy to change a…

Why aren't you just using environment variables for feature flags? Have people still not bought into the whole 12 factor config things?

How do environment variables help? You still need something that knows what values to set the env vars to.

Re: It's OK to hardcode feature flags

#65
One sense of feature flag that I am familiar with (not from experience) is in trunk based development where they are used to integrate new code (with a feature flag) which is relatively untested. Or just not fully developed. That’s an alternative to longer-lived feature branches which are only merged until it is either fully finished or (going further) fully tested. Hard-coding that kind of feature flag makes sense. Because a later revision will delete the feature flags outright (removing the branches).

There also seems to be feature flags in the sense of toggling on and off features. Then hard-coding makes less sense.

Re: It's OK to hardcode feature flags

#66
There's a typo in the article:

>Hardoced feature flags

Think the author obviously meant "hardcoded" here.

Anyways, recently, this has been really hard to sell teams on in my experience. At some point "feature flag" became equivalent to having an entire SaaS platform involved (even for systems where interacting with another SaaS platform makes little sense). I can't help but wonder if this problem is "caused" by the up-coming generation of developers' lived experience with everything always being "online" or having an external service for everything.

In my opinion, your feature flag "system" (at least in aggregate) needs to be layered. Almost to act as "release valves."

Some rules or practices I do:

* Environment variables (however you want to define or source them) can and should act as feature flags.

* Feature flag your feature flag systems. Use an environment variable (or other sourced metadata, even an HTTP header) to control where your program is reading from.

* The environment variables should take both take priority if they're defined AND act as a fallback in case of detected or known service disruption with more configurable feature flag systems (such as an internal DB or another SaaS platform).

* Log the hell out of feature flags, telemetry will keep things clean (how often flags are read, and how often they're changed).

* Categorize your feature flags. Is this a "behavioral" feature flag or functional (i.e., to help keep the system stable). Use whatever qualifiers make sense for your team and system.

* Remove "safety" flags for new features/releases after you have enough data to prove the release is stable.

* Remove unused "behavior" flags once a year.

My $0.02

Re: It's OK to hardcode feature flags

#67
This statement is not true if your organization has very stringent deployment requirements or a release cycle that is measured in days rather than hours. If you can go from idea to deployment in under an hour, sure, you probably don’t need a fancy feature flag system. That’s not the case for a lot of organizations. Source: spent a really long time fixing agony caused by hardcoded feature flags.

Re: It's OK to hardcode feature flags

#68
post #60

Earlier quoted context omitted.

> using an (often expensive) feature flags as a service platform I have no idea why anyone would actually do that in real life. Feature flags are something so trivial that you can implement them from scratch in a few hours, tops — and that includes some management UI.

Add to that ideally feature flags should be removed after feature is released. Ideally also you shouldn’t have more than handful of feature flags. Permanent per customer configuration is not a feature flag. Also best would be not to have too many per customer configurations.

Feature flags are ofter initially for feature and later left in as dependency flags. Even within a large organization, individual components and services by other teams will have outages.

Re: It's OK to hardcode feature flags

#70

Earlier quoted context omitted.

Seriously. This is one of those cases where rolling your own really does make sense. Flags in a DB table, flags in a json file, all super simple to build and maintain, and 100x faster and more reliable than making the critical paths of your application's request cycle depend on an external provider.

You know what I would find worse than telling my customers that they can't access the application they paid for and works because I farmed my auth out to a 3rd party that is having an outage? Telling them that my auth provider isn't out, but the thing I use to show them a blue button vs a red button is. Oof.

Has this actually been a problem? We’ve been using launch darkly for years and if they do have an outage (which is really really rare) the flag will be set to the default value. It’s also very very cheap, maybe $500 a month.
Post reply on HN