问题描述
我正在使用 AWS 部署 dockerized FastAPI 项目.任务定义选择FARGATE,Task Memory 512,Task CPU 256.
I am using AWS to deploy dockerized FastAPI project. I choosed FARGATE for task definition and Task Memory is 512, Task CPU is 256.
ECS 服务发送垃圾邮件GET/HTTP/1.1";404 Not Found'本身并关闭然后响应503.
ECS service is spamming '"GET / HTTP/1.1" 404 Not Found' itself and shutting down then responsing 503.
你知道为什么吗?
谢谢
推荐答案
那些看起来像是负载均衡器健康检查.
Those look like load balancer health checks.
运行状况检查是一种检查服务器是否仍然可用并已启动的方法,大多数情况下这是根据响应的状态代码确定的.
Health checks are a way of checking if a server is still available and is up, which is determined most of the time from the status code of the response.
负载均衡器会定期向每台服务器询问这个问题,以确定哪些服务器可以安全地将流量引导至.
Load balancers ask each server this question periodically to determine which servers are safe to direct traffic to.
在这种情况下,您的 Fargate 容器前面似乎有一个 ALB/NLB(应用程序/网络负载均衡器),并启用了运行状况检查.
In this case, it looks like you have an ALB/NLB (Application/Network Load Balancer) which is in front of your Fargate containers, with health checks enabled.
健康检查也最有可能寻找 200 OK &当您在 Fargate 中运行的应用程序返回 404 Not Found for GET/
时,健康检查失败并且 Fargate 正在关闭任务.
The health check is also most likely looking for 200 OK & as your application running in Fargate is returning 404 Not Found for GET /
the health check is failing and Fargate is shutting the task down.
您有多种选择:
- 将健康检查端点更改为返回 200 OK 的端点
- 改变
GET/
端点以返回 200 OK - 禁用健康检查
- Change the health check endpoint to an endpoint which returns 200 OK
- Alter the
GET /
endpoint to return 200 OK - Disable the health check
这篇关于AWS ECS 服务 FastAPI 项目是垃圾邮件“GET/HTTP/1.1"404 未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!