Feature Flags (Pattern)
Problem
Services need runtime toggles for three recurring reasons:
- Safe rollout — enable a new feature gradually (percentage, tenant-scoped, user-scoped) rather than flipping everyone at once.
- Kill switch — disable a misbehaving code path without a rollback deploy.
- Degradation — shed sheddable surfaces under load or during incidents (DR).
Static configuration files, environment variables, and code constants can’t serve any of these — they require deploys. Runtime configuration in an ad-hoc store fragments the substrate and breaks auditability.
Solution
Use a shared platform flag substrate — Azure App Configuration + Feature Management SDK — with strict lifecycle and audit discipline.
1. Substrate
- Azure App Configuration — one instance per env.
- Feature Management SDK — evaluates flags with targeting rules (percentage, tenant, user, custom attributes).
- UAMI-scoped data-plane access (Private Data Store Access).
- SDK cache with refresh (typ. 30–60 s) and push-refresh via Event Grid for kill switches.
2. Flag definition
Every flag has:
- Owner — team + individual reviewer.
- Default — safe value (usually off) baked into IaC.
- Targeting rules — percentage, tenant, custom.
- Target removal date — flags are temporary by default (typ. 90 days post-full-rollout).
- Documented purpose — behaviour it enables, not implementation detail.
3. Code discipline
- Wrap flag reads at the outermost decision point — not scattered through deep code.
- Test both branches in CI.
- Tolerate short SDK cache staleness — flags are eventually consistent.
- Retire the flag by first pinning value, then removing the code branch, then removing the flag from IaC.
4. Audit
- Every flag value change emits an audit event (Audit Logs).
- Emergency toggles logged with elevated severity + post-hoc review.
5. Change control
- Flag definitions in IaC + Runway.
- Flag runtime values through approved automation (CI/CD SP + on-call role only above Alpha).
- No portal edits above Alpha under normal operations.
When to use
- Rolling out a risky new feature.
- Wrapping a code path likely to need a kill switch.
- Gating degraded-mode behaviour for sheddable surfaces.
- Time-bound experiments / A-B tests.
Not for:
- Long-term configuration (App Config non-flag values).
- Secrets (belong in Key Vault).
- Replacing proper release engineering.
Consequences
Positive
- Safe, fast rollouts and rollbacks without deploys.
- Uniform substrate across ION; audit trail included.
- Degraded-mode toggle for incident mitigation.
Negative
- Flag proliferation is a real risk — needs lifecycle discipline.
- Combinatorial state — on/off paths must both be tested.
- Runtime dependency on App Config availability.
Failure modes
- Owner-less flags — orphans that never retire.
- Long-term flags keep two behaviours alive forever.
- Flag-controlled critical path — critical must not degrade.
- Portal-toggled prod flags — untracked drift.
- Random per-request evaluation — breaks UX + tests.
- Secrets in App Config — misplaced trust surface.
References
references/Design Pattern- Feature Flags.md- ADRs: 0012, 0024.
- Capability: Feature Flags.
- Related patterns: Audit Logs, Private Data Store Access.
Applied in
- Every ION service consuming platform App Configuration
- Platform-wide
degraded-modekill switch - MFE progressive rollout of new UI surfaces (Veritas + Alya)
- Playbook version rollouts (Cogs)
- New template rollouts (Pigeon)