A feature flag is a control mechanism that lets an application enable or disable behavior without requiring a new deployment for every change. It can begin as a simple if statement, but in production it becomes part of the release process, operational safety model, and team workflow.
A well-designed flag lets a team expose a new capability to a small audience, observe its effects, and quickly disable it if necessary. A poorly designed flag creates long-lived branches, unclear defaults, hidden dependencies, and a growing maintenance burden. The difference is usually not the flag provider; it is the discipline around design, evaluation, rollout, and removal.
Deployment and release are different events
Deployment puts new code into an environment. Release makes that code available to selected users. Feature flags separate these activities. A team can deploy an implementation while keeping it disabled, then enable it gradually after the code is present in production.
This separation is useful for database changes, external-service integrations, and high-traffic user-interface changes. It does not make unsafe code safe automatically. The new path still requires tests, access control, capacity planning, and a tested fallback when the flag is disabled.
Choose a flag type based on its purpose
| Type | Purpose | Typical lifetime |
|---|---|---|
| Release flag | Expose a new capability gradually | Temporary |
| Experiment flag | Compare two or more behaviors | Limited to the experiment |
| Operational flag | Change dependency or performance behavior | Potentially permanent |
| Permission flag | Control access by plan, role, or tenant | Defined by the business rule |
The classification affects ownership, review frequency, and cleanup. A release flag should normally disappear after general availability. An operational flag may remain as an incident-control mechanism, but its authorized operators and safe state must be documented.
Build a staged rollout workflow
- Define the safe default: Decide what should happen if the evaluation provider is unavailable or returns an error. For a new or risky capability, the previous behavior is often the safer default.
- Start with internal users: Enable the feature for employees, test accounts, or selected tenants. Check both user experience and the quality of logs, metrics, and support procedures.
- Use small traffic increments: Increase exposure in controlled stages such as 1%, 5%, and 25%. At every stage, inspect errors, latency, resource consumption, and relevant product outcomes.
- Write promotion criteria first: Specify acceptable error rates, latency limits, minimum sample sizes, and rollback conditions instead of relying on intuition.
- Remove the old path: Once the feature is fully released, delete the obsolete branch and configuration through a planned follow-up change.
Percentage rollouts should use a stable targeting key such as a user ID, account ID, or tenant ID. If the assignment changes randomly on every request, one user may see different behavior across sessions and experiment measurements may become difficult to interpret. The OpenFeature specification describes a targeting key as the identifier of the subject being evaluated and notes its importance for rules, overrides, and fractional evaluation.
Place evaluation at a clear application boundary
Evaluate a flag where the behavioral decision is easy to understand. Repeating the same evaluation inside many small methods makes the system harder to reason about. A clear decision point is easier to test and review:
var useNewCheckout = flags.GetBoolean("checkout.new-flow", false, context);
if (useNewCheckout)
{
return newCheckout.Process(request);
}
return legacyCheckout.Process(request);The default value in this example is the fallback used when the flag system cannot provide a result. Automatically defaulting a risky feature to true can turn a control-plane failure into an unplanned release.
Do not treat a feature flag as an authorization system. A flag may decide whether an interface or optional behavior is visible, but it does not prove that a user is allowed to perform a sensitive operation. Authorization must remain an explicit server-side policy and enforcement check. A client-side flag should never be considered a security boundary.
Control multi-part releases carefully
Many features consist of several changes: a new interface, an API endpoint, a data model, and reporting logic. Define the order in which these components become active. Dependencies can prevent an upper layer from being enabled before the lower layer is ready.
However, each dependency increases evaluation and troubleshooting complexity. If several flags must be enabled together, document their relationship, owners, expected states, and removal order. The dependency should be visible in code review or release documentation rather than existing only in someone’s memory.
Design kill switches as operational controls
A kill switch is an operational flag used to disable a non-core capability or reduce reliance on a failing dependency during an incident. For example, if a recommendation service is unhealthy, the application may disable recommendations while preserving the primary user journey.
Good kill switches have several properties:
- Use a clear boolean name such as
recommendations.enabled. - Test the disabled path under realistic load.
- Restrict who can change the flag and record every change in an audit trail.
- Document local caching, timeouts, and fallback behavior when the provider is unavailable.
- Add expected recovery signals and operating steps to the incident runbook.
The flag system itself can become a dependency. If evaluation requires a network call, test what happens during a provider outage, stale configuration, or partial connectivity. Server-side caching, bounded timeouts, and safe defaults help prevent a control mechanism from becoming a new failure source.
Observability is part of the rollout
If you cannot determine which flag variation handled a request, explaining production differences becomes difficult. Without exposing sensitive personal data, associate the flag key, variation, application version, and—when available—the evaluation reason with logs or traces. OpenFeature’s observability guidance discusses mapping evaluation information such as the flag key and resulting variant into telemetry.
Monitor at least two groups of signals during every rollout:
- Technical signals: error rate, p95 or p99 latency, timeouts, CPU, memory, saturation, and queue depth.
- Product signals: completed transactions, conversion, cancellation, support contacts, or another outcome that represents user success.
Record flag changes as separate change events from deployments. Two instances may run the same application version while serving different behavior because their flag configurations differ. Keeping both timelines is essential during incident analysis.
Prevent flag debt
Every temporary flag should have an owner, purpose, creation date, expected removal date, default behavior, and rollout status. A repository search or static check for known flag keys can identify references that remain after a flag is retired. CI can warn about overdue flags, while permanent operational and permission flags can be tracked in a separate inventory.
Cleanup is more than deleting one conditional. Review tests, configuration records, dashboards, documentation, targeting rules, and unused variations. Remove the flag from the control plane as well as from application code so it cannot be accidentally reactivated later.
Practical review checklist
- Is the purpose and type of the flag explicit?
- Does it have a technical or product owner?
- Are disabled and provider-error paths tested?
- Is the targeting key stable?
- Are rollout stages and rollback criteria written down?
- Are flag changes recorded and access-controlled?
- Are technical and product metrics monitored together?
- Does every temporary flag have a removal date?
Feature flags are not a replacement for testing, deployment automation, authorization, or observability. They are a control layer that connects those practices to safer delivery. The most maintainable systems use a small number of clearly named flags, stable targeting, measurable rollout stages, and a routine process for removing temporary decisions.
0 Comments