Learning center

ECS invalid CPU or memory: rejected revision or no capacity?

List the family's newest revisions: no new revision means registration rejected the CPU and memory values, and a new one means placement found no room. The first is fixed in the task definition before anything runs. The second is a capacity question about a revision that is already valid.

Two failures before any task exists#

Both failures leave the new deployment without a stopped task to read, which is why they get confused. They happen at different steps and leave different records.

Registration rejected the values. RegisterTaskDefinition validates cpu and memory against the launch types listed in requiresCompatibilities, and returns a ClientException when they do not fit. AWS documents the CLI and API form as Invalid 'cpu' setting for task., and notes that Terraform may report No Fargate configuration exists for given values. No revision is created, so the pipeline stops at the register step and no ECS deployment starts. Invalid CPU or memory · Launch type validation

Placement found no capacity. The revision registered, the service started a deployment for it, and the scheduler could not find room. On EC2 the service events say the service was unable to place a task because no container instance met all of its requirements, and can name the closest instance as having insufficient CPU units available. AWS lists not enough CPU and not enough memory among the causes of that event. The matching EventBridge service action event is SERVICE_TASK_PLACEMENT_FAILURE, with a reason such as RESOURCE:CPU; on Fargate Spot the reason is RESOURCE:FARGATE. Service event messages · Service action events · API failure reasons

This guide covers one row of the signature table. If the deployment has stopped tasks, the failure is after placement; sort them with the stop code guide.

Read the family's revisions#

Use a read-only profile and replace the uppercase placeholders. --sort DESC lists the newest revision first. ListTaskDefinitions

aws ecs list-task-definitions \
  --profile PROFILE --region REGION --family-prefix FAMILY --sort DESC --max-items 3 \
  --query 'taskDefinitionArns' --output json --no-cli-pager

aws ecs describe-task-definition \
  --profile PROFILE --region REGION --task-definition TASK_DEFINITION_ARN \
  --query 'taskDefinition.{definition:taskDefinitionArn,registered:registeredAt,cpu:cpu,memory:memory,requires:requiresCompatibilities,validated:compatibilities,os:runtimePlatform.operatingSystemFamily,containers:containerDefinitions[].{name:name,cpu:cpu,memory:memory,reservation:memoryReservation}}' \
  --output json --no-cli-pager

If the newest revision is the one that was already running and its registered time is older than the deploy, registration failed. Read the error from the deploy tool's output. With CloudFormation, the task definition resource records it:

aws cloudformation describe-stack-events \
  --profile PROFILE --region REGION --stack-name STACK \
  --query 'StackEvents[?ResourceType==`AWS::ECS::TaskDefinition`] | [:5].{time:Timestamp,status:ResourceStatus,reason:ResourceStatusReason}' \
  --output json --no-cli-pager

A CREATE_FAILED or UPDATE_FAILED status with a reason naming the CPU or memory setting confirms the rejection. StackEvent fields

Check the values against the documented limits#

The task-level cpu and memory are required on Fargate and must be one of these pairs. cpu may be written in vCPUs and memory in GB; both are stored as integers in CPU units and MiB once registered. TaskDefinition cpu and memory

cpuAllowed memory
256 (.25 vCPU)512, 1024 or 2048 MiB
512 (.5 vCPU)1024 to 4096 MiB in steps of 1024
1024 (1 vCPU)2048 to 8192 MiB in steps of 1024
2048 (2 vCPU)4096 to 16384 MiB in steps of 1024
4096 (4 vCPU)8192 to 30720 MiB in steps of 1024
8192 (8 vCPU), Linux platform 1.4.0 or later16 GB to 60 GB in 4 GB steps
16384 (16 vCPU), Linux platform 1.4.0 or later32 GB to 120 GB in 8 GB steps

Windows containers on Fargate need at least 1 vCPU. For EC2 and external instances, task-level values are optional and cpu may be anything from 128 to 196608 CPU units. RegisterTaskDefinition

If the task-level pair is valid, the container-level rules are the next read. The containers' memory must total less than the task's memory, and their cpu less than the task's cpu. A container's memory must be greater than its memoryReservation when both are set. On EC2 without a task-level memory, every container needs memory or memoryReservation. ContainerDefinition

What each result means#

What you seeReadingChange
No new revision; ClientException naming cpu or memoryRegistration rejected the valuesPick a pair from the table and register again
New revision; validated lacks FARGATE; service runs on FargateThe revision was never checked against Fargate's sizesAdd FARGATE to requiresCompatibilities so registration checks it
New revision; insufficient CPU or memory events; no task for the deploymentValid size, no EC2 capacity that fits itSize the task to the instances, or add capacity that fits
New revision; RESOURCE:FARGATE on a Fargate Spot providerNo Spot capacity at the timeReview the capacity provider strategy; the size is valid

For the EC2 row, compare the revision with what the instances have left. The scheduler subtracts memoryReservation when it is set, otherwise memory. Remaining resources · memoryReservation

aws ecs list-container-instances \
  --profile PROFILE --region REGION --cluster CLUSTER \
  --query 'containerInstanceArns' --output json --no-cli-pager

aws ecs describe-container-instances \
  --profile PROFILE --region REGION --cluster CLUSTER \
  --container-instances CONTAINER_INSTANCE_ARN_1 CONTAINER_INSTANCE_ARN_2 \
  --query 'containerInstances[].{instance:ec2InstanceId,registered:registeredResources[?name==`CPU` || name==`MEMORY`].{name:name,value:integerValue},remaining:remainingResources[?name==`CPU` || name==`MEMORY`].{name:name,value:integerValue}}' \
  --output json --no-cli-pager

A task larger than any instance's registered value can never be placed in that cluster as it stands. A task smaller than registered but larger than every remaining value waits for room, which a scale-out or the old deployment's tasks stopping can make.

Two ways checkout:51 can fail#

This fixture is illustrative. The fictional service checkout runs checkout:50 with cpu 512 and memory 1024, and the release raises the task size. The two columns are two alternative histories: one on Fargate, one on an EC2 cluster.

ReadRejected registration (Fargate)Placement failure (EC2)
Change in the releasememory 1536cpu 4096, memory 8192
Newest revisioncheckout:50, registered last weekcheckout:51, registered at the deploy
Deploy tool outputClientException for the task's CPU and memory settingsSuccess
Service eventsNone for the releaseUnable to place a task; closest instance has insufficient CPU units
Instances' registered CPUNot applicable2048 on every instance

In the first case, 1536 MiB is not one of the values allowed with 512 CPU units, so nothing was registered and production still runs checkout:50. Change memory to 2048 and register again. In the second case, checkout:51 is valid for EC2 but asks for twice the CPU any instance in the cluster registers, so the deployment never gets a task. Either size the task to fit 2048 CPU units or add an instance type that registers more.

Confirm on the replacement#

For a rejected registration, confirm the new revision's number, registeredAt and stored cpu and memory, then that the deployment for it reaches its desired count. For a placement fix, confirm that the deployment's runningCount reaches desiredCount and that the service events stop reporting insufficient resources.

Where this reading stops#

A correct size can still fail for other placement reasons, such as ports, network interfaces or attributes, and those leave their own service events. Fargate tasks run without container instances, so on Fargate the size table and the deployment's state are the reads you have. A deployment that never gets a running task has its own question, whether it was ever placed, which another guide in this collection answers. Raising the size to get past registration does not tell you the container needs it; container memory kills after a deploy are a separate failure with a stopped task to read. Service event messages

Task-level CPU and memory are ignored for Windows containers, so on Windows the container-level values carry the size. TaskDefinition cpu and memory

Questions#

What does "Invalid 'cpu' setting for task" mean in ECS?

RegisterTaskDefinition rejected the task-level CPU and memory values for a launch type in requiresCompatibilities, usually Fargate. No revision was created. Choose a CPU and memory pair that Fargate supports and register again.

Why does my ECS deployment create no tasks after I raised CPU or memory?

If the new revision exists, check the service events. On EC2, an event that no container instance met all of the task's requirements, with the closest one short of CPU units or memory, means no instance has room for the new size.

Does Fargate allow any memory value with 1 vCPU?

No. With 1024 CPU units, memory must be between 2048 and 8192 MiB in steps of 1024 MiB.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading