What the Hell are Feature Flags?

In recent years, Feature Flags have become an indispensable part of a lot of companies, but what are they?

Carlos Trujillo
JavaScript in Plain English

--

Good looking Asian man thinking
Photo by Afif Kusuma on Unsplash

Feature Flags go by many names — Feature Toggles, Feature Switches, etc. But regardless of the name, they all refer to the same development technique.
This development technique essentially allows you to turn features on and off at the run time, without changing the code, just by turning on and off a switch on a third-party provider (you can of course implement your own Feature Flag Service)

Diagram with three boxes, one for third party provider that connects to request box that connects to code base box
High level concept view of Feature Flags

Let’s take a closer look.

First, we would need to define our new Feature Flag in our third-party provider.

This would differ from one service to the other, but imagine something like this.

The word new feature next to a switch

Next, we would need to make a request in our code that checks whether or not our Feature Flag is on or off.

const isNewFeatureEnabled = await getFeatureFlagFromThirdParty(newFeature)

And then we would take one path or another based on the result of said request.

if(isNewFeatureEnabled){
newFunction()
} else {
oldFunction()
}

This provides a lot of advantages. Just by turning on and off a switch, we can execute one code or another.

Imagine you are now pushing new code to production, maybe a new Feature, with Feature Flags you can now feel much safer, should your new code cause the dreaded regression with just the turn of a switch you can go back to the way it was before.No need to rollback through complicated re-deploys.

And that’s just the tip of the iceberg, Feature Flag services come with many additional functionalities like being able to activate a code to a certain number of clients ( maybe you want to introduce the new Feature for just 10% of your user base), maybe you want to do A/B testing, etc.

Some of the best known Feature Flag providers are

GitLab

Logo for GitLab, an open DevOps platform
GitLab is an open DevOps platform

GitLab provides its own Feature Flag service, and there is a free tier option with up to 200 feature flags per self-managed project (50 for SaaS).

The fact that GitLab also provides many must-have features for handling your codebase makes it a very viable option and one that I would recommend for starting your journey with Feature Flags.

LaunchDarkly

Image that reads. Ship Fast. Rest easy. Get total control of your code to ship quicker, reduce risk, and reclaim your nights and weekends.
LaunchDarkly is specialized in FeatureFlag Management

LaunchDarkly provides an easy-to-use SDK for most languages.
As a company devoted to Feature Flags, they have a huge array of options when it comes to customization and the ability to add rules for segmenting who will your new feature be available to.

It does come at a cost, as their pricing is based on active users.

Pricing options. Starter comes at 10 dollars per month per user and PRO comes at 20 dollars per month per user.
Pricing options for LaunhDarkly

ConfigCat

Image of a cat as the ConfigCat logo
ConfigCat logo

ConfigCat is also one of the leading Feature Flag providers.
They do have a Free Tier option and then their pricing is a set monthly fee non-dependant on your organization users. Ah, and they even plant a number of trees depending on the option you choose.

They have a lot of features like targeted user segments based on region, email, subscription, or any other custom user attribute. And support % rollouts, A/B testing, and variations.

With these options plus the hundreds of Open Source projects out there, introducing Feature Flags in your next project should be a no-brainer.

Just think about how much better you will sleep at night thinking that rolling back your code is only one switch away!

More content at plainenglish.io

--

--

I love coding, music, films, video games, writing. Once upon a time I was a DJ who coded, now I’m a coder who DJs