Practice: Design a Feature Flag Service
Feature flag service inspired by LaunchDarkly and Unleash: flag rules live in a database, apps read them from a cache or the CDN edge, and changes are pushed out in the background with an audit trail.
Build this system yourself on the canvas below. Add components, connect them, and run traffic simulations to see where your design holds up and where it breaks.
Functional requirements
- Evaluate a flag for an app instance: given the flag key and a user or context, return on or off (or a variant) from the flag's rules
- Let an admin create or change a flag and its rules (percentage rollout, user lists, environments)
- Push each change out to every reader within 30 seconds, through the cache and the CDN edge
- Record every change in an audit log: who changed what, when, and the previous value
- Let apps keep working with their last known flags when the flag service or its database is unreachable
- Limit admin changes per minute and require a valid key for each environment
Non-functional requirements
- Flag fetch < 50ms p99 from the edge or cache; evaluation happens in the app, so a fetch is only a rules download
- A change reaches readers within 30 seconds (publish through a queue, then purge the cache)
- Handle 10K flag fetches per second at peak and about 1 change per second
- Reads stay available during a database outage: the cache and edge hold the last published rules
- The audit log is append-only and never loses an entry (99.999% durability)
- Scale to 1M app instances without any of them hitting the database
- 99.99% availability for flag reads