In a case when
Well if money under an equipment upgrade is budgeted (in mythical good time), but now it is necessary to receive performance maximum from the available resources.
On open spaces of the Internet there are many articles on a subject as to implement it — failure from LAMP for benefit of nginx+php-fpm or uWSGI (out of need), their thin setup (we do not forget to cache a statics), the PHP installation of an accelerator, tuning of DBMS (if it is used), and other useful things.
But even at installation and competent execution of all points it is possible to optimize work of services a little more.
It will be a question of a task of priorities for processes (man nice, man renice).
The kernel of linux supports gradation of priority of processes from-20 to +19 (negative value — high priority, positive value — low priority, 0 priority — default value for the user processes).
SPRI — allows to appropriate a priority of start of services, depending on your needs, for improvement of operability of the server.
At competent setup reduction of the LA server by 5-20% is possible.
We download the last release here.
# wget http://www.r-fx.ca/downloads/spri-current.tar.gz
We unpack archive
# tar -xvzf spri-current.tar.gz
We start an install.sh installation script
# /bin/bash spri-0.5/install.sh
The script will be set in directory/usr/local/spri and usr/local/sbin/spri will be created simlink on it/, in cron entry not its execution will be added each 45 minutes (changes at discretion and to needs).
# less /etc/cron.d/spri */45 * * * * root /usr/local/sbin/spri -q >> /dev/null 2>&1
By default SPRI divides processes into six categories: low, low-med, med, med-high, high, rt (I think a difference in "importance" it is intuitively clear from the name).
Structure of a directory of a script (/usr/local/spri)
- spri — a script which is caused each 45 minutes (we look in cron) and changes priorities for demons according to the mood.
- conf.spri — a config file in which priorities for groups are defined and is set a way on which information on lists of the services entering into this or that group undertakes.
- ps.ignore — processes which are ignored.
- prios directory — files of priorities of groups (high, low, low-med, med, med-high, rt) with the services written in them are stored in it.
Adding, removal of service from group is carried out by editing the necessary file, for example / usr/local/spri/high.
For viewing of a priority it is possible to use the utility of top, value in the NI column
For application of the changes made to a config files of groups it is necessary to start a script.
It supports two formats of start — noise-free and talkative.
# spri SPRI 0.5 [email@example.com] ======================== -v Show Output -q Hide Output
quite start, start with a key is registered in cron - v is convenient for drawing up an overall picture of current settings (not too that conveniently in turn to climb on all six config files).
As the script is applied each 45 minutes (if parameter did not change hands), it is necessary to add it to autostart for start after planned and not really rebut.
We open the rc.local file
also we add a line
/bin/bash /usr/local/sbin/spri -q
! to add till the line exit 0, we remain and we leave a text editor.
! it is possible to register also without full paths — spri - q
Depending on the tasks we place priorities to services, and we analyze result (finding of "ideal" result most likely will require several attempts).
At the correct arrangement of priorities it will turn out to improve productivity of the project a little more.
* https://www.rfxn.com/projects/system-priority/ project website
This article is a translation of the original post at habrahabr.ru/post/274297/
If you have any questions regarding the material covered in the article above, please, contact the original author of the post.
If you have any complaints about this article or you want this article to be deleted, please, drop an email here: firstname.lastname@example.org.
We believe that the knowledge, which is available at the most popular Russian IT blog habrahabr.ru, should be accessed by everyone, even though it is poorly translated.
Shared knowledge makes the world better.