According to the documentation you can give the scheduler three kinds of strategies:
Amazon ECS supports the following task placement strategies:
binpack
Tasks are placed on container instances so as to leave the
least amount of unused CPU or memory. This strategy minimizes the
number of container instances in use.
When this strategy is used and a scale-in action is taken, Amazon ECS
will terminate tasks based on the amount of resources that will be
left on the container instance after the task is terminated. The
container instance that will have the most available resources left
after task termination will have that task terminated.
random Tasks are placed randomly.
spread Tasks are placed evenly based on the specified value. Accepted
values are instanceId (or host, which has the same effect), or any
platform or custom attribute that is applied to a container instance,
such as attribute:ecs.availability-zone. Service tasks are spread
based on the tasks from that service. Standalone tasks are spread
based on the tasks from the same task group.
When this strategy is used and a scale-in action is taken, Amazon ECS
will select tasks to terminate that maintains a balance across
Availability Zones. Within an Availability Zone, tasks will be
selected at random.
What you seem to need seems like the opposite of binpack, so you might need to create a custom scheduler.
Alternatively you could increase the required memory in your task definitions with the memoryReservation
parameter. That way your containers should get as much memory as they need for their operations.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…