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 ...
随机推荐
- hdu 1963 Investment 多重背包
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1963 //多重背包 #include <cstdio> #include <cstr ...
- Codevs 1003 电话连线
时间限制: 1 s 空间限制: 128000 K 题目等级 : 黄金 Gold 题目描述 Description 一个国家有n个城市.若干个城市之间有电话线连接,现在要增加m条电话线(电话线当 ...
- cocos2d-x 节点操作 -->J2ME
cocos2d-x 的节点操作涉及到以下几点 1. 节点之间的关系 2. 节点的添加操作 3. 节点的删除操作 4. ...
- Linux命令行提示符设置
我们使用Linux系统时接触最多的是它的命令行窗口,很多时候我们都需要在命令行上输入命令,在输入的命令前都会有提示符,一般系统默认的提示符形式是:[username@host 工作目录]$. 其实,我 ...
- Linux C 程序 GTK+图形界面编程(22)
GTK+图形界面编程 Linux大多是在字符界面,但也可以开发图形界面 目前已经存在多种Linux下开发图形界面的程序开发包:最常用的是Qt和GTK+ Qt是一个跨平台的图形界面开发库,不仅仅支持Li ...
- 【Qt】Qt之自定义界面(窗体缩放-跨平台终极版)【转】
简述 通过上一节内容,我们实现了窗体的缩放,功能很不错,但是很遗憾-不支持跨平台!如果对于多平台来说,这是一个硬伤,所以,我们急需要一个能够支持跨平台的实现方案. 在网上看到过很多不同的实现方式,多多 ...
- Messagebox.Show()常用参数设置
private void button1_Click(object sender, EventArgs e) { MessageBox.Show(" 1 个参数 " ); } pr ...
- jasonTree多选多级树控件
jasonTree1.0 jasonTree多选多级树控件(名字是自己取),用于友好的展示树形结构的数据,并可以多选,传统的做法是在一个select的下拉框中显示一个可折叠的树结构,公司的需求人员这种 ...
- centos5.4下mysql主从复制
centos5.4下mysql主从复制配置分享. 本文转自:http://www.jbxue.com/article/771.html 安装环境:centos 5.4 mysql版本:mysql 5. ...
- Android之“Unfortunately,xxx has stopped!”
初学Android遇到Unfortunately,xxx has stopped!真是一件让人头疼的事情,下面就遇到的两种可能情况给出解决方案.通常遇到的情况在于由一个Activity跳转至另一个Ac ...