Limiting CPU on some processes on web server

Eduardo Morras emorrasg at yahoo.es
Fri Mar 13 18:46:31 UTC 2015


On Wed, 11 Mar 2015 12:26:56 +0000
opendaddy at hushmail.com wrote:

> Hi!
> 
> I run this web app that depends on ImageMagick to process images and
> ffmpeg to process videos. These processes, unfortunately, consume
> 100% of my CPU, rendering my web app unusable (gateway timeout).
> 
> Tried `nice -n 19` but to no avail.
> 
> What other options do I have?

You can use cpuset from shell script, if use imagemagick:

cpuset -c -l 1 /usr/local/bin/ImageMagick <insert parameters>

to restrict imagemagick to use cpu 1.

If process is running, use

cpuset -c -l 0,2 -p <pid of your webapp>

To force your webapp to run only on cpus 0 and 2

Check man cpuset and man 2 cpuset for more information.

> Thanks!
> 
> O.D.

---   ---
Eduardo Morras <emorrasg at yahoo.es>


More information about the freebsd-questions mailing list