Troubleshooting solutions for health check failures in AWS ECS
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.
Ensure that the packages used for health checks, such as curl and wget, are properly installed in the container image!
Double-check the command used for internal health checks in the AWS ECS container.
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)
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)
- Must create health-check endpoint
Verify the path of the health check for the target group in the AWS ALB.
Next.js
- In the case of Next.js, response headers may return codes like 307 or 308 instead of 200.
For Spring Boot applications, consider setting a longer interval for health checks due to the possibility of cold starts.
Interval : 30
Retries : 10
StartPeriod : 60
Timeout : 60
Subscribe to my newsletter
Read articles from Unknown directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by