Target Groups
What is a Target Group?
Target Group is a logical grouping of EC2, IP or Lambda that receive traffic from a LBs.
- It tells the Load Balancer where to route traffic.
Target Group Types (Based on Load Balancer)
| Load Balancer Type | Supported Target Types |
|---|---|
| ALB | EC2, IP, Lambda |
| NLB | EC2, IP, ALBs |
| GWLB | EC2, IP |
Auto Scaling Group (ASG) Integration
Note
✔ If ASG is linked to a Target Group:
- Instances launched by ASG are automatically registered/deregistered
- ASG uses Target Group health checks to detect and replace unhealthy instances
Health Checks in Target Groups
Purpose
- Monitors the health of targets to ensure traffic is only routed to healthy instances
Key Configurations Example
| Configuration | Value | Description |
|---|---|---|
| Protocol | HTTP | HTTP, HTTPS, or TCP |
| Port | 8080 | Target port |
| Path | /health | Used with HTTP/HTTPS |
| Healthy Threshold | 3 | Successful checks to mark as healthy (default: 5) |
| Unhealthy Threshold | 2 | Failed checks to mark as unhealthy (default: 2) |
| Timeout | 5s | Wait time for a response (default: 5s) |
| Interval | 30s | Time between health checks (default: 30s) |
| Success Codes | 200 | HTTP status codes indicating success |
Interpretation
- Load Balancer sends a GET /health request to each target every 30s
- If it receives 3 consecutive 200 OK responses, the target is marked healthy
- If it fails 2 times in a row, the target is marked unhealthy