How do you implement feature flags and progressive rollouts in custom software?
Feature flags decouple deployment from release, enabling safe progressive rollouts and experimentation. Architecture: feature flag service (LaunchDarkly, Unleash, or custom implementation) stores flag definitions, evaluation SDK embedded in the application checks flags at runtime, and a management UI allows non-developers to toggle features. Implementation: wrap new feature code in flag checks, evaluate flags on both server and client side, cache flag values with short TTL for performance, and implement fallback behavior when the flag service is unavailable. Flag types: release flags (toggle features on/off for gradual rollout), experiment flags (A/B test variants with metrics tracking), ops flags (circuit breakers for degraded mode), and permission flags (feature gating by user tier). Progressive rollout: start at 1% of users, monitor error rates and performance, increase to 10%, 25%, 50%, 100% with monitoring at each stage. Target specific cohorts: internal users first, then beta users, then geographic regions. Custom implementation: store flags in a database table (name, enabled, percentage, userrules), evaluate using consistent hashing on user ID for deterministic assignment, implement an SDK that caches evaluations, and provide a React context for client-side access. Flag lifecycle: create flag before development, enable in development and staging, progressive rollout in production, verify metrics, remove flag and dead code after full rollout. Technical debt: schedule flag cleanup in the sprint after full rollout, never let permanent flags accumulate without review.