Reputation: 1375
I'm trying to create a deployment where as many tasks as possible are on each EC2 instance, but ECS still places one task per instance which then makes them heavily underutilized.
Here's all the settings I think are relevant:
On every deploy tasks are placed into empty instances and if there aren't any ASG creates new ones, there's never more than one task per instance.
Upvotes: 1
Views: 1427
Reputation: 2134
It seems that the micro EC2 instance you require doesn't have enough ENI capacity to scale more than 1 task per container instance.
According to the documentation:
With the awsvpc network mode, Amazon ECS creates and manages an Elastic Network Interface (ENI) for each task and each task receives its own private IP address within the VPC. This ENI is separate from the underlying hosts ENI. If an Amazon EC2 instance is running multiple tasks, then each task’s ENI is separate as well.
Since "this ENI is separate from the underlying hosts ENI", running 1 ECS task requires at least 2 interfaces. In case of running 2 ECS tasks you would need 3 ENI and so on.
When I get a description of EC2 instance types (you can just run aws ec2 describe-instance-types --filters "Name=instance-type,Values=t3a.micro"
) I see that t3a.micro has a maximum limit of only 2 available network interfaces ("MaximumNetworkInterfaces": 2). So, you need to make better use of the existing maximum number of network interfaces or to get a container instance with capacity to attach more network interfaces.
A solution might be to use an instance type with more ENI capability or to increase task density with ENI trunking. Please read about ENI trunking considerations before. ENI trunking might look something like this:
Upvotes: 5