Lars Hanke
Lars Hanke

Reputation: 634

Linux: limit CPU/memory resources per user based on fair shares

I'm searching for a solution to plumber some Linux packages to achieve the resource management as described below. I know that I could probably write a daemon that might do what I want, but I want to spare that non-trivial and lengthy work.

I administer a machine, which is used for long lasting calculations eating lots of CPU. On that machine several users can log in and start their calculations. The goal is that the machine load is optimized and each user gets his fair share of CPU time. A similar issue, but less critical so far, exists with memory.

So this is my idea how it might work in order to clarify what I mean:

The load-optimizer would give all requested CPU time to system processes (and eventually root) and calculate the remaining capacity. This capacity would be divided by the number of logged in users. Each user, who requires less than his share, gets all he requests. Recurse until all users require more than their share. Then throttle the remaining users to receive equal shares, e.g. by renicing.

This does not have to be accurate to the jiffy. The long lasting calculations run for hours, sometimes days. So if the balancing is fair on a 5-10 minute average this is already perfect user scheduling.

Does anyone know of a solution, which does approximately that?

Upvotes: 0

Views: 1953

Answers (1)

jørgensen
jørgensen

Reputation: 10569

Arrange for users processes to be sorted into per-user cgroups, and then just make use of Linux's CFS cgroup scheduling (CONFIG_CGROUP_SCHED). While at it, I shall recommend systemd, since it already does the per-user sorting.

Upvotes: 3

Related Questions