How to manage an intensive processor process on a server

I need to run a Python script with processor and memory (parsing and modifying a long WAV file) as a background process on my web server (VPS) between HTTP requests.

It takes up to 20 seconds to run the script, and I'm concerned about the performance on my server. Is there a good approach to lowering the priority of a process that periodically yields to OS control or otherwise protects the performance of my modest server?

+7
performance python signal-processing
source share
2 answers

Assuming this is a UNIX server, you can use nice command to lower its priority. That should do the trick.

+7
source share

You can use cpulimit on a Linux based server. This will allow you to limit the CPU usage (specify the percentage limit) of even already running scripts, and its use is quite simple.

It is available in the Debian repository, so you can easily install it with aptitude:

apt-get install cpulimit 

Typical uses of cpulimit include:

 # To limit CPU usage to 75% of program called foo: cpulimit -e foo -l 75 # To limit CPU usage to 50% of program with pid = 1582 cpulimit -p 1582 -l 50 
+5
source share

All Articles