Feature Flags (aka Feature Toggles)

What are Feature Flags?

Feature flags (aka feature toggles or feature switches) are a technique used in software development, where specific features are wrapped in a conditional block of code that can be remotely toggled on or off.

Why Use Feature Flags?

There are many use cases for feature flags when building an app or software service:

Kill Switch

Because feature flags can be toggled on or off without the need for a code deployment, feature toggles are a great way to reduce the risk of new features introducing bugs into your software. If a bug is discovered in a block of code that is wrapped in a feature flag, it can quickly and easily be disabled without having to go through a lengthy code push or app store deployment.They can even be toggled on/off by non-technical members of a development team such as product managers by editing a config file or toggling the feature off via a GUI interface in feature management software such as Optimizely or LaunchDarkly.

Phased Rollouts

In addition to protecting your code, feature flags can be used to do a gradual feature rollout to a percentage of your user base, rather than rolling out a new feature to 100% of your users at once. This again helps limit the risk of feature deployment, not just of bugs but of features that may create a negative experience to your users. You can start with a small percentage of your traffic first, and roll out the feature to more users as you gain real world data about how it is performing.

Rolling out a feature to a small subset of your users in order to suss out any potential issues is known as a canary test or canary release.

Targeted Rollouts

Closely related to phased rollouts are targeted rollouts. With targeted rollouts you can specify a specific segment of your audience that you want to deploy a feature to. For example, you could launch a feature to only users in the US, for example. This can be used in conjunction with phased rollouts, so that only a percentage of the target audience sees a feature.

Targeted rollouts can also be used for feature gating, so for example if your software product or app has multiple tiers, you can release certain features that are only available to users who are at a certain tier (enterprise vs free plan, for example).

A/B Testing

Another benefit of feature flags is that it can be used to run A/B tests. With A/B testing, you show different users a different experience and see how that impacts how they behave for a given metric. This can be easily be implemented via targeted & phased rollouts.

For example, say you are a retailer that wants to increase sales of men’s shoes on your website. You could create a new shoe-picker feature, and release it as a targeted rollout to your male users. You can then do a phased rollout so that 50% of your users see the old experience, and 50% see the new one. Then you can collect data for a few days and see which one lead to more sales, before deciding if you want to rollout the experience to all your users. Leading tech companies such as Google, Facebook, and Netflix continually A/B test new features to create the best user experience for end users.

Continuous Delivery

Feature flags are often also used as a part of the continuous integration/continuous delivery (CI/CD) development process. CI/CD is a devops technique which involves introducing automation to various stages of the deploy process, and making it easier and safer for developers to deploy new code to the production environment. Use of feature flags as part of this process can make it easier to integrate code into a shared repository (such as Github) and roll back problematic features with minimal effort.

Trunk Based Development

Another use case for feature toggles is in trunk based development (TBD). In TBD, code is continually integrated into the main trunk rather than creating a series of feature branches which can lead to merge conflicts and other issues. Feature flags can help facilitate more frequent code changes by limiting the blast radius of source code for new features.

Free Feature Flagging

If you are looking to get started with implementing feature flags in your software, I recommend checking out Optimizely Rollouts, which provides free feature toggles and A/B testing capability. Disclaimer: I work at Optimizely, but I’m confident this is best free feature flagging tool out there, and it’s trusted by some of the largest companies in the world.

Let me know in the comments if you have any questions about feature flags!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.