简体   繁体   English

如何处理 AWS elasticbeanstalk 上的金丝雀发布?

[英]How to handle canary releases on AWS elasticbeanstalk?

I have previously seen it done by having one EC2 instance running HAProxy, configured via a json file/lambda function, that in turn controlled the traffic with sticky sessions, into two separate elasticbeanstalk applications.我之前看到它是通过让一个运行 HAProxy 的 EC2 实例完成的,通过 json 文件/lambda function 配置,这反过来控制具有粘性会话的流量,进入两个单独的 elasticbeanstalk 应用程序。 So we have two layers of load balancing.所以我们有两层负载平衡。

However, this has a few issues, one being: Testing several releases becomes expensive, requires more and more EB applications.然而,这有一些问题,其中之一是:测试多个版本变得昂贵,需要越来越多的 EB 应用程序。

By canary release, I mean, being able to release to only a percentage of traffic, to figure out any errors that escaped the devs, the review process, and the QA process, without affecting all traffic.通过金丝雀发布,我的意思是,能够只发布一定比例的流量,找出逃过开发人员、审查过程和 QA 过程的任何错误,而不影响所有流量。

What would be the best way to handle such a setup with AWS resources and not break the bank?使用 AWS 资源处理此类设置而又不破产的最佳方法是什么? :) :)

I found this Medium article that explain the usage of passive autoscaling group where you deploy the canary version into it and monitor for statistics.我发现这篇 Medium 文章解释了被动自动缩放组的用法,您可以在其中部署金丝雀版本并监控统计信息。 Once you are satisfied with the result, you can change the desired count for the canary autoscaling group to 0, and perform rolling upgrade to the active autoscaling group.对结果满意后,您可以将 Canary 自动伸缩组的所需计数更改为 0,并滚动升级到活动的自动伸缩组。

Here is the link to the article: https://engineering.klarna.com/simple-canary-releases-in-aws-how-and-why-bf051a47fb3f这是文章的链接: https : //engineering.klarna.com/simple-canary-releases-in-aws-how-and-why-bf051a47fb3f

The way you would achieve canary testing with elastic beanstalk is by使用弹性豆茎实现金丝雀测试的方法是

  1. Create a 2nd beanstalk environment to which you deploy the canary release创建您部署金丝雀版本的第二个 beanstalk 环境
  2. Use a Route53 Weighted routing policy to send a percentage of the DNS requests to your canary environment.使用 Route53 加权路由策略将一定比例的 DNS 请求发送到您的 Canary 环境。
  3. If you're happy with the performance of the canary you can then route 100% of the traffic to the canary env, etc.如果您对 Canary 的性能感到满意,则可以将 100% 的流量路由到 Canary env 等。

Something to keep in mind with DNS routing is, that the weighted routing is not an exact science since clients cache DNS based on the TTL you set in Route53. DNS 路由要记住的是,加权路由不是一门精确的科学,因为客户端根据您在 Route53 中设置的 TTL 缓存 DNS。 In the extreme scenario where you would have eg only one single client calling your beanstalk environment (such as aa single web server) and the TTL is set to 5 minutes, it could happen that the switching between environments only happens every 5 minutes.在极端情况下,例如只有一个客户端调用您的 beanstalk 环境(例如单个 Web 服务器)并且 TTL 设置为 5 分钟,环境之间的切换可能仅每 5 分钟发生一次。

Therefore for weighted routing it is recommended to use a fairly low TTL value.因此,对于加权路由,建议使用相当低的 TTL 值。 Additionally having many clients (eg mobile phones) works better in conjunction with DNS routing.此外,拥有多个客户端(例如移动电话)与 DNS 路由结合使用效果更好。

Alternatively it might be possible to create a separate LB in front of the two beanstalk environments that balances requests between the beanstalk environments.或者,也可以在两个 beanstalk 环境之前创建一个单独的 LB,以平衡 beanstalk 环境之间的请求。 However I'm not 100% sure if a LB can sit in front other (beanstalk) LBs.但是,我不能 100% 确定 LB 是否可以坐在其他(豆茎)LB 前面。 I suspect the answer is not but I haven tried yet.我怀疑答案不是,但我还没有尝试过。

Modifying the autoscaling group in elastic beanstalk is not possible, since the LB is managed by beanstalk and beanstalk can decide to revert the changes you did manually on the LB.修改弹性 beanstalk 中的自动缩放组是不可能的,因为 LB 由 beanstalk 管理,beanstalk 可以决定恢复您在 LB 上手动所做的更改。 Additionally beanstalk does not allow you to deploy to a subset of instances while keeping the older version on another subset.此外,beanstalk 不允许您部署到实例的子集,同时将旧版本保留在另一个子集上。

Hope this helps.希望这会有所帮助。

Traffic splitting is supported natively by Elastic Beanstalk. Elastic Beanstalk 原生支持流量拆分。

Be sure to select a "high availability" config preset when creating your application environment (by clicking on "configure more options"), as this will configure a load balancer for your env:确保在创建应用程序环境时(通过单击“配置更多选项”)select 预先设置“高可用性”配置,因为这将为您的环境配置负载均衡器:

选择高可用性配置

Then edit the "Rolling updates and deployments" section of your environment and choose "Traffic splitting" as your deployment strategy.然后编辑您环境的“滚动更新和部署”部分,并选择“流量拆分”作为您的部署策略。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM