部署时暂时无法使用AWS ECS 503服务 [英] AWS ECS 503 Service Temporarily Unavailable while deploying

查看:181
本文介绍了部署时暂时无法使用AWS ECS 503服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Amazon Web Services EC2容器服务与适用于我的应用程序的应用程序负载平衡器一起使用.部署新版本时,大约两分钟的时间,我会得到503服务暂时不可用.它比我的应用程序的启动时间还多. 这意味着我现在无法进行零停机时间部署.

I am using Amazon Web Services EC2 Container Service with an Application Load Balancer for my app. When I deploy a new version, I get 503 Service Temporarily Unavailable for about 2 minutes. It is a bit more than the startup time of my application. This means that I cannot do a zero-downtime deployment now.

是否有设置在启动新任务时不使用它们?还是我在这里想念什么?

Is there a setting to not use the new tasks while they are starting up? Or what am I missing here?

更新:

ALB目标组的健康检查号码如下:

The health check numbers for the target group of the ALB are the following:

Healthy threshold:     5
Unhealthy threshold:   2
Timeout:               5 seconds
Interval:              30 seconds
Success codes:         200 OK

健康阈值是在考虑不健康目标之前,需要连续进行健康检查的次数"
不健康阈值是在考虑目标不健康之前需要进行的连续健康检查失败的次数."
Timeout 是以秒为单位的时间,在此时间内没有响应表示运行状况检查失败."
Interval 是单个目标的两次健康检查之间的大概时间"

Healthy threshold is 'The number of consecutive health checks successes required before considering an unhealthy target healthy'
Unhealthy threshold is 'The number of consecutive health check failures required before considering a target unhealthy.'
Timeout is 'The amount of time, in seconds, during which no response means a failed health check.'
Interval is 'The approximate amount of time between health checks of an individual target'

更新2: 因此,我的集群由两个EC2实例组成,但是可以根据需要进行扩展.所需的最小计数是2.由于我的应用程序需要特定的端口号,因此每个实例运行一个任务.在部署之前(jenkins运行aws cli脚本),我将实例数设置为4.否则,AWS无法部署新任务(这是另一个要解决的问题).联网模式为桥接.

UPDATE 2: So, my cluster consists of two EC2 instances, but can scale up if needed. The desired and minimum count is 2. I run one task per instance, because my app needs a specific port number. Before I deploy (jenkins runs an aws cli script) I set the number of instances to 4. Without this, AWS cannot deploy my new tasks (this is another issue to solve). Networking mode is bridge.

推荐答案

因此,问题似乎出在任务定义中我的容器设置的端口映射上. 在我将80用作主机并将8080用作容器端口之前.我以为我需要使用这些,但是主机端口实际上可以是任何值.如果将其设置为0,则ECS将在32768-61000范围内分配端口,因此可以将多个任务添加到一个实例.为了使其正常工作,我还需要更改安全组,以使流量从ALB到这些端口上的实例.
因此,当ECS可以在同一实例上运行多个任务时,合理的50/200 min/max正常运行百分比是有意义的,并且可以进行新任务修订的部署而无需添加新实例.这也确保了零停机时间的部署.

So, the issue seems to lie in the port mappings of my container settings in the task definition. Before I was using 80 as host and 8080 as container port. I thought I need to use these, but the host port can be any value actually. If you set it to 0 then ECS will assign a port in the range of 32768-61000 and thus it is possible to add multiple tasks to one instance. In order for this to work, I also needed to change my security group letting traffic come from the ALB to the instances on these ports.
So, when ECS can run multiple tasks on the same instance, the 50/200 min/max healthy percent makes sense and it is possible to do a deploy of new task revision without the need of adding new instances. This also ensures the zero-downtime deployment.

感谢所有询问或发表评论的人!

Thank you for everybody who asked or commented!

这篇关于部署时暂时无法使用AWS ECS 503服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆