Feature Flag
know more from here: https://www.youtube.com/watch?v=WMRjj06R6jg&list=UUkQX1tChV7Z7l1LFF4L9j_g
Feature flag: a way if exposing features to a sub-sent of your user base.
Release early, release often
Continuous integration is all about the entire team committing to master daily.
Small changes, shipped to production quickly, rather than living on feature branches, increase the velocity of new features and bug fixes reaching your customers.
But with most changes merged directly to master, how can you build new features with the confidence that shipping them won't have any impact on your customers, and only make it available once you're confident it's ready for prime time?
In a feature branch world, your new feature would be in the works for a while, changes are continuously merged in from master, making sure not to break anything.
But you won't know until it's finally merged and deployed to production whether your changes work.
How can you continuously ship new features to production with the confidence of not impacting your customers?
The answer is: feature flags.
A feature flag is a branching point that your code can utilize to determine whether or not a feature should be made available to one or more customers.
The original approach was made popular by the fine folks at Flickr. They needed a means to disable features when something is broken in production, to reduce the load on the database or on other parts of the system.
But feature flags can be used for much more than just disabling features in production.
Enable a feature only for a specific number of users, or even just for yourself to try it out in isolation.
Trial a new feature for a sample set of customers to compare how they're using it compared to the previous version of the feature.
This allows you to run experiments with actual users before you put it live. You can collect feedback and iterate based on real production usage.
Enable it for your team to try out and give feedback on. At GitHub, this is known as staff mode. Next time you see a hubber in the wild, peek at their version of GitHub, I'm sure you'll notice some subtle differences.
Enable a feature for a specific set of users, or just your team for them to try it out before it's rolled out for everyone.
When a feature finally is rolled out for everyone, you can decide case by case on whether you want to leave a global feature flag so you can disable a new feature in the future.
The three use cases can even be put together. First you roll out a new feature for yourself, so you can try it out in production. Next you enable it for your team, and then you enable if for a subset of users. Finally, you make it available for everyone.
How do I implement feature flags?
At the core, feature flags are simple configuration settings with Boolean values.
if Travis::Application.config.features.repository_settings?
# code to handle settings
end
This example uses a Rails built-in means to manage application configuration, storing flags as simple true/false key value pairs.
For a Rails project, you can store this configuration in an initializer file.
# config/initializers/features.rb
Travis::Application.config.features = {
repository_settings: true
}
For every new feature, you can add the setting here, leaving all of them in one place to find, disable and enable them easily. All it takes is one change and a redeploy to enable or disable a feature.
This mechanism allows you to only fully disable or enable something, and only with redeploying the entire app, which can sometimes be burdensome. It also lacks the finesse to enable features for specific users or groups of users.
Flagging features at runtime
A more dynamic approach is to store the feature configuration in either an ephemeral or permanent storage, like Redis or your database, respectively.
Assuming your code continuously checks feature flags at runtime, all it takes is changing a value in the central configuration service and it can have an immediate affect on the running application without requiring a restart.
James Golick's rollout is a popular library to implement dynamic feature flags for Ruby applications. It allows you to enable features for specific users, groups of users, a percentage of users, or disable and enable them entirely. Hey, that library covers all of our bases!
Not coincidentally, it's the one we're using for Travis CI.
Rather than store the data in a configuration file, you can store them in Redis, or any supported key value store. Instead of asking the application's configuration, you ask rollout whether a feature is enabled.
if rollout.active?(:repository_settings, current_user)
# settings logic goes here
end
Enabling a feature for a user is just as simple.
rollout.activate_user(:repository_settings, User.find_by_login('roidrage'))
You can segment users into groups as well, based on the flags a specific users. Our friends at Librato use a mechanism similar to this for segmenting out users they'd like to test new features before they're available for everyone, the beta list if you will.
rollout.define_group(:beta_testers) do |user|
user.beta?
end
Document feature flags
When feature flags are collected using a centralized store like Redis, it gets harder to track which flags are available, what their defaults should be, and which features they affect.
Make sure to keep simple documentation around where you collect feature flags to make sure the right ones are changed at the right time.
Feature flags at Travis CI
We're using rollout for our feature flags, but we've added a few more things that we need. Some features on Travis CI are only made available for certain repositories or certain accounts and all of their respective repositories.
Most of our feature flags are built for production runtime though. We have means to enable build scheduling, for instance during a maintenance, without taking down the entire process. That way we can still process actively running builds without scheduling new ones.
We've used feature flips to migrate to different implementations of something too. Originally, our user synchronization went through RabbitMQ and was handled by the same process that handles scheduling builds.
As we switched over to a process based on Sidekiq, we enabled our own users first to make sure the process works, before we finally enabled it for everyone. We eventually moved the feature flip, as the code that originally handled this part was deleted as well.
We're also using them to enable custom subscription plans for some of our customers.
Ship with confidence
Feature flags are very handy to roll out new features gradually, but they also give you higher control over your system running in production as well.
New features, even in raw shape, can be put to use and test in the production environment as soon as something is ready for trying out, and without impacting users unless you choose to.
On top of that, they give you a means to disable certain features during a production incident.
Is your project using feature flags or a similar means? Feel free to share your experiences in the comments.
Feature Flag的更多相关文章
- 给你的 ASP.NET Core 程序插上 Feature Flag 的翅膀
前言 我们知道,目前大多数应用程序在正式发布到生产环境之前都会经历多个不同的测试环境,通过让应用程序在多个不同的环境中运行来及时发现并解决问题,避免在线上发生不必要的损失.这是对于整个软件的发布流程来 ...
- Sentry 开发者贡献指南 - Feature Flag
功能 flag 在 Sentry 的代码库中声明. 对于自托管用户,这些标志然后通过 sentry.conf.py 进行配置. 对于 Sentry 的 SaaS 部署,Flagr 用于在生产中配置标志 ...
- 基于Feature Flag的下一代开发模式
渐进式发布(Progressive Delivery)被认为是持续发布(Continous Delivery)的下一代形态,其专注于增强发布过程控制与降低发布风险,最终提高整体收益.国际科技巨头比如A ...
- 微软Azure配置中心 App Configuration (二):Feature Flag 功能开关特性
写在前面 Web服务开发过程中我们经常有这样的需求: 某些功能我必须我修改了配置才启用,比如新用户注册送券等: 某个功能需到特定的时间才启用,过后就失效,比如春节活动等: 某些功能,我想先对10%的用 ...
- 【亲述】Uber容错设计与多机房容灾方案 - 高可用架构系列
此文是根据赵磊在[QCON高可用架构群]中的分享内容整理而成.转载请事先联系赵磊及相关编辑. 赵磊,Uber高级工程师,08年上海交通大学毕业,曾就职于微软,后加入Facebook主要负责Messen ...
- 使用Trello实现敏捷项目管理
使用Trello实现敏捷项目管理 作者 侯伯薇 发布于 五月 24, 2012 | 1 讨论 新浪微博腾讯微 ...
- 八卦某 G 的前端开发方式及流程
他山之石,可以攻玉. 话说本人从毕业到现在一直在某 B 公司工作,前些年折腾过不少开发方式和工具,但总觉得或许有更好的方案,所以很好奇其它公司内部是如何工作的,我曾经浏览过某 Y 公司内部无所不包 ...
- Package org.xml.sax Description
This package provides the core SAX APIs. Some SAX1 APIs are deprecated to encourage integration(集成:综 ...
- Linux 内核使用的 GNU C 扩展
gcc核心扩展linuxforum(转)=========================== Linux 内核使用的 GNU C 扩展 =========================== GNC ...
随机推荐
- 模板template
1.模板就是实现代码重用机制的一种工具,它可以实现类型参数化,即把类型定义为参数,从而实现了真正的代码可重用性.模板可以分为两类,一个是函数模板,另一个是类模板. 2.函数模板的定义一般形式如下: t ...
- 在Java中怎样把数组转换为ArrayList?
翻译自:How to Convert Array to ArrayList in Java? 本文分析了Stack Overflow上最热门的的一个问题的答案,提问者获得了很多声望点,使得他得到了在S ...
- HTML5 manifest ApplicationCache
使用 HTML5,通过创建 cache manifest 文件,可以轻松地创建 web 应用的离线版本. HTML5引入了应用程序缓存,这意味着 web 应用可进行缓存,并可在没有因特网连接时进行访问 ...
- jsp探针
在网上找到一些jsp探针,收藏下. JSP探针1.jsp <%@ page contentType="text/html;charset=gb2312" %> < ...
- Silverlight动画的基本知识、关键帧动画
基础知识 (一)动画:是快速播放一系列图像(其中每个图像与下一个图像略微不同)给人造成的一种幻觉 (二)动画类型:两类 (1)From/To/By动画:在起始值和结束值之间进行动画处理. ...
- WordPress 主题开发 - (三) 开发工具 待翻译
Before we get started building any WordPress Theme, we’re going to need to get our development tools ...
- Super Object Toolkit (支持排序)
(* * Super Object Toolkit * * Usage allowed under the restrictions of the Lesser GNU General Public ...
- 机器学习实战——k-邻近算法:约会网站
1.kNN 算法 算法说明: set<X1,X2……Xn> 为已知类别数据集,预测 点Xt 的类别: (1)计算中的set中每一个点与Xt的距离 (2)按距离增序排列 (3)选择距离最小的 ...
- (菜鸟要飞系列)三,基于Asp.Net MVC5的后台管理系统(用户的增删改查功能)
这些天被项目,考试整昏了头脑,没时间更新,我已经将这一部分全部做完了,现在把代码放上来,大家可以自己研究,有问题可以私聊,这里把图放上来 http://download.csdn.net/detail ...
- ZOJ 2314 带上下界的可行流
对于无源汇问题,方法有两种. 1 从边的角度来处理. 新建超级源汇, 对于每一条有下界的边,x->y, 建立有向边 超级源->y ,容量为x->y下界,建立有向边 x-> 超级 ...