"A running server is a healthy server." Not always. The machine can be up, the operating system fine, and the application on it frozen, out of memory or still starting. A load balancer that only knew "the server exists" would keep sending users to a dead app. Target groups and health checks are how Elastic Load Balancing avoids that.
What a target group is
A target group is the list of destinations a load balancer can send requests to, together with the protocol and port to use. A listener rule on the load balancer says "requests that match this condition go to that target group", so one load balancer can serve several groups, for example /api/* to one and everything else to another.
When you create a target group you choose a target type, and it can't be changed later. For an Application Load Balancer the types are:
- instance: EC2 instances, registered by instance ID. Attach the group to an Auto Scaling group and new instances register themselves.
- ip: private IP addresses, which is how containers and on-premises servers are usually registered.
- lambda: a single Lambda function.
When you deregister a target, the load balancer stops sending it new requests and lets in-flight requests finish during the deregistration delay (300 seconds by default).
How health checks work
The load balancer sends a small request to every registered target on a schedule. For an Application Load Balancer with instance or IP targets, the documented defaults are:
- an HTTP
GETto the path/ - every 30 seconds, with a 5 second timeout
- success means a
200response - 2 failed checks in a row mark the target unhealthy; 5 successes in a row bring it back
All of these are settings on the target group, so check the current values for your load balancer type before relying on them. An unhealthy target stays registered but receives no new traffic until it passes again.
Check the app, not just the box
The most common mistake is a shallow health check: the default / path served by the web server, which answers happily while the application behind it is broken. Point the check at a dedicated path, such as /health, that only returns 200 when the app can really do its job.
Two warnings:
- Don't go too deep. If every target's health check depends on the same database, one database blip marks all targets unhealthy at once.
- If every target in a group is unhealthy, the load balancer fails open and sends traffic to all of them anyway. That is better than refusing everyone, but it means a bad health check can hide a real outage.
Where AI fits
Model servers make the myth worse. A GPU instance can be "running" for minutes while it is still loading model weights, and an inference process can hang while the machine looks fine. Send users there and they wait, then time out.
So give the model server a readiness path that returns 200 only when the model is loaded and can answer, and point the target group's health check at it. Keep that check cheap: confirm the model is ready rather than running a full, expensive generation every few seconds. If loading takes a long time, also give new instances a matching health check grace period in the Auto Scaling group, so they aren't replaced before they finish starting.
Quick recap
- A target group is the set of targets, plus protocol and port, that a listener rule forwards to.
- Health checks run on every target; unhealthy targets get no new traffic until they pass again.
- Check a path that proves the app works, and for AI, that the model is ready.