INFRASTRUCTURE LEARNINGINFRASTRUCTURE LEARNING
インフラ大全インフラ大全IT INFRASTRUCTURE / LEARNING
Infrastructure learning guide
Find a lesson or lab/

Esc to close · Search terms stay on your device

LEARNING日本語

Topic lessonTopic: Containers, ECS and Fargate

ECS health checks explained: task health, ALB targets and startup failures

RUNNING describes execution; HEALTHY reports a configured check. Neither alone proves a successful user operation. ECS container checks also differ from ALB checks. Use fixed report-API examples to identify what each observation establishes and which evidence to inspect next.

What you will learn

Separate lifecycle, container checks, ALB and business results; explain UNKNOWN aggregation, startup grace and a diagnostic order based on stop reasons.

Prerequisite

A task is an execution unit; a service maintains executions toward a desired count. An ALB routes requests to targets. These are normalized teaching records, not live AWS logs. No account or secret input is needed.

Distinguish running from usable by the observation point

One task, different observed conditions
ObservationWhat it checksWhat it does not establish alone
Task RUNNINGTask lifecycle state.Container-check results or user HTTP responses.
Container HEALTHYSuccess of the command configured in the task definition.Reachability from the ALB or every business operation.
ALB target healthyCheck response for a configured target, path and other settings.Authenticated operations or correctness of saved data.
User business resultAn outcome for that input, path and time.Other inputs or continued future success.

A container health check is a command executed inside the container; its tools must exist in the image. Success on localhost does not establish success through the ALB’s port, path or network route. ECS monitors checks specified in the task definition, rather than automatically monitoring a check present only in an image’s Dockerfile.

Read task health from two container checks

Aggregation example: API A and helper B belong to one task; both are essential and have checks in the task definition. Essential marks a container as required for the task. A is HEALTHY and B is UNKNOWN. Another helper C is nonessential and UNHEALTHY. Lifecycle is RUNNING; ALB and user responses are uncollected.

Check aggregation: arrows combine check results, not HTTP traffic
Check aggregation: arrows combine check results, not HTTP traffic1: A: HEALTHY — Include A check state — Task: UNKNOWN. 2: B: UNKNOWN — Include B check state — Task: UNKNOWN12A: HEALTHYB: UNKNOWNTask: UNKNOWNCheck aggregation: arrows combine check results, not HTTP traffic1: A: HEALTHY — Include A check state — Task: UNKNOWN. 2: B: UNKNOWN — Include B check state — Task: UNKNOWN12A: HEALTHYB: UNKNOWNTask: UNKNOWN
  1. A: HEALTHY → Task: UNKNOWNInclude A check state
  2. B: UNKNOWN → Task: UNKNOWNInclude B check state
A: HEALTHY
Essential; check in definition
B: UNKNOWN
Essential; check in definition
Task: UNKNOWN
Separate from RUNNING
Aggregate essential containers with task-definition checks
ABTask health
HEALTHYHEALTHYHEALTHY
HEALTHYUNKNOWNUNKNOWN
HEALTHYUNHEALTHYUNHEALTHY
UNKNOWNUNHEALTHYUNHEALTHY

Aggregation checks UNHEALTHY first, then UNKNOWN. This example is UNKNOWN because B is UNKNOWN. C is excluded from this aggregation, but that does not prove its helper function is unaffected. UNKNOWN can mean evaluation in progress, no configured check or unavailable status; it is neither proven health nor confirmed downtime.

An agent disconnect does not by itself make a container UNHEALTHY. The last received health value can remain displayed. Check when and from where a HEALTHY observation was received, rather than treating it as a newly completed check.

Distinguish the two startup grace settings

Retries configures the consecutive failures used to determine unhealthy status. Read startup grace separately from failure counts to distinguish bootstrap failures from continuing failures.

Similar names, different effects
SettingScopeDo not confuse it with
Container startPeriodControls how bootstrap check failures count toward retries.It does not mean checks never run during this period.
Service healthCheckGracePeriodSecondsThe scheduler ignores unhealthy LB, VPC Lattice and container checks after startup for this period.It does not change the check result or repair the application.

Startup example: startPeriod is 30 seconds; a check succeeds at second 10 and fails at second 20. After an early success, subsequent failures count toward retries even within startPeriod. This alone does not establish immediate UNHEALTHY; inspect actual checks, failure counts and retries. These times are teaching values, not universal AWS recommendations.

Read an ALB failure with its configuration and response

ALB example: normalized records for the same revision and observation period
RecordValue
ECS task healthHEALTHY
ALB target health / reasonunhealthy / Target.ResponseCodeMismatch
ALB check configurationHTTP; port 8080; /healthz; success code 200
Observed check response404
User business outcomeUncollected

This ALB example records a mismatch between expected 200 and observed 404. First compare intended path, port and protocol with the actual responder and application behavior. A response-code mismatch differs from a timeout. Do not call it fixed merely by allowing all traffic or accepting 404; establish what the check should validate.

A healthy ALB check does not establish correct user operations or database writes. ALB can also fail open when all targets are unhealthy, so unhealthy does not prove user traffic can never arrive. Check target health separately from actual requests and business outcomes.

Separate startup failure from post-start health failure

Do not diagnose from one label alone
ObservationEvidence to inspect nextAvoid assuming
Never reaches RUNNING or becomes STOPPEDMatch task stopCode, stoppedReason, container reason and service events.Not every failure is insufficient health-check grace.
Image retrieval or initialization failureInspect revision, execution role, image reference and required connectivity.Broad application task-role permissions are not a universal fix.
Container check failureInspect command, tools in the image, startup logs, time and configuration.Localhost success is not ALB-path success.
ALB target check failureInspect reason code, registration/AZ, target settings, path and response.ResponseCodeMismatch is not the same as a timeout.
  1. Match service, task ID, task-definition revision and observation time.
  2. Check whether RUNNING was reached; inspect the same task’s stop reasons.
  3. Inspect configured checks, essential flags and individual container results.
  4. Separate ALB configuration, target state and reasons from local checks.
  5. Distinguish startup time from cause; recheck comparable conditions after a correction.
  6. Verify user requests and outcomes, then consider deployment counts and recovery.

Check what is observed and what remains unknown

Choose an option to see the result and explanation.

In the aggregation example, A is HEALTHY and B is UNKNOWN. What is task health?
Read the answer and reason

Answer: UNKNOWN; investigate B’s check state · B is an eligible UNKNOWN check; do not declare proven health or confirmed downtime.

If B becomes UNHEALTHY in the aggregation example?
Read the answer and reason

Answer: Task health becomes UNHEALTHY, separately from lifecycle · An eligible UNHEALTHY check takes priority; do not infer a simultaneous STOPPED lifecycle state.

The startup example succeeds at second 10 and fails at 20. Is the failure ignored because startPeriod is 30 seconds?
Read the answer and reason

Answer: No; failures after early success count toward retries · This single failure still does not prove immediate UNHEALTHY; inspect counts and settings.

The ALB example reports ResponseCodeMismatch and 404. What should be compared first?
Read the answer and reason

Answer: Intended endpoint, path and success condition with the actual response · Investigate expected 200 versus 404, including the responder and application, without guessing the cause.

The last HEALTHY value remains after an agent disconnect. What is established?
Read the answer and reason

Answer: A last-received value; time and fresh observations matter · Disconnect need not immediately mark it unhealthy, but the retained value is not fresh proof of health.

Check, then explain in your own words

  1. Explain the eligible A/B checks and UNKNOWN result.
  2. Distinguish startup grace settings using the startup example.
  3. Compare ALB configuration with its response and verify user outcomes separately.
Check your understanding: What should you distinguish when a RUNNING task fails ALB checks?

Match lifecycle, local container checks, ALB configuration/responses and user outcomes by revision, target and time.

Each observation checks a different condition. One healthy label does not establish end-to-end success; investigate evidence relevant to the reported failure.

Sources and conditions checked

The official references used in this lesson are collected here with their scope, conditions and corresponding sections. Independent expert review and live AWS comparison have not been performed.