Archive for the ‘sysadmin’ Category

limiting I/O and CPU on Linux with nice and ionice

Thursday, March 18th, 2010

In one of my earlier posts about web hosting with Ubuntu Server, I left the startup script for the user-owned Apache instances as an exercise for the reader; the gist of it is to create a script in /etc/init.d/ (based on the “skeleton” file in that directory). The meat of it is something like:

for d in /var/www/*
do
  apache2 -f /var/www/$d/conf/apache2.conf -k start
done

This iterates over the directories in /var/www and runs Apache for each one, each with it’s own config file.

One interesting thing you can do here is make the user’s Apache process “nice” to fellow processes:

for d in /var/www/*
do
  nice -10 ionice -c3 apache2 -f /var/www/$d/conf/apache2.conf -k start
done

nice” changes priority for tasks waiting on CPU, while “ionice” changes the priority for tasks waiting on IO (for example disk reads and writes).

This can keep one busy or misbehaving server from interrupting other sites or important background tasks; alternatively, you could set one site to be highest-priority.

centralized logging with syslog-ng

Tuesday, October 6th, 2009

Just wanted to point out another excellent post from the Blog O’ Matty on centralized logging with syslog-ng.

I actually helped to set up real-time web analysis with syslog-ng (using TCP) and a slightly hacked webalizer (it was ignoring multiple hits happening on the same second) from a FreeBSD/Apache web farm ~10 years ago, and have been looking into it again for my current logging needs.

His blog has consistently awesome posts (if you’re interested in systems administration), and as your doctor I highly suggest that you subscribe.