Design a feature flag system with frontend controls
Difficulty: MEDIUMCategory: HLDFrequency: 1Asked On 2024-03-16
Problem Statement
Designing a scalable, real-time Feature Flag (Feature Toggle) System that allows developers and product managers to enable, disable, or gradually roll out features across users, environments, and platforms. The system should support frontend integration, so that flags can be evaluated and controlled directly on web and mobile clients, while still maintaining security, performance, and consistency.
🔶 Functional Requirements
1.Feature Flag Management (Admin UI / API)
•Create, update, and delete feature flags.
•Define flag types: boolean, multivariate (A/B testing), percentage rollout.
•Scope flags to environments (dev, staging, prod).
•Target flags based on attributes (user ID, region, device type, app version).
•Rollout strategies (gradual %, random sampling, whitelisted users).
2.Frontend Controls
•SDK for web/mobile clients to fetch and evaluate flags in real-time.
•Local caching for offline flag evaluation.
•Support for client-side overrides (for debugging, QA, beta testing).
•Ability to toggle experimental UI flows without app redeploys.
3.Data Collection & Analytics
•Track flag evaluations, impressions, and experiment conversions.
•Provide dashboards to visualize rollout status and experiment results.
4.Access Control & Security
•RBAC (admins, developers, PMs, QA).
•Audit logs for all flag changes.
•Prevent frontend clients from tampering with sensitive flags.
5.Integrations & APIs
•REST/gRPC APIs for programmatic flag evaluation.
•Integration with CI/CD pipelines for automated testing with flags.
🔶 Non-Functional Requirements
•Scalability: Handle millions of flag evaluations per second.
•Low Latency: Flag evaluation on frontend must be <10ms (cached/local evaluation).
•Consistency: Changes to flags should propagate globally within seconds.
•Reliability: High availability with zero-downtime updates.
•Security: Ensure flags cannot be reverse-engineered or tampered with from frontend SDKs.
🔶 Constraints
•Must support real-time updates (websockets/polling/long-polling).
•Flags should be evaluated locally on the client whenever possible, but with a fallback to server evaluation.
•Large-scale environments (tens of thousands of flags, millions of users).
•Rollbacks must be instant in case of bad feature rollout.
🔶 Example Use Cases
1.A PM enables a new checkout flow only for 5% of users in India to test performance.
2.QA overrides a feature flag in the frontend app to test an unreleased feature.
3.A developer disables a broken feature instantly in production without redeploy.
4.A marketing team runs an A/B test with three different homepage layouts.
5.Mobile clients cache flag values locally and sync updates when online.
👉 Summary:
"Design a distributed, real-time Feature Flag System with frontend SDK support, enabling safe rollouts, experiments, and instant toggles, while ensuring scalability, low latency, security, and analytics-driven decisions."