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?
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)
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.
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
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
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.
ConfigCat
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