Architecture Intermediate
Feature Flags Implementation¶
Feature FlagsDeploymentRelease 3 min read
Gradual rollout of new features. Kill switches, percentage rollout, and A/B testing.
Types¶
- Release Toggle — gradual rollout (10% → 50% → 100%)
- Experiment — A/B testing
- Ops Toggle — kill switch
- Permission — features for specific plans
Implementation¶
class FeatureFlags {
isEnabled(flag, ctx = {}) {
const f = this.flags[flag];
if (!f?.enabled) return false;
if (f.percentage !== undefined) {
return (this.hash(ctx.userId) % 100) < f.percentage;
}
if (f.allowedUsers?.includes(ctx.userId)) return true;
return f.enabled;
}
}
// Configuration
const flags = new FeatureFlags({
newCheckout: { enabled: true, percentage: 25 },
darkMode: { enabled: true }
});
Tools¶
- LaunchDarkly — enterprise
- Unleash — open-source
- Flagsmith — open-source + cloud
Summary¶
A must-have for continuous delivery. Maintain discipline — regularly remove old flags.
Need Help with Implementation?¶
Our team has experience designing and implementing modern architectures. We’re happy to help.