[Turn] publish and gradation A / B testing

# What is gray publish, publish and gray A / B testing

in general, upgrade the server application, you need to application source code or packages uploaded to the server, and then stop off the old version of the service, and then start the new version. But there is such a simple way to publish two issues, on the one hand, the new version of the upgrade process, the service is temporarily interrupted, on the other hand, if there is a new version of BUG, the upgrade fails, the rollback is also very troublesome, likely to cause longer service is unavailable.

In order to solve these problems, we developed a variety of release strategy, here we introduced one by one.



## blue-green deploy



so-called blue-green deployment, refers to the simultaneous operation of two versions of the application, as shown above, when the blue-green deployments, do not stop out of the old version, but directly deploy a new version, such as the new version after running, then the traffic is switched to the new version. But the blue-green deployment requirements during the upgrade process, run two programs at the same time, demand for hardware is required twice daily, such as daily operation, you need 10 servers to support business, then use the blue-green deployment, you will need to purchase 20 Taiwan server.



## rolling release

rolling release can get rid of the problem when the blue-green deploying hardware requirements to be raised.



The so-called rolling upgrade, that is, during the upgrade process, not all of a sudden start all new versions, is to launch a new version, and then stop an old version, and then start a new version, and then stop an old version until the upgrade is complete , so, if the daily needs of 10 servers, the upgrade process will only need 11 stations on the line.

But there is a problem rolling upgrade, after the start of rolling upgrade, traffic will flow directly to the new version has been started up, but this time, the new version is not always available, such as the need for further testing to confirm. So during a rolling upgrade, the entire system is in a very unstable state, if problems are found, the problem is also more difficult to determine the new version or an old version caused.

To solve this problem, we need to implement flow control capability is rolling upgrade.

## 灰度发布

灰度发布也叫金丝雀发布,起源是,矿井工人发现,金丝雀对瓦斯气体很敏感,矿工会在下井之前,先放一只金丝雀到井中,如果金丝雀不叫了,就代表瓦斯浓度高。



在灰度发布开始后,先启动一个新版本应用,但是并不直接将流量切过来,而是测试人员对新版本进行线上测试,启动的这个新版本应用,就是我们的金丝雀。如果没有问题,那么可以将少量的用户流量导入到新版本上,然后再对新版本做运行状态观察,收集各种运行时数据,如果此时对新旧版本做各种数据对比,就是所谓的A/B测试。

当确认新版本运行良好后,再逐步将更多的流量导入到新版本上,在此期间,还可以不断地调整新旧两个版本的运行的服务器副本数量,以使得新版本能够承受越来越大的流量压力。直到将100%的流量都切换到新版本上,最后关闭剩下的老版本服务,完成灰度发布。

如果在灰度发布过程中(灰度期)发现了新版本有问题,就应该立即将流量切回老版本上,这样,就会将负面影响控制在最小范围内。

## 使用脉冲云轻松地实现灰度发布

脉冲云的部署管理可以轻松实现上述的带有流量管理功能的灰度发布。正常编辑应用信息后点击保存,然后脉冲云会提示直接升级或灰度发布。



直接升级就是使用一般的滚动升级,点击灰度发布后可以人工干预升级过程,进行流量控制。

选择灰度发布后,就会呈现灰度发布控制面板。



在这个控制面板上,可以拖拉滑块,快速调整新旧版本的运行副本数量,同时也可以按百分比,将流量导入到新版本上。此外,还可以通过匹配HTTP Header,指定个别用户的流量到新版本上。



除了匹配用户流量的HTTP请求头,还可以直接指定匹配请求头中的Cookie信息,匹配规则支持精确匹配、包含、正则、前缀、后缀等,甚至还允许反向匹配。

当确认新版本运行无误后,就可以点击 **完成升级** 按钮,就会将流量全部切换到新版本上,并且销毁掉所有老版本应用。如果新版本出了问题,可以点击 取消升级 按钮,立即将流量切回老版本,并销毁掉新版本应用。






## 总结

在新版本应用发布时,为了服务器不停机升级,使用灰度发布策略,在灰度发布开始时,使用HTTP Header 匹配指定测试人员的流量到新版本上,然后当新版本内部测试通过后,可以再按百分比,将用户流量一点一点导入到新版本中,比如先导入10%观察一下运行情况,然后再导入20%,如此累加,直到将流量全部导入到新版本上,最后完成升级,如果期间发现问题,就立即取消升级,将流量切回到老版本。

运用灰度发布,就再也不需要加班到深夜进行停机升级了,在白天就可以放心大胆地、安全地发布新版本。

相关资料:

脉冲云:脉冲云

灰度发布视频:
https://v.youku.com/v_show/id_XMzc4OTU3OTA3Mg==.html?spm=a2h3j.8428770.3416059.1

Guess you like

Origin www.cnblogs.com/xxbktest/p/11639973.html