SimAWSby ShahriarLabs
Search

Load balancing and scaling · Chapter 3 of 3

What a health check actually proves

A health check determines whether a server is capable of processing work, but poorly designed checks can easily trigger self-inflicted outages.

FoundationsBuilds the idea from nothing. No prior AWS assumed.

The role of automated health monitoring

Why do load balancers and auto scaling groups monitor server health?

Target GroupApp ClientsLoad BalancerTarget 110.0.1.10 (Healthy)Target 210.0.1.20 (Healthy)When a target fails health checks, ELB routes new requests to healthy targets while allowing active in-flight requests to complete during the connection draining window.

The load balancer routes client traffic evenly between Target 1 and Target 2, while checking target health in the background.

1/5
  1. 01

    Avoiding black hole servers

    When a server process crashes or freezes, it stops responding to requests. Without health checks, a load balancer will continue sending traffic to the dead server, resulting in connection errors for users.

  2. 02

    Determining healthy states

    A health check is a periodic request sent by the load balancer to a specific endpoint on your server. If the server returns a successful response code within the timeout window, it is considered healthy.

  3. 03

    Automating replacement

    Once a target crosses the unhealthy threshold, an Application Load Balancer normally routes new requests to healthy targets. If all registered targets are unhealthy, it can fail open and route to them anyway. A load balancer does not terminate instances. An Auto Scaling Group can replace unhealthy instances when its relevant health-check type is enabled; ELB health checks are optional and ignored by default.

Check yourself

When other registered targets remain healthy, what does an Application Load Balancer normally do after a target crosses its unhealthy threshold?

Under the hoodThe same thing from underneath: limits, failure modes, numbers.

The danger of deep health checks

How can a shared database failure cause unhealthy application targets and unnecessary instance replacement?

Target GroupApp ClientsLoad BalancerTarget 110.0.1.10 (Healthy)Target 210.0.1.20 (Healthy)When a target fails health checks, ELB routes new requests to healthy targets while allowing active in-flight requests to complete during the connection draining window.

The load balancer routes client traffic evenly between Target 1 and Target 2, while checking target health in the background.

1/5
  1. 01

    Shallow versus deep health checks

    A shallow health check only verifies that the web server process is running and responding. A deep health check verifies external dependencies, such as database connectivity or third-party APIs.

  2. 02

    The cascading failure risk

    A shared database failure can make otherwise running application targets fail deep health checks together. ALB can then fail open if every registered target is unhealthy. If an Auto Scaling Group uses ELB health checks, it may replace instances unnecessarily; AWS can throttle replacement rather than terminating the entire fleet at once. Design checks so replacing a server addresses the failure they detect.

  3. 03

    Connection draining and deregistration

    An unhealthy target is not automatically deregistered. When you explicitly deregister an ALB target, it enters draining: new requests are routed elsewhere while existing requests can finish during the configured deregistration delay. Health-check failures and deregistration are separate transitions.

The numbers

ALB default thresholds
5 checks to become healthy, 2 to become unhealthyAsymmetric on purpose: pull a bad target out fast, put a recovered one back slowly.
NLB default thresholds
5 healthy, 2 unhealthyCurrent defaults; configurable from 2 to 10. Distributed active health checks use consensus, so targets can receive more checks than the configured interval suggests.
Default deregistration delay
300 secondsThe time the load balancer waits for active requests to complete before closing connections.
Minimum check interval
5 secondsThe frequency of health check requests, which determines detection speed.

Check yourself

Why are deep health checks that query database tables considered risky?

Official references & further reading

These lessons simplify selected behaviors for learning. Verify current service limits, Region support and production requirements with the official references. Experiments describe their own assumptions.

Report an error or suggest a clearer explanation →