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 service is spamming '"GET / HTTP/1.1" 404 Not Found' itself and shutting down then responsing 503.
Do you know why?
Thanks
CodePudding user response:
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.
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.
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.
You have multiple options:
- Change the health check endpoint to an endpoint which returns 200 OK
- Alter the
GET /
endpoint to return 200 OK - Disable the health check