2 Answers
- Newest
- Most votes
- Most comments
0
Can you clarify what EC2 instance type you are using and how much resource (CPU, RAM) it takes during API calls.. I'm wondering if the EC2 is too small and the API is taking too long and thus it cannot return the health checks within 5 seconds.
answered a month ago
0
It sounds like you're experiencing an issue with your EC2 instances becoming unhealthy and being replaced when you make API calls. This behavior can be caused by several factors:
1. Application errors: Your API code might be crashing or not responding properly when it receives requests, causing the instance to fail health checks.
2. Resource constraints: The API calls may be overwhelming the instance's resources (CPU, memory, etc.), leading to unresponsiveness and failed health checks.
3. Incorrect health check configuration: The Elastic Load Balancer (ELB) health check might be too strict or not properly configured for your application.
4. Insufficient startup time: If your application needs more time to initialize, the health check may be failing before the application is ready.
To troubleshoot this issue:
1. Review your application logs: Since the instances are being terminated quickly, you may need to set up centralized logging (e.g., CloudWatch Logs) to capture logs before the instance is replaced.
2. Adjust the health check grace period: Increase the grace period in your Auto Scaling group to give instances more time to start up and become healthy before they're subject to health checks.
3. Verify your application's health check endpoint: Ensure that your API has a proper health check endpoint that responds quickly and accurately represents the application's health status.
4. Check instance resources: Monitor the CPU, memory, and disk usage of your instances to ensure they have sufficient resources to handle the incoming requests.
5. Review security groups and network ACLs: Confirm that your security settings allow traffic between the ELB and your instances on the necessary ports.
6. Implement a pre-warm up strategy: If your application needs time to initialize, consider implementing a strategy to "warm up" new instances before they start receiving traffic.
By addressing these potential issues, you should be able to stabilize your environment and keep your instances healthy when handling API calls.
Sources
Elastic Beanstalk: ELB Health Check Fails During Auto-Scaling Down | AWS re:Post
CodeDeploy actions wrong order during scale in | AWS re:Post
Community | What is AWS AutoScaling and Elastic Load Balancer (ELB)
answered a month ago
Relevant content
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 9 months ago
Hey SHAJAM,
I have checked and found that the CPU utilization is low, and we are using a T3.medium instance.