部署时 AWS ECS 503 服务暂时不可用 [英] AWS ECS 503 Service Temporarily Unavailable while deploying

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

问题描述

我将 Amazon Web Services EC2 Container Service 与应用程序负载均衡器一起用于我的应用程序.当我部署一个新版本时,我得到 503 Service Temporively Unavailable 大约 2 分钟.它比我的应用程序的启动时间多一点.这意味着我现在无法进行零停机部署.

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

健康阈值是在考虑不健康目标健康之前需要连续成功检查的次数"
不健康阈值是在考虑目标不健康之前所需的连续健康检查失败次数."
超时是没有响应意味着健康检查失败的时间量,以秒为单位."
间隔是对单个目标进行健康检查之间的大致时间间隔"

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 最小/最大健康百分比是有意义的,并且可以在不需要添加新实例的情况下部署新任务修订版.这也确保了零停机部署.

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天全站免登陆