Frontend

Designing a Feature Flag Architecture in Frontend System Design

Feature flags (also called feature toggles) allow developers to enable or disable features without deploying new code. Modern applications use feature flags for gradual rollouts, A/B testing, canary releases, emergency kill switches, and user segmentation. A well-designed frontend feature flag system enables rapid experimentation while keeping applications performant, scalable, and resilient.

ByteAndBites·Jul 08, 2026
Designing a Feature Flag Architecture in Frontend System Design
Design a scalable frontend feature flag architecture for a large web application.

Requirements:
  • Enable/disable features remotely
  • No redeployment required
  • User-specific flags
  • Percentage rollouts
  • Country/device-based targeting
  • A/B testing support
  • Kill switches
  • Offline fallback
  • Fast startup
  • Real-time updates (optional)

Follow-up Questions
  • Where should flags be stored?
  • How do you avoid flickering during app startup?
  • How do you cache flags?
  • How do you support offline mode?
  • How do you perform percentage rollout?
  • How do you remove stale flags?
  • How do you update flags without refreshing the page?

How to Think About It (Framework)
  • Flag Service
  • Client SDK
  • State Management
  • Flag Evaluation
  • Rollout Strategy
  • Caching
  • Performance
  • Cleanup

High-Level Architecture
The frontend should never hardcode feature availability.
Instead:
App Startup → Feature Flag SDK → Feature Flag Service → Evaluate Rules → Expose Feature Values → Render UI

High Level Architecture
High Level Architecture

UI Layer
Every component should consume flags instead of checking environments.
Example:
JavaScript
if (flags.newCheckout) {
   render(NewCheckout)
} else {
   render(LegacyCheckout)
}

Data Model
JavaScript
interface FeatureFlag {
    key: string;
    enabled: boolean;
    rollout: number;
    rules: Rule[];
}
Example:
JavaScript
{
   key: "new-navbar",
   enabled: true,
   rollout: 20
}

Flag Evaluation
Evaluation can happen based on:
  • User ID
  • Country
  • Device
  • App Version
  • Subscription
  • Browser
  • Custom attributes
Blog image


Percentage Rollout
Instead of:
Everyone gets feature

Roll out gradually

Example
5% → 10% → 25% → 50% → 100%
Blog image

Typical implementation:

JavaScript
hash(userId) % 100 < rolloutPercentage
This ensures the same user consistently receives the same experience.

Kill Switch

One of the most important production features.
Suppose Checkout V2 breaks.
Instead of redeploying:
Dashboard

Disable Flag

All clients hide feature

Issue resolved
No deployment required.

Blog image


Caching Strategy
Flags should not be fetched every page load.
Cache in:
  • Memory
  • localStorage
  • IndexedDB (optional)
Use:
stale-while-revalidate
Flow:

Cached Flags

Render immediately

Fetch latest

Update silently

Real-Time Updates
Optional but useful.
Server

WebSocket / SSE

Client SDK

Update Flags

Re-render affected components

State Management
Store
flags
loading
error
lastUpdated
source

Rendering Strategy

Avoid:
Loading...

Fetch Flags

Render UI
Instead

Cached Flags

Render

Background Refresh

This prevents UI flickering.

A/B Testing

Example
Button A vs Button B

Evaluation:
variant = hash(userId) % 2
Store analytics separately.

UI Diagram with A/B
UI Diagram with A/B


Performance Optimization
Lazy load flag groups: 
  • Don't download thousands of flags.
Memoize evaluations: 
  • Avoid recalculating flags.
Batch updates:
If 20 flags change

One render
Not 20 renders.
Remove dead flags
  • Old flags increase complexity.
  • Schedule cleanup after rollout.

Edge Cases
  • Flag service unavailable
  • Network timeout
  • Corrupted cache
  • User logs out
  • User changes country
  • Rollout changes during session

What Interviewer is Testing
  • Frontend architecture
  • Remote configuration
  • Rendering strategies
  • Caching
  • Performance
  • Progressive rollout
AtlassianJavascriptInterviewDream11System DesignZepto
Frontend System Design Playbook
Series
Frontend System Design Playbook
View series
A hands-on series focused on cracking frontend system design interviews at companies like Google, Atlassian, and Uber. Instead of theory-heavy discussions, this series breaks down real UI systems—like infinite scroll, autocomplete, caching, and complex state management—into clear, practical approaches with implementation-focused thinking.