What Is a Toggle?

The word toggle is both a verb and a noun; as a verb it means to change the state of something from one state to another. The noun refers to a pin passed through the eye of a fastener or other device to hold it in place. It is also a switch used in computers to enable different functions; for example, pressing the caps lock key toggles the function on or off.

As an architectural concept, toggles are meant to be a mechanism for making changes quickly and easily. Toggle switches should be intuitive to use, utilizing visual cues like movement and color to signal the current state of the switch. The use of high contrast colors and the inclusion of state descriptors are additional design choices that help users understand the functionality of a toggle.

Toggle configuration is best centralized in a single location to provide consistency and ease of modification across a fleet of servers. This will typically involve moving the toggles out of the static files and into some type of centralized store; often an application DB which is accessible to both system operators, testers and product managers. This will also likely include the build-out of an admin UI which can be used to modify and view feature flags and their configuration.

When a team releases a new version of their product it’s important that they test all the possible toggle configurations that could be active in production. This includes testing all of the toggles which are set to be flipped On plus all of the toggles which they plan to flip Off in the future. Many teams also choose to test a fallback configuration where all of the existing or legacy code is enabled; this allows them to assess how a potential release would perform in a live environment without having to re-deploy the product.

Toggles can be used for a variety of purposes within an organization from enabling A/B tests to providing data-driven optimizations for things like Call To Action wording or the order in which products appear on a site. To ensure that the most optimal experience is being delivered to a user it’s important that these experiments be conducted in a controlled manner and that the result of the experiment can be accurately measured. This is where a tool like Toggle can be especially valuable.

Toggle should be considered a valuable asset to an organization’s toolkit but with this power comes some complexity. Savvy teams recognize that each toggle they introduce has a carrying cost and seek to keep the number of toggles in their inventory low. They are proactive in adding a task to the team backlog for the removal of a Release Toggle at the end of a release cycle and they put “expiration dates” on their toggles; this will cause a test to fail (or even the application to refuse to start) if a toggle is still present after its expiration date.