Cihan
Cihan

Reputation: 2307

AWS ECS - Multiple containers on a single instance performance issues

I'm using a 16 CPU instance on AWS Elastic Container Service (ECS). And I want to run 8 containers here, which all reserve 2 CPUs.

The performance I get with this setup is significantly slower (around doubly) than when I run 8 containers on 8 instances of 2 CPUs each.

Currently, it seems like the CPU assignment isn't "hard", in that a container can be given more than 2 CPUs by the scheduler at any time.

Is there a way to "hard assign" CPUs to containers? My end goal is to make CPUs as specialized as possible for just a single task, so that the performance is better, i.e. closer to the performance I get when I run the containers on separate instances. If there are other steps I should be taking, I would appreciate pointers on them as well.

Note that the tasks that containers run are fully independent.

Upvotes: 1

Views: 1613

Answers (1)

Patrick
Patrick

Reputation: 3230

So a couple points:

  1. The "CPU" parameter of the ECS configuration will "reserve" the CPU for a given container. The CPU will always be able to use that much CPU with minimal delay. HOWEVER - that's not the maximum CPU (and there is no way to set a maximum cpu in ECS); containers are allowed to use unallocated CPU as desired. So if you had 1 container running with 2048 reserved CPU units, it will still be allowed to use all 16 CPUs until something else needs them.

  2. The performance degradation you're seeing is likely a result of CPU thrashing where the containers need more CPU than you're giving them so they grab it from the other containers who aren't using it. Then when the other containers need it they need to grab from the container that's using it more, causing that to lose performance. You may need to right-size your containers.

After those two points, I have to ask: Running 8 smaller servers with 8 containers will fix this issue as you note (no more resource sharing between the 8 containers) and will be much cheaper. Why one big server instead of 8 smaller?

Upvotes: 2

Related Questions