Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 02-01-2008, 08:00 AM   #1
Registered: Aug 2004
Location: BR - Floripa
Distribution: Ubuntu 9.10 - 2.6.x.x
Posts: 661

Rep: Reputation: 34
Question how to limit the users CPU usage ?


I'm setting up a Linux LTSP server that will in most of the time serve a remote session to about 40 to 60 users... The server is well prepared to do that, but my fear is that some user could easily bring down the serve with a loop function or a fork bomb. Well to avoid this I have choose to use limits.conf from pam security package to limit the maximum processes a user can run ... for now this is working. But, limiting the maximum processes a user can run don't necessary avoid the user to ran a very heavy processes that uses a lot of CPU and make the system slow or even unusable.

Trying to workaround this situation I made a lot of google search since the CPU option in limits.conf or in ulimit doesn't set the maximum process usage but the maximum CPU Time a process can have...

Some other solution I found was to user a renice daemon to make the processes less priority but I wasn't thinking about renicing processes but really limitating the maximum usage a user could have...

Well, I hope some one have a solution for this problem

thanks in advance!

[ ]'s
Old 02-03-2008, 01:11 AM   #2
Senior Member
Registered: Mar 2006
Posts: 1,896

Rep: Reputation: 61
First, if you limit the number of processes per user, a fork bomb gets killed very quickly. (Yes, I have tried it. ) As far as a user hogging the CPU, a user running at a normal "nice" level would have to have a number of heavy CPU processes going to do that. And eventually the CPU limit would nail the abuser. Other than that, I don't know that there is an existing mechanism to do what you want. (You could write a script to monitor these things, and kill or renice an offending process/user, but I doubt you want to go to that kind of trouble.)

I believe the completely fair scheduler (CFS) has now been merged into the kernel. I don't think the current version has this, but at some point in the future you are supposed to be able to "fairly" schedule groups instead of just processes. When that is added to the kernel (or maybe there is a patch you can add now), you could configure it so that each user only gets a "fair share" of the CPU time regardless of how many processes that user is running.
Old 02-04-2008, 09:13 AM   #3
Registered: Aug 2004
Location: BR - Floripa
Distribution: Ubuntu 9.10 - 2.6.x.x
Posts: 661

Original Poster
Rep: Reputation: 34
Yeah... Im using only the proccess number limit to avoid someone from spawn a lot of processes, but still fearing the high cpu usage ... I think Im going to make a script to renice the java_vm process, the application that most of the users use is Java based and is what sometimes eats a lot of the cpu.

But thank for the chat, was interesting.
=) [ ]'s

PS: For now my test box is a Dual Core/2gb ram handling 15 users, next will be an Itautec 2xQuadXeon with 16GB of ram handling 60 users, I think it will handle the task without problem, but...

Last edited by maginotjr; 02-04-2008 at 09:16 AM.
Old 02-04-2008, 08:00 PM   #4
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 17,735

Rep: Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523
Try ulimit -t;
from the manpage:
-a All current limits are reported
-c The maximum size of core files created
-d The maximum size of a process's data segment
-f The maximum size of files created by the shell
-i The maximum number of pending signals
-l The maximum size that may be locked into memory
-m The maximum resident set size
-n The maximum number of open file descriptors (most systems
do not allow this value to be set)
-p The pipe size in 512-byte blocks (this may not be set)
-q The maximum number of bytes in POSIX message queues
-s The maximum stack size
-t The maximum amount of cpu time in seconds
-u The maximum number of processes available to a single
-v The maximum amount of virtual memory available to the
-x The maximum number of file locks


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
limit cpu % usage for a process student04 Linux - General 15 03-18-2014 07:22 PM
need a command to limit cpu usage ra2000 Linux - General 2 12-03-2006 09:02 PM
Limit CPU usage slantoflight Linux - General 5 02-23-2006 03:37 AM
limit cpu usage by mysql eduac Linux - Software 3 06-08-2004 05:08 PM
How can I limit the CPU usage of a PID? ideasman Linux - Software 1 04-01-2004 07:15 AM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:33 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration