So you installed your VPS all looks good but you have to high CPU with high load 2.0. You have optimize your program but still load is high so what can be done? You can simply limit any process which running or limit it on start. In this Tutorial we will show how to limit your VPS successful.
LINUX OS – RedHat Based – Debian – Ubuntu
First We install Subversion on your OS
yum install svn
Debian – Ubuntu
sudo apt-get install subversion
If subversion not found make sure to run command apt-get update && apt-get upgrade
After Subversion installed we download source of cpulimit
svn checkout svn://svn.code.sf.net/p/limitcpu/code/ limitcpu-code
Now we enter Dir we just downloaded
We install GCC on our OS
yum install gcc gcc-c++
Debian – Ubuntu
sudo apt-get install gcc make
Now we complain our source by command
Now we copy cpulimit to /usr/bin
mv cpulimit /usr/bin
Now if type
We should see the follow
Error: You must specify a target process
CPUlimit version 2.2
Usage: cpulimit TARGET [OPTIONS…] [– PROGRAM]
TARGET must be exactly one of these:
-p, –pid=N pid of the process
-e, –exe=FILE name of the executable program file
The -e option only works when
cpulimit is run with admin rights.
-P, –path=PATH absolute path name of the
executable program file
-b –background run in background
-c –cpu=N override the detection of CPUs on the machine.
-l, –limit=N percentage of cpu allowed from 1 up.
Usually 1 – 200, but can be higher
on multi-core CPUs (mandatory)
-q, –quiet run in quiet mode (only print errors).
-k, –kill kill processes going over their limit
instead of just throttling them.
-r, –restore Restore processes after they have
been killed. Works with the -k flag.
-s, –signal=SIG Send this signal to the watched process when cpulimit exits.
Signal should be specificed as a number or
SIGTERM, SIGCONT, SIGSTOP, etc. SIGCONT is the default.
-v, –verbose show control statistics
-z, –lazy exit if there is no suitable target process,
or if it dies
— This is the final CPUlimit option. All following
options are for another program we will launch.
-h, –help display this help and exit
So now how can we use cpulimit? here are basic commands to solve your CPU issue.
If we have current application running and we want to limit it we can simply do that by getting PID. which can be found in TOP command you type it in terminal.
cpulimit –p 1005 –l 30 -b
So above command limit application with PID 1005 with maximum of 30% of CPU
after enter the command simply press enter if it stuck at process detected
–p process number of application.
–l limit in % of how much application can use.
-b means it will run in background
What if we want limit application from start?
Here is simple solution example we will use Samp03svr as example
cpulimit –limit 30 ./samp03svr
So now we limit file samp03svr on start by 30%
This is simple way to limit your CPU usage
You can check your load of VPS by command
Which should look something like this
[root@blog cpulimit-code]# uptime
04:54:24 up 39 min, 1 user, load average: 0.00, 0.00, 0.00
Load average will be different for all clients depend on their usage and applications running on their VPS.
Final Results via TOP command
This is basically how to limit your CPU on your VPS you can change cpu % to any value you like to limit such process.
Any questions or if you have trouble in installing contact our support.