Search code examples
amazon-web-servicesamazon-ecsamazon-vpcaws-application-load-balancer

ECS (Fargate) healthcheck running multiple times


I am running an ECS Fargate task fronted by an ALB. There is one target group associated with the ALB which is running health-checks every 30 seconds on it's target (one ECS fargate task).

enter image description here

However, it seems to be hitting the healtcheck endpoint 3 times every 30 seconds, see logs.

2023-06-08 09:24:29 ENDPOINT: GET /healthcheck
2023-06-08 09:24:29 ENDPOINT: GET /healthcheck
2023-06-08 09:24:29 ENDPOINT: GET /healthcheck
2023-06-08 09:23:59 ENDPOINT: GET /healthcheck
2023-06-08 09:23:59 ENDPOINT: GET /healthcheck
2023-06-08 09:23:59 ENDPOINT: GET /healthcheck
2023-06-08 09:23:29 ENDPOINT: GET /healthcheck
2023-06-08 09:23:29 ENDPOINT: GET /healthcheck
2023-06-08 09:23:29 ENDPOINT: GET /healthcheck
2023-06-08 09:22:59 ENDPOINT: GET /healthcheck
2023-06-08 09:22:59 ENDPOINT: GET /healthcheck
2023-06-08 09:22:59 ENDPOINT: GET /healthcheck

The only reason I can think of is that the VPC spans 3AZs, as does the ALB. But I thought that given there is only one target group (and one task running), there should only be one call to the healtcheck endpoint every 30 seconds? Is the expected behaviour?


Solution

  • The only reason I can think of is that the VPC spans 3AZs, as does the ALB.

    That is exactly why you are seeing three health checks for each health check period. The health checks are coming from each AZ that the ALB is deployed to.

    But I thought that given there is only one target group (and one task running), there should only be one call to the healtcheck endpoint

    You can think of the target group like a configuration file that you are providing the load balancer. The load balancer is actually performing the health checks. And since the load balancer is deployed across multiple AZs you are getting health check requests from each of those AZs. Behind the scenes there are actually separate load balancer servers deployed in each AZ, each one performing their own health check requests.

    Is the expected behaviour?

    Yes