Search code examples
amazon-ecsaws-elb

ECS + ALB - My applications only respond a few times


I've developed two spring boot applications for microservices and I've used ECS to deploy these applications into containers. To do this, I followed the official pet clinic example (https://github.com/aws-samples/amazon-ecs-java-microservices/tree/master/3_ECS_Java_Spring_PetClinic_CICD). All seems to works correctly, but when I make a request to the ALB very often I receive the 502 or 503 HTTP error and a few times I can see the correct response of the applications. Can someone help me? Thanks in advance.


Solution

  • You receive a 502 when you have no healthy task running and 503 when task is starting/restarting.

    All of this mean that your task got stopped and then your cluster restart it, so you should find what make your task failed.

    It can be something directly in your code that make it crash. or it can be the cluster healthcheck defined in your target group that failed.

    Firstly you should look your task in the AWS ECS Console and see what error your task receive when it's stopped.

    But as you are able to make request for some time and then it failed. I pretty sure your problem come from your healthcheck. So go in your target group used by the task (in AWS EC2 Console) and make sure the healthcheck path configured exist and returned a 200 status code.