Introducing Optimizely Opal
an all-new AI platform. See how it works
Glossary

Feature flags

What are feature flags?

Feature flags (also known as feature toggles or feature switches) are a software development and product experimentation technique that controls functionality during runtime, without deploying new code. This allows for better control and more product experimentation over the full lifecycle of features.

While basic feature flags function as simple on/off switches, modern feature flag systems like FX offer much more sophisticated capabilities that follow a "crawl, walk, run" progression:

  1. Crawl (Basic On/Off switches): At their simplest, feature flags determine whether code is executed. If the flag is "on," new code runs; if "off," the code is skipped.
  2. Walk (Dynamic parameter control): Rather than hardcoding behavior with if-else statements, FX's SDK "decide" method enables a parameterized approach. This allows you to fine-tune various aspects of a feature through the FX UI without requiring code changes.
  3. Run (Experimentation and optimization): With FX's flag-first approach, once you implement the flag and event tracking for feature releases, you gain experimentation capabilities without additional development work. This includes A/B testing and AI-powered optimizations.

Feature flags let you deploy new features without making them visible to all users immediately or make features visible only to specific subsets of users and environments. Often considered a best practice in DevOps, this approach provides unprecedented control over your feature lifecycle.

Here’s how the Optimizely team uses feature flags.

How feature flags work?

Feature flags are essentially conditional statements in your code that control whether specific features or code blocks are executed. Here's a simple breakdown:

  1. Conditional branches: Developers add if/else statements in the code where new features are implemented.
  2. Flag status: Each feature flag has a status (on or off) that can be controlled externally, often through a configuration file or management interface.
  3. Code execution: The new feature code is executed if the flag status is on. If the flag is "off," the code is bypassed, and the old behavior (or no behavior) remains in place.

This allows teams to deploy new code to production but keep features hidden until they're ready to be released, all without additional code deployments.

When implementing feature flags, there are several rollout strategies to consider, each serving different purposes:

  • Phased rollouts: Gradual release to increase user percentages
  • Canary testing: Limited release to small, representative group
  • Targeted rollouts: Release to specific user segments (e.g., by location)
  • Beta testing: Release to opt-in users for feedback
  • Dark launches: Activate in production but hide from users
  • Percentage rollouts: Incrementally increase user exposure

These strategies can be combined to create a custom rollout plan that aligns with your goals and risk tolerance.

Feature flag use cases and benefits

There are many benefits for incorporating product experimentation and feature toggles into your release process. The following are some common use cases:

  1. Testing in production

    Feature flags allow development teams to test new features in production, while mitigating the risk of a poor release by providing a way to quickly roll back the feature if necessary via a kill switch. Because it is often impossible to completely simulate the production environment in staging, feature toggles allow you to validate the functionality of new feature releases in the real world while minimizing the risk. Feature flags also encourage trunk-based development, which helps prevent merge conflicts from divergent code paths.
  2. Canary releases

    Another use case for feature toggles is allowing a team to test a new feature on a subgroup of end users to see how it performs before rolling it out to a broader audience. Canary testing helps to limit the risk of launching a feature to your full user base, and allows you to quickly roll back a feature simply by toggling it on or off, rather than having to go through another deploy cycle.
  3. Quicker release cycles

    Using feature flags, a team can modify a system’s behavior without making disruptive code changes to the live code. Thus, one major benefit of feature flags is their simplicity to deploy in the development process. Feature flags decouple feature lifecycle management from code deployment, freeing up the engineering team to work on other tasks.
  4. Rollback / kill switch

    Enabling or disabling new features using feature flags is as easy as toggling it on or off or editing a config file vs having to re-deploy and having to go through a lengthy code push. If a bug is discovered in a new feature, it can be rolled back instantly without having to touch your source code. This can be especially powerful for mobile app developers, who can use feature flags to release or roll back new features without having to go through the length app store review process.
  5. Server-side A/B Testing

    Developers can implement A/B tests, using feature flags by enabling a feature for half of a segment of users, and disabling the feature for the other half, and seeing how the two perform against each other for a certain metric (such as app usage or purchases). Because the test is implemented in the backend through code, there is no latency, compared to what one might experience with a test implemented via client-side JavaScript.

    Feature flags also allow product managers and other non-engineers to A/B test various features within products or systems with no need for a code deployment. Tests can also be targeted at specific segments of your userbase as well, for example users that live in a specific country or fit a specific user profile. Leading tech companies such as Google, Facebook, Amazon and Netflix frequently A/B test new features before deploying to their full user base.
  6. Feature gating

    Feature flags can be used to implement targeted rollouts of features to a specific subset of your users. This can be great for A/B testing features with specific segments of your audience, but it can also be used to release features to only a subset of your users, for example granting users in your enterprise tier access to features that aren't available in lower tiers. Implementing feature gating using flags allows you to easily rollout features to more of your users in the future as your product evolves.
  7. Continuous deployment

    Another major benefit is of feature flags are their ability to allow quick learning. Feature flagging allows companies to continuously deliver and deploy software to their users in a faster way. The use of feature flags allows companies to perform gradual feature rollouts, fix bugs in the code without redeploying, experience a more streamlined development cycle and do rollbacks of code more easily.
  8. Feature flag development process

    Implementing feature flags in your code doesn't have to be a complicated process. With a feature flag service such as Optimizely, all you need to do is install the SDK, create the flags within the feature flag platform, and then wrap new features or code paths in your code within the flags.

    That's all it takes to enable feature flags, and now the new feature can be toggled on or off via a configuration file, or even via a visual interface within the feature flagging platform. This can enable non-technical users, such as product managers, to run experiments on new features or turn off features, without having to rely solely on the development team.

    Once feature flags are live, another important consideration is feature flag management. To avoid the technical debt of having feature flags remain in the code after they have served their purpose, it is important to review flags at a regular cadence and remove ones that are no longer necessary. This process can be automated within many feature flagging platforms.
  9. Feature flags & continuous delivery

    Championed by influential software developer Martin Fowler, continuous delivery is a software development discipline in which software can be released to production at any time. It has been adopted by leading software companies around the world whose teams are now expected to quickly deliver software that is stable and bug-free to your user base.

    Feature flagging enhances CI/CD by making “continuous” more achievable. The feature flags and feature toggles are a key component of the implementation of continuous delivery, allowing the separation of feature rollout from code deployment. Incomplete features can be merged into the production codebase but hidden behind feature flags.

    With continuous delivery and feature flag management, a team can launch, control, and measure their features at scale.
  10. AI feature development

    Feature flags enable agile development of AI features by controlling which models are used and how they're configured without code changes. This helps teams adapt quickly in 2025, allowing them to switch between models, adjust parameters, and roll out AI capabilities gradually to ensure quality.
  11. Decoupling deployment from release

    Feature flags separate code deployment from feature release, enabling safer, more frequent deployments. When features require multiple teams with different timelines, completed work can be merged and hidden behind flags while other teams continue development. This reduces merge conflicts from delayed, massive PRs and allows features to be activated independently when ready. The result is faster development and improved stability.

Feature flag lifecycle

1. Create and configure feature flags:

  • Define the flag in your codebase
  • Set up the flag in your feature management system
  • Configure initial rules and targeting criteria

2. Deploy and activate flags in production:

  • Release code with the new feature flag to production
  • Enable the flag for initial target groups or percentage of users

3. Monitor performance and collect analytics:

  • Track user interactions with the new feature
  • Analyze impact on key metrics (e.g., conversion rates, user engagement)
  • Gather feedback from users exposed to the feature

4. Sunset and remove flags when no longer needed:

  • Once a feature is fully released or deprecated, remove the flag
  • Clean up related code to prevent technical debt
  • Update documentation to reflect changes

Feature flags vs. configuration files

While feature flags may seem similar to configuration files, they offer significant advantages. Configuration files typically require manual editing and redeployment to change settings (a process limited to developers), whereas feature flags evaluate at runtime. With a feature management platform, you can flip a switch and instantly change behavior without redeploying or restarting your application.

Additionally, configuration files require self-hosting, which becomes risky and expensive at scale. Opti hosts data files on CDN for rapid reads and consistent availability. Feature flags also enable precise targeting and control, allowing you to roll out specific changes to specific audiences based on user attributes, segments, or percentages, unlike configuration files that act as blunt on-off switches for all users.

Feature flags and technical debt

As feature flags become more widely used within an organization, they can potentially create technical debt if not properly managed. This "flag debt" occurs when your codebase becomes cluttered with flags and old code paths that are no longer useful because features have been fully rolled out.

Best practices for managing feature flag technical debt include:

  • Using clear naming conventions that indicate the purpose and expected lifespan of flags
  • Regularly reviewing active flags and checking the last modified dates to identify obsolete ones
  • Documenting each flag's purpose and expected removal timeline
  • Automating cleanup processes where possible
  • Assigning dedicated time for flag cleanup in your development cycles
  • Using SDK notification listeners to dispatch events to third-party systems upon decision or conversion events

Feature flags in Optimizely Feature Experimentation

Optimizely Feature Experimentation offers powerful feature management capabilities that transform how product and engineering teams work together. This solution brings the same flexibility that product teams rely on for experimentation to the feature deployment process, allowing teams to validate hypotheses before full launches.

With Optimizely, engineering and product teams can work together with continuous integration and continuous delivery practices.

Organizations benefit from accelerated development cycles while mitigating risks through strategic feature flag implementation.

Following the approach of industry leaders like Amazon, Google, and Facebook, Optimizely's omni-channel experimentation platform enables teams to:

  • Develop new user experiences
  • A/B test to identify optimal variations
  • Use feature flags to control rollout

By initially testing features with small traffic segments, teams can confidently determine if new features truly improve the user experience before wider deployment.

For teams seeking a simpler solution, Optimizely Rollouts provides completely free feature flags, unlike competitors such as LaunchDarkly. Rollouts supports popular programming languages and frameworks through GitHub SDKs, including Node.js, Python, Ruby, Go, React, Swift, and C#.

Getting started with feature flags

Consider the following steps:

  • Identify your goals: Identify and define what you want to achieve with feature flags (faster releases, safer deployments, feature management, etc.)
  • Choose your approach: Decide whether to build a homegrown solution, use open-source tools, or adopt a comprehensive feature experimentation platform.
  • Start small: Begin with a few critical features before expanding your usage.
  • Train your team: Ensure developers understand how to implement feature flags and that product managers know how to use them.
  • Establish governance: Create processes for flag creation, testing, rollout, and cleanup.
  • Measure impact: Track how feature flags are affecting your development velocity, release quality, and business metrics.

Ready to experiment with feature flags?

Optimizely Feature Experimentation can help you implement feature flags, run experiments, and deliver features with confidence. Everything you need to manage the entire feature lifecycle, from development to release to measurement.

Explore Optimizely Feature Experimentation →