- Newest
- Most votes
- Most comments
When a task in an ECS service fails a load balancer health check, the service scheduler's behavior depends on several factors, including the maximumPercent and desiredCount parameters.
Here's how the process works:
-
If a task is marked unhealthy due to a failed load balancer health check, the service scheduler will first attempt to start a replacement task.
-
Then one of two things happens:
- If the replacement task becomes healthy (passes its health check), the service scheduler stops the unhealthy task
- If the replacement task also becomes unhealthy, the scheduler will stop either the unhealthy replacement task or the existing unhealthy task to maintain the desired count
The healthy threshold count parameter is relevant in scenarios where a task becomes unhealthy but isn't immediately replaced. For example:
- If the
maximumPercentparameter limits the scheduler from starting a replacement task first, the unhealthy task might remain running while the scheduler stops tasks one at a time to free up capacity - In this case, if the unhealthy task resolves its issues, it would need to pass the number of consecutive health checks specified by the healthy threshold count to transition back to healthy status
By default, this threshold is set to 5 consecutive successful health checks, which with the default 30-second interval means it takes 2 minutes and 30 seconds for a task to transition from unhealthy back to healthy. You can optimize this by reducing both the interval (to as low as 5 seconds) and the threshold count (to as low as 2), which would reduce the transition time to just 10 seconds.
For newly registered targets (like when a task first starts), only a single successful health check is required regardless of the healthy threshold count setting.
Sources
Update Amazon ECS service parameters - Amazon Elastic Container Service
Amazon ECS services - Amazon Elastic Container Service
Load balancer health check parameters - Amazon Elastic Container Service
Optimize load balancer health check parameters for Amazon ECS - Amazon Elastic Container Service
Relevant content
asked a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 6 months ago

This might be the most helpful AI answer I've ever received! Will wait to see if any humans can confirm this, as I cannot see this behaviour documented, but it would make complete sense.