Feature toggle

Published date: April 15, 2024, Version: 1.0

Overview

Feature toggle is a capability to enable/disable a codepath at runtime without deploying new code and control what business features are turned on/off.

 

General Principles

  • Toggles should have short lifespan

  • Name toggles well

  • NEVER reuse the toggle for different features (except epic toggles)

  • Always toggle OFF unsafe codes

  • Monitor toggles (Don’t forget to clean up the toggles, remove dead code)

  • Apply branch by abstraction whenever it possible

Branch by abstraction

Branch by Abstraction is a development technique that implies that you do a task gradually and release the application at the same time

Abstraction

Branch by Abstraction relies on a set of rules. There are 5 steps (some glue them up to 4)

1. Introduce an abstraction.

2. Create a new implementation.

3. Turn on for yourself, turn off for others.

4. Work on the new implementation step by step.

5. Remove the old implementation.

Toggle Types

Release Toggle

A release toggle is embedded into the codebase that keeps the feature code inactive. So instead of creating a feature branch, the dev team can write a single new feature. Release toggles are temporary elements in a codebase, so their lifecycle is only up to a couple of weeks.

On production this toggle can be used for turn ON feature with some delay.

Experimental Toggles (Sub type of Release Toggle

These toggles are mainly used for testing purposes. The toggle splits the user base into different segments to expose an isolated segment to the new feature. The usage data for the segmented users are used to infer the effect of the new feature. As it’s only used for testing purposes, the toggles can be removed once the testing is done.

Operational Toggles

Operational toggles are comparatively more permanent in some cases. They are used to turn an operation on or off - generally used while coding a new feature. The longevity of the operational toggle can be different for different use cases. They can either be static or dynamic, as the core operational conditions can vary depending on the functions it regulates.

Permission Toggles

Permission toggles, as the name suggests, release a feature only to a user who has permission to access them. A simple example is using permission toggles for premium features, making sure only premium users can access them. They are meant to be more permanent and also are more dynamic compare to the other four.

1. Compile :

  • get value during compilation, for example turn on sql profiler…

2. Startup :

  • read configuration file on startup

3. Periodic :

  • background process to check and update the state each N minutes

4. Activity :

  • check actual state of toggle during logic execution, for example in each request
Flexibility

Compile and Startup toggles not supports runtime updates, requires application redeployment/restart. Periodic and Activity toggles support runtime updates, not requires application redeployment or restart.

Toggle benefits 

  1. A/B Testing
    An A/B test is a split testing methodology that hosts two versions of a feature. The traffic is segmented into two groups, each shown to a version of the feature. Here a feature toggle can be used such that if the toggle is turned “on” the user segment will view the A version of the feature and if it’s turned “off” the user segment can experience the B version. A/B testing is a popular testing technique in software development that allows to test variations of codes and get a common consensus on how they are received by the users.

  2. Canary Deployment
    Canary Deployment deployment is also a testing method that is a risk-averse way of testing where only the new feature version is released to only a small subset of users. Feature toggles can be used for this deployment method as well. Since the process of canary testing is meant to test bugs in the code, if during testing the dev team encounters any errors they can simply roll back the feature by turning the toggle off. Dev teams can also make use of feature toggles to acquire data and work deriving insights from them.

  3. Trunk Based Deployment
    Trunk Based Deployment is a software development strategy where new code or features is added to the main codebase or ‘trunk’ instead of creating multiple feature branches. Feature toggles can be incorporated in deploying this strategy, as it enables rapid deployment and roll back just by using a toggle switch.

  4. Feature Toggle as a ‘Circuit Breaker’
    The ON/OFF switch mechanism of a feature toggle can work as a circuit breaker mainly for the purpose of maintainability and recovering from failures. If a feature exhibits major glitches it can simply be turned off breaking its running circuit.

Adoption expectations

 Adoption expectations

System Components  MVP MVP+

Branch by abstraction

+

+

Compile-type toggles

+

+

Startup-type toggles

+

+

Periodic-type toggles

+

+

Activity-type toggles

 

+

Centralized feature toggle solution

 

+

 

Tools

Functionality Tool Name

Documentation Collaboration

Atlassian Confluence

Architecture design tools

Microsoft Visio, Draw.io, Miro, Lucidchart, Archi

3rd party SAAS feature toggle solutions

LaunchDarkly, Azure App configuration, Optimizely, ConfigCat, Flagship, Split

 

Roles

Name  Responsibilities 

Scrum Master/Team Coach

Coach and support usage feature toggle techniques for complex time consuming activities

Solution Architect

Design solution to support feature toggle

System Architect

Design systems to support feature toggle

Product Owner

Prioritize features and refine toggle states

Developer

Adopt feature toggle techniques and process to embrace small incremental changes

Build Engineer

Integrate automated release and deployment process