For my client I need to benchmark a multi-threaded/multi-server solution.

Unfortunately, we only have a big server (128 GB, 32 cores,…) and we are putting all our instances on this single server. As each instance is multi-threaded, we noticed that they often get in each others way, resulting in bad performances (context swapping, …).

We solved this problem in 2 ways.

On one hand we used thread affinity in the application in order to bind some thread to a given CPU, and on the other hand we used docker to authorize a given application to access only some CPUs (via cpuset).

To be sure that docker was correctly restricting the access to the CPUs, I created a docker image:

If you run it with

$ docker run -ti --cpuset-cpus=6 agileek/cpuset-test

it will take one cpu (the 7th) at 100%.

You can see it in action:

If you run it with

$ docker run -ti --cpuset-cpus=0,4,6 agileek/cpuset-test

it will take all available CPUs (the 1st, 5th and 7th)

You can see it in action:

Edit 2016-01-06