LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   How to limit the CPU usage per user? (https://www.linuxquestions.org/questions/debian-26/how-to-limit-the-cpu-usage-per-user-715490/)

jamespayne79 03-30-2009 09:04 AM

How to limit the CPU usage per user?
 
We have a Debian server that are used for computation and shared by several users. Sometimes, a single user may have ill-written script that will ocupy all the CPU time. That makes the server unaccessible for other users. In that case, even the administrator cannot login to the system and kill the trouble-making process.

Just wondering if there's any software or daemon that can restrict the CPU usage of a user or group, just like what "quota" did for disk space. The buttom line, total user CPU usage should be less than some threshold, e.g. 80%. So the system administrator always have a chance to clean up the mess.

vlademir 03-31-2009 01:55 AM

Quote:

Originally Posted by jamespayne79 (Post 3492529)
We have a Debian server that are used for computation and shared by several users. Sometimes, a single user may have ill-written script that will ocupy all the CPU time. That makes the server unaccessible for other users. In that case, even the administrator cannot login to the system and kill the trouble-making process.

Just wondering if there's any software or daemon that can restrict the CPU usage of a user or group, just like what "quota" did for disk space. The buttom line, total user CPU usage should be less than some threshold, e.g. 80%. So the system administrator always have a chance to clean up the mess.

Hi,

See this threat :

http://www.linuxquestions.org/questi...-usage-617928/

jamespayne79 04-05-2009 04:07 AM

Quote:

Originally Posted by vlademir (Post 3493330)

Thanks for the reply. I tried limits.conf, but it doesn't seem to be working. I added a group called "students" and put all users into that group. Then limited 30 processes for "students" members. However, when I do "ulimit -a", it shows the user still can have thousands of processes.

Any ideas? Does it has something to do with the SMP kernel we use?

jschiwal 04-05-2009 05:12 AM

Check your PAM configurations and see if pam_limits is used. Also check the line that includes pam_limits.so and see if another config file is used.

You could also invoke ulimit in /etc/profile (or /etc/profile.local if that is what is used). Also be sure to scan through the logs. Perhaps try to exceed the limits yourself using your own user account while monitoring the logs.

syg00 04-05-2009 05:28 AM

Have a look at cpulimit - it's a bit hard to manage for lots of processes; especially of they are short-lived, but works as advertised.
For multi-CPU configs I use cgroups (nee cpusets) and confine groups of processes/users to a subset of total CPUs - documented in the source tree. Might work for you if you can limit groups of users - the granularity isn't great though.

jamespayne79 04-06-2009 10:28 AM

That why they call people guru
 
Thanks jschiwal and syg00 for you important and useful suggestions. The limits work great now! And I will definitely check the "cgroups", sounds like what I am looking for.


All times are GMT -5. The time now is 04:19 PM.