DVA-C03 practice question: Custom metrics, alarms and health checks (3 of 4)
Troubleshooting and Optimization A free question from our original DVA-C03 practice exam. Try it, then open the answer to see why each option is right or wrong.
A payments API runs as an Amazon ECS service on AWS Fargate, behind an Application Load Balancer. Its tasks are slow to start, because the application needs about 60 seconds to load its cache before it can answer requests.
When a task stops responding, the team wants ECS to replace it automatically. The application has a /health endpoint that returns an error when its database connection is down.
Which configuration meets these requirements without replacing healthy tasks while they start?
Choose one answer.
AA. Set the service's health check grace period to 120 seconds, and point the target group health check at /health. ECS stops and replaces tasks that fail the load balancer check after the grace period.
BB. Point the target group health check at the root path on port 80 with a 2-second timeout, and set no grace period, so each new task is checked as soon as it starts.
CC. Create a CloudWatch alarm on the target group's 5xx count that notifies an operator, who then stops any task that returns errors.
DD. Set the service's minimum healthy percent to 100 and maximum percent to 200, so ECS starts each replacement task before it stops the old one.
Show the answer and explanation
Answer: A
A. Right: Correct. The grace period tells the ECS service scheduler to ignore load balancer health check failures while a new task loads its cache. After that, a failing target group check on /health makes the scheduler replace a task that stops responding or loses its database connection. Learn more: Amazon ECS service definition parameters (opens in a new tab)
B. Wrong: New tasks are checked before the cache loads, so they fail and are replaced again and again. The root path also does not reflect the database connection that the team wants checked.
C. Wrong: An alarm only notifies, so a person must stop each task, which breaks the automatic replacement the team wants. It also reacts to errors in total rather than to the health of each task.
D. Wrong: These settings control how many tasks run while tasks are replaced. They do not decide when a task is unhealthy, and they do not stop new tasks from failing health checks while they load the cache.
Explanation
The ECS service scheduler replaces tasks that fail the load balancer target group health check, and /health makes that check reflect the database connection. The health check grace period keeps the scheduler from judging a slow-starting task too early. Together they replace unhealthy tasks automatically without churning new ones during startup.
Want more on Custom metrics, alarms and health checks? The 5 full-length practice sets have 16 more Custom metrics, alarms and health checks questions, 390 in all, none of them in the free exam. One payment of $14.99, no subscription. See the practice sets →