ASG Health Checks and Instance Replacement
You'll learn how Auto Scaling Groups detect and automatically replace unhealthy instances to maintain application availability.
What Are ASG Health Checks?
Auto Scaling Groups continuously monitor your instances using health checks to ensure they're functioning properly. Think of health checks like a supervisor regularly checking that workers are present and productive—if someone's absent or not performing, they're replaced.
ASGs support two health check types:
EC2 Health Checks
These verify the instance is running at the infrastructure level. AWS checks if the EC2 instance is in a "running" state and reachable by the hypervisor. If the instance stops, crashes, or has hardware problems, it's marked unhealthy.
ELB Health Checks
These go deeper—your load balancer pings the actual application endpoint (like /health) to verify your app is responding correctly. The instance might be "running" from AWS's perspective, but if your application crashed, the ELB marks it unhealthy.
Grace Periods
When instances first launch, they need time to boot and initialize your application. The health check grace period (default 300 seconds) tells ASG: "Don't check health yet—give it time to start up." This prevents premature termination of instances that are still initializing.
Automatic Replacement
When an instance fails health checks, ASG automatically:
- Marks it unhealthy
- Terminates the failing instance
- Launches a replacement to maintain your desired capacity
This happens continuously without manual intervention, ensuring your application stays available even when individual instances fail.
Key Takeaway: ASG health checks (EC2 or ELB) continuously monitor instance health, respecting grace periods for startup time, and automatically replace unhealthy instances to maintain your application's desired capacity and availability.