Process CPU priority across containers

Hi, I am interested in prioritizing certain processes on certain containers. I’m aware of the nice and renice commands in Linux but was curious if there is a known good way to manage priority across multiple containers. For example a graphics render process in one container may need highest priority over a background process in another container, which should always apply even if the background process is set to highest priority within the container. Are there any examples of projects that manage performance in this way, or advice that people have about optimizing this? For my use case the perceived performance is most important, so certain critical processes such as graphics render should always take precedence.

Maybe one way to do this is using some of the docker-compose.yml settings to apply limitations to certain services. See our list of supported fields in the documentation and I’m guessing that either cpu_shares or cpu_quota might be possible to use to give more or less weight to some services. Click on the names there in the docs to go to the relevant docker-compose documentation for more details.

I don’t think we have tried this, but this would be my first guess to balance the workload. Not exactly the same situation as you ask, but maybe.

Also if you want to separate workloads even more, could even try cpuset I believe to, e.g. pin one service to one cpu/core, and another to another, for example. This is again not totally the same, but maybe helps. Also some details in the docker Resource Constraints documentation.

1 Like