Recent from talks
Contribute something
Nothing was collected or created yet.
Feature toggle
View on WikipediaThis article may contain excessive or inappropriate references to self-published sources. (May 2022) |
A feature toggle in software development provides an alternative to maintaining multiple feature branches in source code. A condition within the code enables or disables a feature during runtime. In agile settings the toggle is used in production, to switch on the feature on demand, for some or all the users. Thus, feature toggles do make it easier to release often. Advanced roll out strategies such as canary roll out and A/B testing are easier to handle.[1][2]
Continuous delivery is supported by feature toggles, even if new releases are not deployed to production continuously. The feature is integrated into the main branch even before it is completed. The version is deployed into a test environment once, the toggle allows to turn the feature on, and test it. Software integration cycles get shorter, and a version ready to go to production can be provided.[3]
The third use of the technique is to allow developers to release a version of a product that has unfinished features. These unfinished features are hidden (toggled) so that they do not appear in the user interface. There is less effort to merge features into and out of the productive branch, and hence allows many small incremental versions of software.[4]
A feature toggle is also called feature switch, feature flag, feature gate, feature flipper, or conditional feature.
Implementation
[edit]This section needs additional citations for verification. (October 2016) |
Feature toggles are essentially variables that are used inside conditional statements. Therefore, the blocks inside these conditional statements can be toggled 'on or off' depending on the value of the feature toggle. This allows developers to control the flow of their software and bypass features that are not ready for deployment. A block of code behind a runtime variable is usually still present and can be conditionally executed, sometimes within the same application lifecycle; a block of code behind a preprocessor directive or commented out would not be executable. A feature flag approach could use any of these methods to separate code paths in different phases of development.
The main usage of feature toggles is to avoid conflict that can arise when merging changes in software at the last moment before release, although this can lead to toggle debt. Toggle debt arises due to the dead code present in software after a feature has been toggled on permanently and produces overhead. This portion of the code has to be removed carefully as to not disturb other parts of the code.
There are two main types of feature toggle. One is a release toggle, which the developer determines to either keep or remove before a product release depending on its working. The other is a business toggle, which is kept because it satisfies a different usage compared to that of the older code.
Feature toggles can be used in the following scenarios:[1]
- Adding a new feature to an application.
- Enhancing an existing feature in an application.
- Hiding or disabling a feature.
- Extending an interface.
Feature toggles can be stored as:[5]
- Row entries in a database.
- A property in a configuration file.
- An entry in an external feature flag service.
Feature groups
[edit]Feature groups consist of feature toggles that work together. This allows the developer to easily manage a set of related toggles.[6]
Canary release
[edit]A canary release (or canary launch or canary deployment) allows developers to have features incrementally tested by a small set of developers. Feature flags are an alternate way to do canary launches[7] and allow targeting by geographic locations or even user attributes.[8] If a feature's performance is not satisfactory, then it can be rolled back without any adverse effects.[9] It is named after the use of canaries to warn miners of toxic gases (Miner's canary).
Adoption
[edit]Martin Fowler states that a release toggle, a specific type of feature toggle, "should be your last choice when you're dealing with putting features into production". Instead, it is best to break the feature into smaller parts that each can be implemented and safely introduced into the released product without causing other problems.[2]
Feature-toggling is used by many large websites including Flickr,[10] Disqus,[11] Etsy,[12] Reddit,[13] Gmail[14] and Netflix,[15] as well as software such as Google Chrome Canary or Microsoft Office.[16]
See also
[edit]References
[edit]- ^ a b "ALM Rangers - Software Development with Feature Toggles". msdn.microsoft.com. July 2015.
- ^ a b Martin Fowler 29 October 2010 (2010-10-29). "FeatureToggle". Martinfowler.com. Retrieved 2013-09-27.
{{cite web}}: CS1 maint: numeric names: authors list (link) - ^ How GitHub Leverages Feature Flags to Ship Quickly and Safely, infoq, 2021-05-09.
- ^ Programming JavaScript Applications. Archived from the original on 2016-09-15. Retrieved 2016-09-14.
- ^ Echagüe, Pato (2014). Managing Feature Flags. O'Reilly Media. ISBN 9781492028598.
- ^ Elliot, Eric (2018). Programming JavaScript Applications. O'Reilly Media.
- ^ "How to do Canary Release / Progressive Delivery with ConfigCat | ConfigCat Blog". configcat.com. 2022-02-09. Retrieved 2022-12-22.
- ^ "Canary Testing - Using Blue-Green Deployments and Feature Flags". unlaunch.io. 26 February 2021. Retrieved 14 August 2021.
- ^ "Canary launches – how and why to canary release". launchdarkly.com. 7 April 2015. Retrieved 9 January 2017.
- ^ Harmes, Ross. "Flipping Out - code.flickr.com". flickr.net. Retrieved 9 January 2017.
- ^ dcramer (July 9, 2010). "Partial Deployment with Feature Switches". Archived from the original on 2013-11-05. Retrieved 2013-10-10.
- ^ "How does Etsy manage development and operations?". codeascraft.com. 4 February 2011. Retrieved 9 January 2017.
- ^ "reddit/reddit". github.com. Retrieved 9 January 2017.
- ^ "Developing Gmail's new look". googleblog.com. Retrieved 9 January 2017.
- ^ "Preparing the Netflix API for Deployment". netflix.com. Retrieved 9 January 2017.
- ^ Wolfe, Mike (2022-05-30). "Office FeatureGates: How Microsoft Can Break and Fix Their Applications in Under 24 Hours". nolongerset.com. Retrieved 2024-08-27.
Feature toggle
View on GrokipediaDefinition and Purpose
Core Concept
A feature toggle, also known as a feature flag or feature switch, is a programmable conditional statement embedded in software code that enables or disables specific functionality at runtime without necessitating a new code deployment or the use of version branching.[1][4][5] This technique allows developers to include new or experimental code paths in a single deployable artifact while controlling their activation dynamically, thereby supporting safer and more flexible software releases.[1][6] The primary purposes of feature toggles include decoupling the release of features from the deployment of code, which facilitates continuous integration and continuous delivery (CI/CD) pipelines by allowing teams to ship code more frequently without exposing unfinished work to all users.[1][5] They also enable enhanced testing strategies, such as gradual rollouts to subsets of users, and permit runtime adjustments to system behavior in response to operational needs or feedback.[4][6] By providing these capabilities, feature toggles reduce deployment risks and accelerate the software development lifecycle.[1] In terms of basic mechanics, feature toggles are typically evaluated during execution using external sources such as configuration files, databases, or dedicated services that determine the toggle's state.[1][5] Simple implementations might rely on boolean flags that switch between code paths, while more advanced ones incorporate rules based on contextual factors like user attributes, geographic location, or percentage-based sampling.[4] This runtime evaluation ensures that the same codebase can behave differently across environments or users without requiring recompilation or redeployment.[6] Feature toggles differ from general configuration settings, which primarily adjust parameters or values, by specifically controlling the execution of distinct code paths for entire features, offering finer-grained behavioral modulation.[1][5] They represent an evolution from traditional practices like maintaining multiple version branches in source control, which often led to merge conflicts and integration challenges, by instead promoting trunk-based development where all changes coexist in a unified codebase.[1][4]Historical Development
Feature toggles emerged in the early 2000s amid the rise of agile software development practices and the initial stirrings of DevOps, primarily as a response to the challenges of maintaining multiple branches in version control systems such as Subversion and later Git, which often led to complex merges and integration issues.[7] Developers began using simple conditional statements in code to hide unfinished features during deployments, enabling continuous integration without exposing incomplete work to users. This approach aligned with agile principles outlined in the 2001 Agile Manifesto, emphasizing iterative delivery and adaptability.[8] The concept gained prominence through Martin Fowler's influential 2010 bliki post on "Feature Flag," which formalized feature toggles as a technique for decoupling deployment from release, allowing teams to ship code rapidly while controlling feature activation at runtime.[9] Adoption accelerated throughout the 2010s alongside the maturation of continuous integration and continuous delivery (CI/CD) pipelines, as tools like Jenkins and GitHub Actions made frequent, low-risk releases feasible. By the mid-2010s, companies such as Google integrated internal feature flag systems into products like Google Maps and Chrome for experimentation and gradual rollouts, while Netflix employed them for A/B testing in client applications.[10][11] Post-2015, the shift toward cloud-native architectures, spurred by the formation of the Cloud Native Computing Foundation, further propelled feature toggles from rudimentary in-code if-statements to advanced platforms supporting A/B testing, personalization, and dynamic configuration.[12] Dedicated services like LaunchDarkly (founded 2014) and Split.io (founded 2015) emerged to centralize management, reducing manual overhead.[13][14] Around 2018, the industry transitioned toward automated toggle management, with tools enabling real-time adjustments and integration with observability systems, as evidenced by widespread adoption in microservices environments.[11] By 2023, these platforms had become standard for enterprise-scale feature control, exemplified by Netflix's use in rolling out profile transfer features.[11] In the early 2020s, efforts toward standardization emerged, including the OpenFeature project, an open specification for vendor-agnostic feature flagging under the Cloud Native Computing Foundation. Additionally, in May 2024, Harness acquired Split.io, further integrating feature management into broader DevOps platforms. As of 2025, feature toggles continue to evolve with AI-driven optimizations and enhanced interoperability.[15][16][11]Types of Feature Toggles
Release Toggles
Release toggles, a specific category of feature toggles, enable teams to deploy incomplete or untested code paths to production environments as latent functionality that remains disabled until activation is deemed appropriate. This approach supports trunk-based development practices in continuous delivery pipelines by allowing developers to merge in-progress work into the main codebase without immediately exposing unfinished features to end users.[1] The primary purpose of release toggles is to decouple the deployment of code from the release of features, thereby facilitating faster development cycles while mitigating risks associated with unstable implementations. For instance, they are commonly used in dark launches, where code for a new feature is pushed to production but kept hidden from users, ensuring that the system can be tested in a live environment without impacting the customer experience. Additionally, release toggles allow organizations to maintain multiple versions of a feature within the same codebase, such as enabling a new shipping date calculation for a specific partner while keeping the legacy version active for others.[1] In terms of lifecycle, release toggles are inherently short-lived and transitionary, often persisting for only a week or two until the associated feature stabilizes and requires no further conditional logic. Once the feature is fully ready, the toggle must be removed or refactored to prevent the accumulation of technical debt, as lingering conditional code can complicate maintenance and increase cognitive load on the development team. Decisions to flip a release toggle are typically static and require a new code deployment to update the configuration, emphasizing their role in controlled release management rather than dynamic runtime adjustments.[1] A practical example involves a software team developing a new algorithm for spline reticulation in a simulation game; the toggle permits the unfinished code to be merged into production early for integration testing, but it is only activated after quality assurance verifies its readiness, ensuring seamless rollout without disrupting ongoing gameplay.[1]Experiment Toggles
Experiment toggles, also referred to as experimentation flags, are a type of short-lived feature toggle specifically designed to direct subsets of users to alternative variants of a feature, allowing for controlled comparisons that inform data-driven decisions about feature effectiveness.[1] Unlike static deployment aids, these toggles enable ongoing testing by assigning users to cohorts at runtime, such as splitting traffic between a baseline version and a modified one to measure differential impacts on user behavior.[17] This approach facilitates iterative optimization without disrupting the broader user base, supporting the validation of hypotheses around feature performance through empirical evidence.[18] Key components of experiment toggles include configurable percentage-based rollouts, where, for instance, 10% of users might be routed to variant A while the remaining 90% experience the control, enabling gradual exposure and risk mitigation during tests.[17] Integration with analytics platforms is essential, as these toggles often connect to tools that capture metrics such as conversion rates, session duration, or error rates, providing real-time data streams for analysis.[18] Variant definitions, including weights and optional payloads like JSON configurations, further allow precise control over how features are presented to different groups.[17] Common use cases for experiment toggles involve A/B testing of new algorithms, such as comparing sorting methods in e-commerce search results, or evaluating design changes like button placements to assess engagement lifts.[18] Multivariate experiments extend this by simultaneously testing combinations of variables, such as UI elements and content recommendations, to isolate the influence of each on outcomes like user retention.[1] These applications are particularly valuable in dynamic environments like web applications, where rapid iteration on user experiences drives product evolution.[17] Evaluation of experiment toggle results relies on statistical criteria to ensure reliability, with a common threshold being a p-value less than 0.05, indicating that observed differences between variants are statistically significant and not attributable to random variation.[19] Platforms like Optimizely incorporate dedicated stats engines to compute these metrics, automating checks for significance while accounting for factors like sample size and baseline variability.[18] Upon reaching significance, successful variants can be scaled via the same toggle infrastructure, promoting efficient transition from experimentation to full adoption.[17]Operational Toggles
Operational toggles, also known as ops toggles, are feature flags designed to control non-feature-related aspects of system behavior, such as performance optimization, error handling, and resource management, without requiring code changes or redeployments.[1][20] These toggles enable operators to dynamically adjust runtime configurations, like switching logging levels or activating circuit breakers, to maintain system stability and respond to operational demands in real time.[5] Their primary purpose is to facilitate graceful degradation during incidents, mitigate risks from uncertain performance impacts, and support quick interventions that enhance overall reliability.[1][21] A key characteristic of operational toggles is their frequent evaluation, often on a per-request basis, to ensure responsive system adjustments, distinguishing them from less dynamic flag types.[5] While many are intended as short-lived mechanisms—lasting days to weeks for specific transitions—others, such as persistent kill switches or circuit breakers, can remain semi-permanent to handle recurring operational needs.[20][1] They are typically integrated with monitoring tools for automated triggering, allowing seamless reconfiguration without interrupting service.[5] Common use cases include disabling resource-intensive components during peak loads to prevent overload, such as turning off a computationally expensive recommendations panel on a website's homepage.[1] Another application is enabling debug modes or adjusting log verbosity for troubleshooting production issues without deploying new code.[5] For instance, during high-traffic events like sales periods, operational toggles can serve as circuit breakers to deactivate non-essential functionalities, thereby conserving resources and maintaining core service availability.[21] Additionally, they support backend switches, such as toggling between primary and secondary database instances based on availability metrics, ensuring continuity during failures.[20] In library upgrades, these toggles allow testing new implementations in live environments by routing traffic progressively, retiring the flag once stability is confirmed.[5]Permission Toggles
Permission toggles, also known as permissioning or entitlement toggles, are a type of feature flag designed to control access to specific features based on user attributes, roles, or criteria such as user ID, geographic location, or subscription level.[1][22] These toggles enforce feature visibility or functionality selectively, enabling product personalization by tailoring experiences to individual users or segments while ensuring compliance with regulatory requirements.[23][22] Unlike broader release mechanisms, they focus on granular access enforcement, often remaining active long-term to manage ongoing user entitlements.[1] The core logic of permission toggles typically involves boolean evaluations or advanced matching rules, such as checkingif user.premium == true or evaluating user roles against predefined segments.[1][24] These decisions are made dynamically on a per-request basis, leveraging user context from sources like HTTP headers or cookies to determine access.[1] Integration with identity providers, such as Auth0, allows toggles to pull real-time user attributes for accurate targeting, ensuring seamless enforcement across applications.[25][23]
Common use cases include granting beta access to select internal or early-adopter users through targeted activation, often termed "Champagne Brunch" for privileged previews.[1] Another application is regional feature gating to comply with regulations like GDPR, where toggles disable data-processing features in restricted geographies to avoid legal violations.[22] For subscription-based services, they unlock premium functionalities only for eligible tiers, such as advanced analytics for gold-plan users, thereby supporting monetization and user segmentation.[23]
Security is paramount for permission toggles, as unauthorized access could expose sensitive features or data. To mitigate risks, toggle states should be encrypted in transit and at rest, with cryptographic signing recommended for client-side overrides like cookies to prevent tampering.[1][22] Auditing changes and restricting administrative access further ensure integrity, particularly when integrating with external systems for user verification.[23]
Implementation
Technical Mechanisms
Feature toggles are fundamentally implemented through conditional logic embedded directly in the application code, allowing developers to enable or disable specific functionalities at runtime without altering the codebase. A common pattern involves using if-statements to check the toggle's state before branching execution; for example, in Java or JavaScript, code might readif (featureToggle.isEnabled("newLogin")) { newLoginImplementation(); } else { legacyLogin(); }, where featureToggle.isEnabled queries the current state of the named toggle. This approach ensures that the new code path is isolated and can be toggled off if issues arise. The toggle state itself is decoupled from the code and stored externally to support dynamic configuration changes. Options include simple configuration files in formats like YAML or JSON for static environments, relational databases for centralized storage with administrative updates, or distributed caches like ZooKeeper or Consul to synchronize states across clustered application instances in real-time.[1]
Advanced architectures for feature toggle evaluation balance latency, security, and scalability by distributing the evaluation process across client and server components. Client-side evaluation, integrated via SDKs in frontend or mobile applications, fetches flag configurations and performs decisions locally on the user's device, leveraging techniques like streaming updates or polling to achieve sub-millisecond latency and reduce backend load during high-traffic scenarios. This is particularly effective for single-user contexts, such as web browsers or apps, where real-time personalization enhances user experience without round-trip delays. However, client-side setups operate in untrusted environments, limiting exposure of sensitive rules to prevent tampering. Server-side evaluation, conversely, occurs on trusted backend infrastructure, where SDKs cache the complete ruleset and evaluate flags based on incoming requests, prioritizing security for multi-tenant systems by shielding logic from end-users and supporting complex, sensitive targeting. Hybrid models incorporate edge computing through CDNs like Akamai or Cloudflare, evaluating flags at network edges to combine client-side speed with server-side governance, ideal for global applications requiring both low latency and compliance.[26]
This distinction between server-side and client-side evaluation has practical implications for the speed of disabling features across platforms. On web platforms, server-side toggles allow companies to disable features almost immediately, often overnight, without requiring client-side updates. For instance, in December 2025, xAI removed the model selector feature for its Grok AI from the website, switching users to abstract modes like Auto or Fast, which was achieved quietly via server-side changes. In contrast, mobile apps, even with server-side flags, may experience delays in fully removing or updating features due to app store approval processes required for code changes, potentially prolonging the availability of prior configurations until users update their apps. This enables web platforms to respond more rapidly to issues or strategic decisions compared to mobile environments, where feature flags still provide quick server-side hiding but not complete removal without redeployment.[27][28][29]
At the core of these architectures lie evaluation engines, which apply sophisticated rule-based systems to determine flag outcomes dynamically. These engines process contexts—such as user IDs, attributes, or segments—using logical operators like AND (requiring all clauses in a rule to match) and OR (evaluating rules sequentially until the first match). The process typically begins with prerequisite checks for dependent flags, followed by individual targeting rules with operators (e.g., in, lessThan, or segmentMatch), and concludes with percentage-based rollouts using weighted bucketing (on a 0-100,000 scale) or fallthrough to a default variation if no rules apply. This structured algorithm ensures precise, consistent decisions while supporting multivariate flags beyond simple booleans. Providers like Flagsmith deliver these engines through polyglot SDKs, supporting languages such as Java, JavaScript, Python, and Go, with local evaluation modes that embed the logic for offline resilience and cross-platform uniformity. Similarly, open-source engines like Unleash's Yggdrasil, implemented in Rust, use domain-specific languages for compact rule definitions, enabling evaluations in hundreds of nanoseconds across diverse SDKs.[30][31][32]
Performance considerations are critical, as frequent evaluations can introduce latency and resource overhead in high-scale systems. To address this, caching strategies store resolved flag states in memory or persistent stores, minimizing remote fetches and computations; for instance, in-memory caches with short Time-To-Live (TTL) durations, such as 30 seconds, balance freshness with efficiency by invalidating periodically to reflect updates without constant polling. Server-side SDKs often employ background refresh mechanisms, caching full configurations for seconds to minutes depending on flag volatility, while client-side variants use session-persistent caches to maintain consistency during user interactions. In distributed setups, feature stores like Redis integrate TTL-based expiration (e.g., 15 seconds) to handle scale, preventing stale data while reducing database hits by up to 90% in production workloads. These techniques ensure toggles add negligible overhead, with evaluations completing in microseconds even under trillions of weekly requests.[33][34][32]
