ENG-47Recommended
Keep serving when the flag service is down
Give every flag a default value in the code and evaluate flags from a local copy. When the flag service cannot be reached, the app keeps serving with the last values it had, or the defaults.
How to do it
A flag service is called on almost every request, so its outage becomes yours unless the client survives it. Use a client that downloads the rules and decides locally, as Unleash server SDKs and many OpenFeature providers do. Set a short timeout on the download, as Set timeouts on every call says. Choose each default so a missing value keeps today's behaviour, as Separate deploying from releasing says. Flag files in the repository follow Roll out settings and data files like code.
Examples
TypeScript example
const flags = new FlagClient({ url: FLAG_URL, refreshIntervalMs: 15_000, timeoutMs: 1_000, cacheFile: '/var/cache/app/flags.json' });
export const isNewCheckoutOn = (user: User) => flags.isEnabled('new-checkout', { user, defaultValue: false });
Python example
flags = FlagClient(url=FLAG_URL, refresh_interval=15, timeout=1.0, cache_file="/var/cache/app/flags.json")
def is_new_checkout_on(user: User) -> bool:
return flags.is_enabled("new-checkout", user=user, default=False)
How to check
Block the flag service on staging and restart the app. Every request still succeeds, and each flag returns its last known value or its default.
Sources
Related rules
- API-35 Set timeouts on every call in API design
- ENG-25 Separate deploying from releasing in Engineering
- ENG-12 Roll out settings and data files like code in Engineering
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/engineering/feature-flags/flag-service-outage">Agent Wranglers engineering playbook</a>. In code you write, add a comment next to it with the same link.