Example Amazon ECS task placement strategies
You can specify task placement strategies with the following actions: CreateService, UpdateService, and RunTask.
Examples
- Distribute tasks evenly across Availability Zones
- Distribute tasks evenly across all instances
- Bin pack tasks based on memory
- Place tasks randomly
- Distribute tasks evenly across Availability Zones and then distributes tasks evenly across the instances within each Availability Zone
- Distribute tasks evenly across Availability Zones and then bin pack tasks based on memory within each Availability Zone
- Distribute tasks evenly across instances and then bin pack tasks based on memory
Distribute tasks evenly across Availability Zones
The following strategy distributes tasks evenly across Availability Zones.
"placementStrategy": [ { "field": "attribute:ecs.availability-zone", "type": "spread" } ]
Distribute tasks evenly across all instances
The following strategy distributes tasks evenly across all instances.
"placementStrategy": [ { "field": "instanceId", "type": "spread" } ]
Bin pack tasks based on memory
The following strategy bin packs tasks based on memory.
"placementStrategy": [ { "field": "memory", "type": "binpack" } ]
Place tasks randomly
The following strategy places tasks randomly.
"placementStrategy": [ { "type": "random" } ]
Distribute tasks evenly across Availability Zones and then distributes tasks evenly across the instances within each Availability Zone
The following strategy distributes tasks evenly across Availability Zones and then distributes tasks evenly across the instances within each Availability Zone.
"placementStrategy": [ { "field": "attribute:ecs.availability-zone", "type": "spread" }, { "field": "instanceId", "type": "spread" } ]
Distribute tasks evenly across Availability Zones and then bin pack tasks based on memory within each Availability Zone
The following strategy distributes tasks evenly across Availability Zones and then bin packs tasks based on memory within each Availability Zone.
"placementStrategy": [ { "field": "attribute:ecs.availability-zone", "type": "spread" }, { "field": "memory", "type": "binpack" } ]
Distribute tasks evenly across instances and then bin pack tasks based on memory
The following strategy distributes tasks evenly across evenly across all instances and then bin packs tasks based on memory within each instance.
"placementStrategy": [ { "field": "instanceId", "type": "spread" }, { "field": "memory", "type": "binpack" } ]