A feature flag selects behavior at runtime. It can reduce exposure before or after a code deployment, but disabling it does not reverse database writes, queue messages, or an incompatible API response already sent. A safe flag has a default, owner, target group, expiry or removal plan, and observable result.
Feature flags: stop exposure without pretending code vanished
Operational decision
For a settlement batch algorithm, deploy code with the new path off by default, then enable it for one internal tenant after a test that exercises the complete ledger write. Observe duplicate-write rate and reconciliation delay before expanding the audience. The policy record below is an editorial release contract, not a vendor API. The application must evaluate the flag at the correct decision point and use a stable targeting key; changing cohorts between requests can make diagnosis difficult. Test flag-provider failure and stale-cache behavior. The off path must remain compatible with the current schema until the rollback window closes. Record the flag state and cohort in operational telemetry without making tenant IDs high-cardinality metric labels. Remove the flag after the migration finishes so two permanent code paths do not accumulate.
feature: settlement_batch_v2
owner: settlements-oncall
default: false
firstCohort: internal-ledger
stopWhen:
duplicateWrites: 1
reconciliationDelayMinutes: 17
removeAfterRelease: ledger-054Cost and verification
Flag evaluation adds a small runtime dependency and creates a second behavior path to test. Keeping old and new paths for months multiplies test combinations and operational confusion. A remotely controlled flag can be fast to switch, but provider outages or propagation delays mean not every instance changes at once. Define the failure default and measure actual exposure. The sample stop thresholds are scenario values; choose limits from service impact and the release's risk model.
Common Mistakes
- Do not call a flag switch a data rollback.
- Do not create a flag with no owner or removal plan.
- Do not assume all instances observe a flag change instantly.
