An Amazon ECS service runs a queue-processing application with a desired count of three tasks and no load balancer. Sometimes the application process hangs while its container keeps running, so the task stays RUNNING and ECS never replaces it. Which change makes ECS replace hung tasks automatically?
Show the answer
Correct answerB. Add a container health check to the task definition that tests whether the application is processing.
AWhy not this: Extra tasks add capacity, but the hung tasks keep running and are never replaced.
BWhy this is right: When an essential container reports unhealthy, the ECS service scheduler stops the task and launches a replacement.
CWhy not this: The circuit breaker watches deployments for failures; it does not act on tasks that hang between deployments.
DWhy not this: The grace period only delays when ECS acts on health check results; with no health check, nothing reports the hung task.
An ECS service keeps its desired count by replacing tasks that stop or that report unhealthy. A task whose process hangs but whose container keeps running looks healthy until a container health check tests the application itself; then the service scheduler stops the unhealthy task and starts a replacement. The deployment circuit breaker only judges deployments.