ASG-ELB Integration
Ref: https://learn.cantrill.io/courses/1820301/lectures/41301443
Diagram: https://github.com/acantril/aws-sa-associate-saac03/blob/main/1500-HA_and_SCALING/00_LEARNINGAIDS/ASG-3.png
- 🔧 An EC2 ASG can be added to the Target Group (TG) of an ELB
- ASG instances automatically provisioned/terminated inside the ELB TG
- Advantages of both ASGs and ELBs:
- 👍 ELB provides infrastructure abstraction → backend can scale/fail without impacting client experience
- 👍 ASG provide scalability + elasticity
- 👍 ASG can gain app awareness → can use ELB health checks together with EC2 instance status checks
ASG Health Checks
Ref: https://learn.cantrill.io/courses/1820301/lectures/41301446
- 🔧 Used by ASG to assess instance health
- Automatic healing → ASG replaces instances that fail their health checks
- 3 types:
- EC2 instance status checks (Default)
- ❗ Instance healthy ONLY if Instance is in
Running
state WITH 2/2 status checks
- If instance is in non-running state (
Stopping
, Stopped
, Shutting Down
, Terminated
…) or impaired (not giving both 2/2 status checks) → instance viewed as unhealthy
- ELB health checks (can be enabled if integrated with an ELB)
- ❗ Instance healthy = both ELB health checks + EC2 instance status checks pass!
- 👍 Powerful → ASG can heal based on NW health (L4), or L7 app health checks (only in ALBs)
- ‼️ Bad configuration = headaches! → careful when configuring ELB health checks!
- 💡 Example 1: you have a complex system but only check basic values in an HTML page… ELB health checks can give OK even though the app is failing!
- 💡 Example 2: your app's DB is failing and causing ELB health failures, but your system only detects if basic values in an HTML page load… → system terminates and recreates instances continuously, without solving the underlying DB issue!
- Custom health checks
- ❗ An external system of your choice marks instances as healthy/unhealthy
- ASGs meet business requirements more closely, can integrate with external tools
- Health check grace period = delay before ASG starts monitoring health checks after an instance launch
- Default = 300s (5 minutes)
- ❗ Allows systems to launch, bootstrap, and internal apps to start before health checks start to fail
- ‼️ Usually the cause for an ASG continuously provisioning and terminating instances is that the health check grace period is not enough time!
- Health checks start to fail before instances finish configuring → endless loop