# Process CPU priority across containers

**URL:** <https://forums.balena.io/t/process-cpu-priority-across-containers/31776>\
**Category:** Product support\
**Created:** [September 9, 2019, 8:32pm UTC](https://forums.balena.io/t/process-cpu-priority-across-containers/31776 "2019-09-09T20:32:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aric-mira](https://avatars.discourse-cdn.com/v4/letter/a/d26b3c/32.png) [@aric-mira](https://forums.balena.io/u/aric-mira)\
**Post date:** [September 9, 2019, 8:32pm UTC](https://forums.balena.io/t/process-cpu-priority-across-containers/31776/1 "2019-09-09T20:32:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![imrehg](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/imrehg/32/36_2.png) [@imrehg](https://forums.balena.io/u/imrehg)\
**Post date:** [September 9, 2019, 8:40pm UTC](https://forums.balena.io/t/process-cpu-priority-across-containers/31776/2 "2019-09-09T20:40:20Z")

</div>

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 [https://www.balena.io/docs/reference/supervisor/docker-compose/#docker-composeyml-fields](https://www.balena.io/docs/reference/supervisor/docker-compose/#docker-composeyml-fields) 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](https://docs.docker.com/config/containers/resource_constraints/#cpu) documentation.
