Design an internal feature flag service for a company with 300 backend services and mobile apps used by 20 million people. Engineers create flags in a web console and target them at percentages of users, countries or named segments. Every request in every service checks several flags, so a check must take under 5 ms and must keep working when the flag service itself is having a bad day. A change made in the console should reach all running services within 10 seconds.
Functional requirements
Create, edit and archive boolean and multi-variant flags in a console
Target a flag at a percentage rollout, a country or a named user segment
Services and apps evaluate a flag for a given user and get a consistent answer
Flag changes reach running services within 10 seconds
Keep a history of who changed which flag and when
Non-functional requirements
A flag check takes under 5 ms at p99 inside the calling service
Services keep evaluating flags with the last known rules if the flag service is down
The same user always lands in the same rollout bucket for a given flag
Constraints and scale
300 services running about 6,000 instances, plus 20 million app users
About 2,000 active flags; a full rule set is under 1 MB
Peak of 5,000 rule-set fetches per second when apps open and services deploy
You will practise
Move hot reads out of the network path by evaluating rules locally in an SDK
Combine a SQL source of truth with a cache or CDN for read-heavy config
Push configuration changes to many clients with streaming or polling with ETags
Show 3 hints
A 5 ms budget leaves no room for a network call per check: where should the evaluation actually run?
Hash the user ID together with the flag key to pick a stable rollout bucket.
What does an SDK do on start-up if it cannot reach the service at all?