knowledge-base

Feature Toggles

Note: Also known as Feature Flags.

These are not necessarily architecture domain specific, but they allow for a smooth transition in evolutionary architecture. Especially the operational toggles require maybe some architectural consideration if they make sense.

The following part is basically a summary of this awesome Martin Fowler Entry by Pete Hodgson.

Why Use?

Categories

It can be tempting to lump all feature toggles into the same bucket, but this is a dangerous path. The design forces at play for different categories of toggles are quite different and managing them all in the same way can lead to pain down the road. It can be tempting to lump all feature toggles into the same bucket, but this is a dangerous path. The design forces at play for different categories of toggles are quite different and managing them all in the same way can lead to pain down the road.

See Diagram

Type Description Lifespan Dynamism
Release Allow incomplete and un-tested codepaths to be shipped to production as latent code which may never be turned on, allowing for trunk-based development of larger features and user stories. Short - Days, Weeks

Release Toggles are transitionary by nature. They should generally not stick around much longer than a week or two.
Typically Static

Changing that toggle by rolling out a new release with a toggle configuration change is usually perfectly acceptable.
Experiment Used to perform multivariate or A/B testing. Each user of the system is placed into a cohort and at runtime the Toggle Router will consistently send a given user down one codepath or the other, based upon which cohort they are in. Commonly used to make data-driven optimizations Short - Hours, Days, Weeks

An Experiment Toggle needs to remain in place with the same configuration long enough to generate statistically significant results. Longer is unlikely to be useful, as other changes to the system risk invalidating the results of the experiment.
Highly Dynamic

Each incoming request is likely on behalf of a different user and thus might be routed differently than the last.
Operational Control operational aspects of our system’s behavior.

Example: rolling out a new feature which has unclear performance implications so that system operators can disable or degrade that feature quickly in production if needed.
Short to Long - Weeks, Months, Years

Once confidence is gained in the operational aspects of a new feature the flag should be retired. However it’s not uncommon for systems to have a small number of long-lived “Kill Switches” which allow operators of production environments to gracefully degrade non-vital system functionality when the system is enduring unusually high load.

These types of long-lived Ops Toggles could be seen as a manually-managed Circuit Breaker.
Dynamic

The purpose of these flags is to allow operators to quickly react to production issues they need to be re-configured extremely quickly.
Permission Used to change the features or product experience that certain users receive. A Canary Released feature is exposed to a randomly selected cohort of users while a Champagne Brunch feature is exposed to a specific set of users. Long - Months, Years

When used as a way to manage a feature which is only exposed to premium users a Permissioning Toggle may be very-long lived compared.
Highly Dynamic

Each incoming request is likely on behalf of a different user and thus might be routed differently than the last.

Static vs Dynamic Toggles

Long lived vs Short Lived Toggles

Implementation Techniques

Feature Flags seem to beget rather messy Toggle Point code, and these Toggle Points also have a tendency to proliferate throughout a codebase.

Toggle Configuration

Working with feature-flag systems

While feature toggling is absolutely a helpful technique it does also bring additional complexity. There are a few techniques which can help make life easier when working with a feature-flagged system.

Governance

Governance can be defined as the establishment of policies around the how/what/why/when of your feature flag implementation.

Resources