0

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.

FabAnn
  • 3
  • 2

1 Answers1

0

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.

Hayha
  • 2,144
  • 1
  • 15
  • 27
  • Firstly, thank you for your response! You are right... it seems the healthcheck was wrong... but I don't know how to set it correctly. I've tried to do some changes but it doesn't work. I always have only "draining" targets. – FabAnn Sep 04 '19 at 13:40
  • @FabAnn Your healthcheck has to point to any of your api endpoint with GET method and that return 200 status. Let's say you have an endpoint https://myapi.com/healthcheck that return 200 OK so your healthcheck path will be "/healthcheck" (path is relative) – Hayha Sep 04 '19 at 13:57
  • Thank you again. I have an application with `server.context-path=/student` and a rest controllr with `@GetMapping("/")` that responds with 200 OK... so I set the path to `/student/` but it doesn't work. The strange thing is that I have modified the health check port range to 200-499 and the application is reachable! – FabAnn Sep 04 '19 at 14:06