What Is a Toggle?

A toggle (pronounced tog-gle) is a hardware or software switch that turns a function on or off. For example, the caps lock and num lock keys on keyboards are toggle switches that turn specific functions on and off. The same concept is applied to many software applications with toggles enabling and disabling features in options menus. In Continuous Delivery environments, toggles allow engineering teams to test new features with a subset of users without impacting the whole product. They are an important tool for testing new features and improving user experience.

Toggles are used to perform Multivariate or A/B Testing on a small group of users, called a cohort. This is done by creating two code paths, one with a feature enabled and the other with the same functionality except disabled. The toggle routes the cohort through one or the other code path at runtime. This allows the team to observe which code path produces better user behavior and then deploy the winning code path to all users. This is a form of trunk-based development and it helps the team deliver improvements to their customers faster and more reliably.

Often, these feature toggles will be active for only a few days or weeks before they are retired. This prevents the accidental release of a feature that will cause major customer issues and is part of a safe practice known as blue-green deployment. It is best to avoid using feature toggles that control large swaths of the application, as it can be confusing for engineers and hard on customers if the toggle has unexpected consequences.

Another way to use feature toggles is as a circuit breaker for the whole application during periods of high latency. These toggles can enable or disable non-essential functionality for a period of time and provide the necessary stability while the engineer debugs the issue. These toggles can also be used to allow a certain cohort of users to access premium features when the business decides to enable them for those users.

For businesses, the ability to easily enable and disable reviews is crucial for their online reputation. Gating or hiding negative reviews is not only against Google’s Terms of Service, but it can also skew the overall rating for a business. Rather than hiding reviews, businesses should make it easy for customers to write a review and encourage them to do so while the experience is still fresh in their memory. This can help to improve ratings and increase customer satisfaction.