Inferensys

Glossary

Feature Flag

A software development technique that wraps a feature in a conditional statement, allowing it to be turned on or off remotely without deploying new code, enabling safe testing and controlled rollouts.
Data engineer managing feature store on laptop, feature definitions visible, casual data engineering session.
CONTROLLED SOFTWARE RELEASE

What is a Feature Flag?

A feature flag is a software development mechanism that wraps a feature in a conditional statement, enabling it to be toggled on or off in a live environment without deploying new code.

A feature flag (also known as a feature toggle) is a conditional code branch that decouples deployment from release. By wrapping a new capability in an if/else statement controlled by a remote configuration variable, engineering teams can merge unfinished code into the main branch without exposing it to users. This enables trunk-based development and eliminates long-lived feature branches.

The flag's state is evaluated at runtime, allowing non-technical stakeholders to instantly toggle functionality for specific user segments. This powers critical operational patterns like canary releases, where a feature is gradually rolled out to a small percentage of users, and kill switches, which allow an underperforming feature to be disabled instantly without a rollback or hotfix.

Core Mechanisms

Key Characteristics of Feature Flags

Feature flags decouple deployment from release, enabling precise runtime control over who sees what functionality and when.

01

Runtime Toggle Mechanism

A feature flag wraps a code path in a conditional statement evaluated at runtime. The flag's state—on or off—is determined by a remote configuration service, a local config file, or a database query. This eliminates the need for a full redeployment to change functionality. The evaluation logic typically follows a pattern: if (featureFlag.isEnabled('new-checkout', user)) { showNewCheckout(); } else { showLegacyCheckout(); }. The flag check is designed to be extremely low-latency to avoid impacting application performance.

02

Targeting and Segmentation

Modern feature flags go beyond simple on/off switches. They support granular targeting rules that determine flag evaluation based on user context. Common targeting attributes include:

  • User ID or email domain: For internal dogfooding or beta lists.
  • Geographic location: For region-specific launches.
  • Subscription tier: To gate premium features.
  • Custom attributes: Any property passed in the evaluation context. This allows for ring deployments, gradually expanding a feature from 1% to 100% of a user base.
03

Operational Feature Flags

Not all flags control user-facing features. Operational flags (or kill switches) govern system behavior and infrastructure. They act as circuit breakers to gracefully degrade service under high load. Examples include:

  • Disabling a non-critical recommendation widget when database latency spikes.
  • Switching from a primary payment gateway to a backup provider instantly.
  • Reducing logging verbosity in production without a hotfix. These flags are often managed by Site Reliability Engineers (SREs) and are critical for high-availability architectures.
04

Experiment Flags and A/B Testing

When combined with an analytics pipeline, a feature flag becomes an experiment flag. The flag service randomly assigns users into treatment and control cohorts and tracks their behavior against key metrics. This transforms a simple toggle into a rigorous A/B/n testing tool. The flag system must ensure consistent bucketing, meaning a user always sees the same variant during an experiment session. Statistical analysis is then performed on the collected data to determine if the new feature drives a statistically significant lift in conversion or engagement.

05

Flag Lifecycle and Technical Debt

A feature flag is a temporary construct, not a permanent part of the codebase. Every flag must have a defined lifecycle: Creation, Rollout, Full Release, and Crucially, Removal. A flag that remains in the code long after a feature is permanently on becomes technical debt. It increases cyclomatic complexity, creates untestable code paths, and risks accidental deactivation. Mature teams enforce flag removal by setting expiration dates on flags and integrating automated cleanup tasks into their sprint cycles.

06

Trunk-Based Development Enabler

Feature flags are the primary enabler of trunk-based development for large teams. Instead of maintaining long-lived, divergent feature branches that result in painful merge conflicts, developers commit incomplete code directly to the main branch hidden behind a disabled flag. This practice ensures continuous integration of all work. The hidden code is deployed to production but remains inert, allowing teams to test in the real production environment without exposing unfinished features to end-users.

FEATURE FLAG FUNDAMENTALS

Frequently Asked Questions

Clear, technical answers to the most common questions about feature flags, their implementation, and their role in modern software delivery.

A feature flag is a software development technique that wraps a feature in a conditional statement, allowing it to be turned on or off remotely without deploying new code. It works by evaluating a boolean expression at runtime—often based on user identity, geography, or a random percentage—to determine which code path executes. The flag's state is typically managed through a centralized feature management platform that pushes configuration changes to applications in near real-time via polling or streaming connections. This decouples deployment from release, enabling teams to merge code into production continuously while controlling who sees it and when.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.