← All problems
Dashboard
Courses
Problems
Badges
Theme
Sign inStart free
Problem 023 · APIs and application architecture

Design a Feature Flag Service

Easy 30 min

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
  1. A 5 ms budget leaves no room for a network call per check: where should the evaluation actually run?
  2. Hash the user ID together with the flag key to pick a stable rollout bucket.
  3. What does an SDK do on start-up if it cannot reach the service at all?

Ready to build?

Open the canvas, place your components and explain your decisions. Your draft saves automatically.

Sign in to start

Failure scenarios

  • The flag service is unreachable during a deployA bad release takes the flag service down for 20 minutes just as 1,000 service instances are restarting and asking for their rule sets.

Run them from the workspace once your design is in place.