Feature Flags in System Design Interviews: When to Use Them and What to Say
Feature flags are a runtime switch that enables or disables a piece of functionality without changing the deployed code. In an interview you can use them to show how you control risk when launching a new feature at scale.
The Problem Feature Flags Solve
When you add a new capability to a live service, you face two risks: a bug that crashes the service, and the inability to roll back quickly. Traditional approaches—code rollbacks or full redeploys—take minutes to hours and often require coordination across many teams. Feature flags give you a knob to turn the new path on for a small fraction of traffic, monitor its health, and expand gradually.
Concrete Example: Photo-Sharing Service
Imagine you are designing a photo-sharing platform that wants to add a new AI-based image compression algorithm. The existing pipeline uses a simple JPEG encoder. The new algorithm is heavier, runs on GPU, and is still being tuned. Deploying it to all users at once could overload the GPU fleet and break uploads.
How Feature Flags Work – Step by Step
- Define the Flag – Create an entry in a configuration store (e.g., DynamoDB, Consul, or a simple JSON file) named
use_new_compressorwith a default valuefalse. - Load at Startup – Each service instance reads the flag value on boot and caches it locally.
- Refresh Periodically – A background thread polls the config store every few seconds or subscribes to change events, updating the local cache.
- Check Per Request – In the upload handler, wrap the new code path:
if cfg.UseNewCompressor {
compressWithGPU(image)
} else {
compressWithJPEG(image)
}- Gradual Rollout – Change the flag value to a percentage (e.g.,
30%). The service reads the flag and, for each request, draws a random number; if it falls below the percentage, it uses the new path. - Monitoring & Rollback – Metrics (latency, error rate) are collected per branch. If the new branch spikes, set the flag back to
falseinstantly.
Where Feature Flags Appear in Classic Design Questions
| Design Question | Exact Spot to Insert a Flag | Why It Helps |
|---|---|---|
| Design a URL shortener | In the redirect service to enable a new cache-first lookup strategy | Lets you test a CDN layer without breaking existing redirects |
| Design a real-time chat system | Around the message persistence layer to switch from synchronous DB writes to an async event-sourcing pipeline | Allows you to verify eventual consistency before committing all traffic |
| Design a video streaming platform | In the transcoding pipeline to toggle a new codec (e.g., AV1) | Gives you a safety net when the new codec consumes more CPU/GPU than expected |
Trade-offs and Alternatives Interviewers May Probe
| Aspect | With Feature Flags | Without Feature Flags |
|---|---|---|
| Deployment speed | Instant rollout or rollback; no redeploy needed | Requires a new build and deploy cycle |
| Operational complexity | Need to manage flag store, cache invalidation, and consistency | Simpler code path, fewer moving parts |
| Latency impact | Extra check (an in-memory read when cached) adds microseconds per request | No extra check, marginally faster |
| Risk of stale config | If the cache isn’t refreshed, old values linger; need TTL strategy | No stale config risk |
Common Alternatives
- Blue-Green Deployments – Run two parallel versions of the service and switch traffic at the load balancer. Safer for large binary changes but requires double the infrastructure.
- Canary Releases – Deploy a new version to a small subset of servers. Similar safety but still involves a full redeploy.
- A/B Testing Frameworks – Often built on top of feature flags; the distinction is that flags are usually binary, while A/B tests handle multiple variants and statistical analysis.
Interviewers may ask you to compare flags to canary releases, focusing on the operational overhead of maintaining two codebases versus a single codebase with runtime switches.
30-Second Pitch
"Feature flags are runtime switches that let you turn new functionality on or off without redeploying. In a large service you store the flag in a central config, cache it locally, and check it on each request. This lets you roll out a new feature to a small percentage of traffic, monitor metrics, and roll back instantly if something goes wrong. The trade-off is a tiny latency increase and the need to keep the flag store consistent, but it’s far safer than a full redeploy or a blue-green deployment."
Mistakes Candidates Often Make
- Treating flags as a silver bullet – Claiming they solve all rollout problems without acknowledging added complexity.
- Skipping the cache refresh discussion – Forgetting to mention how stale values are avoided, which leads to inaccurate rollout percentages.
- Omitting monitoring – Not tying flag branches to separate metrics, making it impossible to decide when to roll back.
- Confusing flags with versioning – Suggesting a flag replaces the need for proper version control or CI pipelines.
- Forgetting failure modes – Not addressing what happens if the config store is unavailable; a good answer includes a fallback to the default value.
How to Practice This
- Pick a classic design problem (e.g., URL shortener) and draw a full architecture diagram on a canvas.
- Identify a single component where a new feature could be toggled, then add a feature-flag box with its config store and cache.
- Use System Design AI’s practice brief to run through the interview flow, focusing on explaining the flag’s purpose, rollout plan, and trade-offs.
Questions people ask
When should I bring up feature flags in an interview?
Mention them when you’re adding a new, risky component—like a new compression algorithm, a different storage engine, or a major change to request handling. They show you think about safe rollouts.
How do I handle a config-store outage?
Design the service to fall back to a hard-coded default (usually the stable path). If the store can’t be reached, the cached flag stays unchanged, and the service continues using the default until it restarts.
Do feature flags add noticeable latency?
When cached locally, the check is a simple memory read, adding only microseconds per request. That’s negligible compared to network or disk latency, but you should still mention the cost.
What’s the difference between a feature flag and a canary deployment?
Feature flags toggle code paths inside a single version, giving per-request control. Canary deployments run a separate version on a subset of servers, controlling traffic at the server level. Both mitigate risk, but flags are finer-grained.