How to Use and Manage Toggle Feature Toggles in a Modern Web Application
Toggle is a tool to enable data-driven decision making in complex software systems. Toggles allow us to configure a program with two distinct paths for execution and at runtime we can decide which path to follow. This allows us to make changes in an incremental way without having to redeploy the whole service. Toggles are a powerful tool and should be used sparingly. It is tempting to use them to cover large swaths of code but this can quickly become confusing and potentially create a nightmare to debug weeks or months down the road.
A toggle is a pin, rod or crosspiece fitted or inserted into a loop in a rope, chain or strap to prevent slipping, tighten or hold an attached object, as in the toggle of a ship’s anchor. It is also a term in electronics, computing, programming and other fields for an option that switches between states or options, as in the ability to toggle between screens during a video call.
This article explores how to use and manage feature toggles in a modern web application. It covers everything from basic questions about best practices for new teams right up to sophisticated use cases for advanced users.
The key thing to remember is that feature toggles are not a replacement for a robust distributed configuration system such as a CD/CI pipeline. It’s important to only toggle code that will be live in production, and test with all toggles flipped On so that you can see what the impact of your change will be on real users. It is also wise to test a fall-back configuration where the current production toggles are all flipped Off.