Thursday, May 3, 2012

SPRI (System Priority)

SPRI (System Priority) is a utility designed to que different processes with
different priority levels based on 3 class levels of importance (high,med,low).
 
The problem? Linux has priority levels to thread all tasks at, these prio's
are ranged from -20 to +19 with 0 as the default for all processes. So this
being the fact, with everything operating at prio 0 you got fights between
services as to who gets what resources first.

Solution? Very simply, que different processes at different priority levels
to effectively discipline the system on who gets what resource access first.

The average load level of a server can be substantialy decreased by using spri,
by as much as 5-20%, of course results may vary.
 
To install SPRI, execute the following commands (as root):

wget http://www.r-fx.ca/downloads/spri-current.tar.gz
md5sum spri-current.tar.gz | cut -d ‘ ‘ -f1

 
The md5sum should be like ef3e4c82b7473bf921e7a470ece037ff  
If not, then delete the file and download again.
tar -zxvf spri-current.tar.gz

cd spri-0.5

./installer.sh

cd ..

rm -rf spri*
 
The changes we need to make are as follows (done as root):
Edit /usr/local/spri/prios/med and ensure that it contains the processes qmail, MailScanner and spamd
Edit /usr/local/spri/prios/med-high and ensure that it contains the processes mysqld and mysqld-max 
Edit /usr/local/spri/prios/low and ensure that it contains the processes awffull, clamav, clamdscan, freshclam and python2.2
Edit /usr/local/spri/prios/low-med and ensure that it contains the processes php, php-script and proftpd
 
Run SPRI by executing the command: /usr/local/sbin/spri -v.
SPRI will set the priorities of the processes defined and ensure they 
are run at their set priorities.

EG: It will display like below. 

[root@tester]# /usr/local/sbin/spri -v
SPRI 0.5 [spri@r-fx.org]
========================
list file '/usr/local/spri/prios/rt' appears empty, nothing done for PRIO -2.

Setting httpd to priority 4:
5406: old priority 0, new priority 4
5409: old priority 0, new priority 4
5410: old priority 0, new priority 4
5411: old priority 0, new priority 4
5412: old priority 0, new priority 4
5413: old priority 0, new priority 4
9612: old priority 0, new priority 4

Setting mysqld to priority 6:
4551: old priority 0, new priority 6

Setting mysqld-max to priority 6:
No processes for mysqld-max running.

Setting squid to priority 6:
No processes for squid running.

Setting sendmail to priority 8:
No processes for sendmail running.

Setting MailScanner to priority 8:
No processes for MailScanner running.

Setting spamd to priority 8:
No processes for spamd running.

Setting ocwhttpd to priority 8:
No processes for ocwhttpd running.

Setting cppop to priority 8:
No processes for cppop running.

Setting cpanel to priority 8:
No processes for cpanel running.

Setting webmaild to priority 8:
No processes for webmaild running.

Setting php to priority 10:
No processes for php running.

Setting php-script to priority 10:
No processes for php-script running.

Setting proftpd to priority 10:
25358: old priority 0, new priority 10

Setting pure-ftpd to priority 10:
No processes for pure-ftpd running.

Setting urchinwebd to priority 12:
No processes for urchinwebd running.

Setting java to priority 12:
No processes for java running.

Setting tomcat to priority 12:
No processes for tomcat running.

Setting clamav to priority 12:
No processes for clamav running.

Setting clamscan to priority 12:
No processes for clamscan running.

Setting freshclam to priority 12:
No processes for freshclam running.

Setting rsync to priority 12:
No processes for rsync running.

Setting python2.2 to priority 12:
No processes for python2.2 running.

Setting ensim-python to priority 12:
No processes for ensim-python running.

Setting eximstats to priority 12:
No processes for eximstats running.

No comments: