Feature Flag-Based Deployment
What you'll learn: How to use feature flags to control which ML model version serves traffic, enabling instant rollback and granular rollout control without redeploying code.
The Core Idea
Feature flags (also called feature toggles) act like runtime switches that determine which model version serves predictions. Instead of hard-coding model selection or requiring new deployments, you externalize the routing logic into configurable flags that can be toggled instantly—often through a dashboard or API.
Think of it like a railway switchman: trains (requests) arrive continuously, and you can redirect them to track A (model v1) or track B (model v2) by flipping a lever, without stopping service or rebuilding the tracks.
How It Works in Production
You deploy multiple model versions simultaneously, then use feature flags to control routing:
- Targeted rollout: Route 5% of users to the new model, 95% to the old one
- User segmentation: Show model v2 only to premium users or specific regions
- Instant rollback: If v2 misbehaves, flip the flag back to v1 in seconds
- Dark launching: Route traffic to v2 but don't show predictions (for shadow testing)
Unlike canary or blue-green deployments that operate at the infrastructure level, feature flags give you application-level control with finer granularity.
Combining with A/B Testing
Feature flags enable sophisticated A/B tests where treatment assignment happens at the application layer. You can:
- Gradually increase exposure based on confidence
- Roll out to specific cohorts first
- Kill switches for emergencies
This complements your shadow, canary, and rolling deployment strategies by adding a dynamic, real-time control layer.
Key Takeaway: Feature flag-based deployment decouples model deployment from activation, giving you instant, reversible control over which model serves which users—critical for safe, progressive ML rollouts.