1

I want to limit the amount of processor power my sheduled jobs (Resque for a Rails application) use and I found this upstart that seems promising and might do what I want:

http://upstart.ubuntu.com/wiki/Stanzas#limit

But I am not so sure how to use it, say I want the process to use a maximum 50% of one of my two CPUs, what should I write in my upstart file?

Also, what will happen when the process reaches the limit?

3
  • I would go with 25 which is 50% of half the CPUs. If you reach the limit, the process is excluded from CPU scheduling. Nothing special though as it is the same as it would be if both CPUs reach 100%.
    – mailq
    Jan 2, 2012 at 23:22
  • mailq, thats a pretty good answer, why not put it in as an answer so you get credit and he can accept it?
    – SpamapS
    Jan 17, 2012 at 0:19
  • "limit cpu" stanza does not limit cpu to a certain percent usage, but will limit total time process is allowed to run on cpu. It will certainly take 100% of the cpu until time is up.
    – Tuminoid
    Feb 29, 2012 at 9:07

1 Answer 1

0

There is no such stanza in Upstart. "limit cpu" stanza will limit the maximum time (in seconds) process is allowed to be executed on CPU. During this allowance, it can take 100% of the CPU.

See man setrlimit(2): http://linux.die.net/man/2/setrlimit

RLIMIT_CPU CPU time limit in seconds. When the process reaches the soft limit, it is sent a SIGXCPU signal. The default action for this signal is to terminate the process. However, the signal can be caught, and the handler can return control to the main program. If the process continues to consume CPU time, it will be sent SIGXCPU once per second until the hard limit is reached, at which time it is sent SIGKILL. (This latter point describes Linux behavior. Implementations vary in how they treat processes which continue to consume CPU time after reaching the soft limit. Portable applications that need to catch this signal should perform an orderly termination upon first receipt of SIGXCPU.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .