0
votes

The SpringBoot application is running as an ECS Task in a ECS Service of an AWS Fargate Cluster. The ECS Service is LoadBalanced as such the Tasks spawned by the Services are automatically registered to a target group.

I am able to call the Health endpoint via API Gateway => VPC Link => Network ELB => Application ELB => ECS Task, as shown below:

Call from Postman

However, the HealthChecks seem to be failing and as such, the tasks are being deregistered continously resulting in totally unusable setup.

ECS Service Events

I have made sure to configure the HealthCheck of the Target Group point towards the right endpoint URL, as shown below:

Health Check Settings

I also made sure that the Security Group that the Fargate Tasks belong in allows traffics from the Application Load Balancer, as shown below:

Security Group for ECS Tasks

But somehow, the HealthChecks kept failing and the tasks are being deregistered, and I'm very confused!

Your help is much appreciated!

1
Maybe you app does not return 200 code, but redirection code (301 or 302). Maybe it uses different port? There is a lot of info missing from your question.Marcin
@Marcin According to my postman the endpoint does return a 200 code! and I've already made sure that everything's running on port 80.Wei Minn
The last SG is for fargete? If so it should allow ALL incomming ports, not only 80, due to dynamic port mapping between ALB and fargate.Marcin
@Marcin, I tried that; still doesn't work! It's really weird that other ECS Services in the same Security groups, were in the same situation for a few hours then, they passed their health checks and are now in stable state.Wei Minn

1 Answers

0
votes

The problem actually is with the Health Check Intervals (30 seconds) and Threshold (2 checks) which is too frequent when the Task is just starting up and is unable to respond to the HTTP request.

So, I increased the interval and the threshold, and everything is fine now!