Feature Flags & Progressive Rollouts: Ship Faster Without Breaking Things
Feature Flags & Progressive Rollouts#
The most dangerous moment in software is deployment. Feature flags eliminate the risk by decoupling deployment from release — code ships to production but stays hidden until you're ready.
The Problem#
Without flags:
Deploy new checkout → 100% of users get it immediately
Bug in new checkout → 100% of users affected
Rollback → redeploy old version (5-30 minutes downtime)
With flags:
Deploy new checkout (flag OFF) → 0% of users see it
Enable for 5% → monitor errors → looks good
Ramp to 25% → 50% → 100%
Bug found at 25%? → flip flag OFF instantly (< 1 second)
Types of Feature Flags#
1. Release Flags (Temporary)#
Gate new features during rollout. Remove after 100% launch.
if (flags.isEnabled("new-checkout", user)) {
return <NewCheckout />;
}
return <OldCheckout />;
2. Experiment Flags (A/B Tests)#
Compare two versions to measure which performs better.
const variant = flags.getVariant("pricing-page", user);
// variant: "control" | "variant-a" | "variant-b"
3. Ops Flags (Kill Switches)#
Disable expensive features during incidents.
if (flags.isEnabled("recommendations-engine")) {
return await getRecommendations(user);
}
return []; // graceful degradation
4. Permission Flags (Long-lived)#
Gate features by plan, role, or entitlement.
if (flags.isEnabled("advanced-exports", user)) {
return <ExportModal showPro={true} />;
}
Progressive Rollout Strategies#
Percentage Rollout#
Day 1: 1% of users (internal + beta)
Day 2: 5% (monitor error rates)
Day 3: 25% (monitor performance)
Day 5: 50%
Day 7: 100% → remove flag
User Targeting#
Phase 1: Internal employees only
Phase 2: Beta program users
Phase 3: Users in US region
Phase 4: All users
Ring-Based Deployment#
Ring 0: Developers (dogfooding)
Ring 1: 1% canary users
Ring 2: 10% early adopters
Ring 3: 100% general availability
Architecture#
Client-Side Evaluation#
App starts → fetch flag config from CDN → evaluate locally
→ no server round-trip per check
Fast (< 1ms). Config updates via SSE/polling. Good for frontend.
Server-Side Evaluation#
Request → server evaluates flag → returns appropriate response
Secure (rules not exposed). Good for backend, API features.
Hybrid#
Frontend flags → client-side SDK (LaunchDarkly, PostHog)
Backend flags → server-side SDK
Both sync from same flag service
Implementation Patterns#
Simple In-Code#
// Don't do this in production (no remote control)
const FLAGS = {
newCheckout: process.env.FEATURE_NEW_CHECKOUT === "true",
};
With Context (User Targeting)#
const flags = await flagService.evaluate({
userId: user.id,
email: user.email,
plan: user.plan, // "free" | "pro" | "enterprise"
country: user.country,
percentile: hash(user.id) % 100, // stable percentage bucket
});
if (flags.newCheckout) {
// User is in the rollout
}
Stable Bucketing#
Same user always gets same flag value (no flickering):
// hash(userId) % 100 gives stable 0-99 value
const bucket = murmurhash(userId) % 100;
const isEnabled = bucket < rolloutPercentage; // e.g., < 25 for 25%
Tools Compared#
| Tool | Type | Best For | Pricing |
|---|---|---|---|
| LaunchDarkly | Managed | Enterprise, complex rules | $$$ |
| Unleash | Open-source | Self-hosted, full control | Free / paid |
| PostHog | Product analytics + flags | A/B tests + analytics together | Free tier |
| Flagsmith | Open-source | API-first, self-hosted | Free / paid |
| ConfigCat | Managed | Simple, affordable | $ |
| Statsig | Managed | Experiment-heavy teams | Free tier |
| GrowthBook | Open-source | Bayesian A/B testing | Free |
| Vercel Edge Config | Edge | Next.js, ultra-low latency | Included |
Quick Decision#
- Enterprise with complex rules → LaunchDarkly
- Self-hosted + open source → Unleash or Flagsmith
- A/B testing + product analytics → PostHog or Statsig
- Simple + cheap → ConfigCat or env vars
- Next.js edge → Vercel Edge Config
Best Practices#
- Temporary flags get removed — set expiry dates, track flag debt
- Default to OFF — new flags should be disabled by default
- Stable bucketing — same user always sees same variant
- Flag naming convention —
feature.new-checkout,ops.disable-recommendations - Monitor per-flag metrics — error rates, latency, conversion per cohort
- Don't nest flags —
if (flagA && flagB && !flagC)is unmaintainable - Audit trail — log who changed what flag when
Anti-Patterns#
- Flag debt — 500 flags, nobody knows which are active. Clean up after launch.
- Flags in database queries — checking flags inside SQL WHERE clauses
- Testing without flags — tests should cover both flag-on and flag-off paths
- Flags as config — feature flags are temporary. Use config for permanent settings.
Architecture Example#
Client SDK → Flag Service (CDN-cached config)
↓ SSE stream (real-time updates)
→ Evaluate flag for user context
→ Render appropriate UI
Server SDK → Flag Service (server-side eval)
↓
→ Return flagged API response
Flag Service:
→ Dashboard (create/edit flags)
→ Targeting rules (%, user attributes, segments)
→ Audit log
→ Metrics (per-flag impact)
Design your deployment architecture at codelit.io — generate interactive diagrams with CI/CD exports.
Summary#
- Decouple deploy from release — ship code anytime, enable when ready
- Progressive rollout — 1% → 5% → 25% → 100%, monitoring at each step
- Kill switches for graceful degradation during incidents
- A/B tests for data-driven decisions
- Clean up flag debt — every flag should have an owner and expiry
- Stable bucketing — hash user ID, not random per request
118 articles on system design at codelit.io/blog.
Try it on Codelit
Chaos Mode
Simulate node failures and watch cascading impact across your architecture
GitHub Integration
Paste a repo URL and generate architecture from your actual codebase
Related articles
Try these templates
Netflix Video Streaming Architecture
Global video streaming platform with adaptive bitrate, CDN distribution, and recommendation engine.
10 componentsSearch Engine Architecture
Web-scale search with crawling, indexing, ranking, and sub-second query serving.
8 componentsGoogle Search Engine Architecture
Web-scale search with crawling, indexing, PageRank, query processing, ads, and knowledge graph.
10 componentsBuild this architecture
Generate an interactive architecture for Feature Flags & Progressive Rollouts in seconds.
Try it in Codelit →
Comments