Troubleshooting solutions for health check failures in AWS ECS

UnknownUnknown
1 min read

I am sharing the troubleshooting details of the issues I encountered while configuring the AWS ECS cluster. I hope the following solutions help you resolve your problems. If these methods do not work, please feel free to reach out anytime.

In this case, the frontend is developed and run using Next.js, while the backend is developed and run using Spring Boot.

  1. Ensure that the packages used for health checks, such as curl and wget, are properly installed in the container image!

  2. Double-check the command used for internal health checks in the AWS ECS container.

    1. Next.js (frontend)

      CMD-SHELL,wget -qO- http ://127.0.0.1:3000/health-check --server-response 2>&1 | grep -q 'HTTP/1.1 308|HTTP/1.1 200' || exit 1
      (watch out space after http)
      
    2. SpringBoot(backend)

      • Must create health-check endpoint
        CMD-SHELL,curl -f http ://127.0.0.1:8080/health-check || exit 1
        (watch out space after http)
        
  3. Verify the path of the health check for the target group in the AWS ALB.

    1. Next.js

      1. In the case of Next.js, response headers may return codes like 307 or 308 instead of 200.
  4. For Spring Boot applications, consider setting a longer interval for health checks due to the possibility of cold starts.

    1. Interval : 30

    2. Retries : 10

    3. StartPeriod : 60

    4. Timeout : 60

1
Subscribe to my newsletter

Read articles from Unknown directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Unknown
Unknown