Tuesday, July 17, 2007

TIP: linux process priority scheduling management

One way to alter process priority is by using renice linux command.

RENICE!

Renice says:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Renice alters the scheduling priority of one or more running processes. The following who parameters are interpreted as process ID’s, process group ID’s, or user names. Renice’ing a process group causes all processes in the process group to have their scheduling prior-ity altered. Renice’ing a user causes all processes owned by the user to have their scheduling priority altered. By default, the processes to be affected are specified by their process ID’s.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can basically apply renice linux command to currently running process and linux daemon, in which, you are trying to avoid service or daemon restart/reload, in a nice way. If you wish to make a currently running program or daemon faster, renice could be one of your friends here.

Let us say, your proxy uses squid service and by default, squid service was launched as a daemon by linux with a 0 (zero) nice value.

Let us view it:

# top -b -n 1 | grep squid
shows

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1849 squid 13 0 311m 307m 2172 S 0 30.5 51:16.42 squid
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Now, let us modify its priority process nice value with -2

# renice -3 1849
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1846: old priority 0, new priority -3
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

EDITED: (+19 instead of +20)
Remember, the lower the value it becomes, minimum (-20), the higher priority and attention it gets from linux OS. That means +19 is the least priority. Anything negative, the thread process or group of process runs faster.

Now, you proxy users would somehow enjoy more of your squid proxy aside from optimizing your squid.conf values.

Now, let us not forget the nice word here.

NICE!

By default, you could also launch a program with a default priority value using "nice" linux command combined with your scheduled midnight cron jobs like your backup shell scripts. By default, a zero priority (0) value is being used when launching any linux application.

Wonderfully issue:

12 01 * * * nice +5 /root/backup.sh > /dev/null 2>&1

which runs the backup shell script without being noticed during midnight hours, while doing the backup script thing.

Lovely.

0 comments:

Sign up for PayPal and start accepting credit card payments instantly.
ILoveTux - howtos and news | About | Contact | TOS | Policy