patternModeratepending
Feature flags — implementing gradual rollouts and A/B testing
Viewed 0 times
feature flaggradual rolloutA/B testLaunchDarklykill switchcanary
nodejspythonbrowser
Problem
Deploying new features is all-or-nothing. If a feature breaks, you need to deploy a revert. Can't test features with a subset of users. Release and deploy are tightly coupled.
Solution
(1) Decouple deploy from release: deploy code with feature behind a flag, enable flag separately. (2) Simple implementation: const flags = { newCheckout: process.env.FF_NEW_CHECKOUT === 'true' }. (3) Percentage rollout: hash(userId + flagName) %% 100 < rolloutPercentage. (4) User targeting: enable for specific users, orgs, or segments. (5) Services: LaunchDarkly, Unleash (self-hosted), Flagsmith, PostHog. (6) Clean up: remove flags after full rollout — flag debt is real. Set expiry dates. (7) Testing: test both flag states in your test suite. (8) Types of flags: release (temporary), ops (kill switch), experiment (A/B test), permission (permanent).
Why
Feature flags let you ship code continuously without exposing unfinished features. They separate deployment (technical) from release (business), enabling gradual rollouts and instant rollbacks.
Revisions (0)
No revisions yet.