1.2 KiB
1.2 KiB
title, type, tags, sources, last_updated
| title | type | tags | sources | last_updated | ||||
|---|---|---|---|---|---|---|---|---|
| Feature Flag | concept |
|
|
2025-07-26 |
Definition
Feature Flag(特性开关)是一种将代码部署与功能发布分离的技术,允许在不重新部署的情况下通过配置切换代码执行路径。
Key Concepts
- Deploy != Release:部署代码但不立即向用户开放
- Kill Switch:紧急关闭机制,用于快速禁用问题功能
- 渐进式 Rollout:分阶段向用户群发布(1% → 5% → 25% → 100%)
Benefits for RTO/RPO
- RTO:从小时级降至秒级(只需关闭开关)
- RPO:Rollback 时不丢失数据,只需切换代码路径
Code Example
if (featureFlag.enabled('new-checkout-flow')) {
return newCheckoutProcess();
} else {
return oldCheckoutProcess();
}
Connections
- Kill Switch ← 紧急机制 → Feature Flag
- 渐进式发布 ← 发布策略 → Feature Flag
- RTO (Recovery Time Objective) ← 降低工具 → Feature Flag
- RPO (Recovery Point Objective) ← 保护工具 → Feature Flag
- LaunchDarkly ← 平台 → Feature Flag