The day from hell.

Today was not a nice day. In between servers throwing wobblers, the internet breaking (I sank teh Intarweb!) and the general hubbub of office life, my mail archiving program decided it was going to creak under pressure and stop our mailserver from coping with a copious mail influx.

I’m actually rather proud of my little archive system. It uses a PHP frontend with AJAX goodness to search any email that has come in or out of the building and then forward said email to whomever we please or download the attachment(s). The search through about 5GB of emails (that doesn’t include the attachments!) takes about 5 seconds at most.

The data is all stored in MySQL and is pumped in using a python extension to our mailserver software, vPop3.

The problem that caused a few emails to get stuck in a big old queue was that the python extension has to connect to the mysql database from scratch every time vpop processes an email. Under heavy load this can take up to 5 seconds per email and when vpop is accepting 4 or 5 emails a second there is soon a huge buildup.

The solution is simple: Make the extension that is run by vpop place the email to be archived in a spool folder of it’s own and let vpop do it’s thing asap. That way I can have a seperate process run once a minute (or run as a service if I decide to get really smart) to parse and archive the spooled mail to the database.

I’m right in the middle of splitting the current incarnation into two components and having one process run all the time. I’m also planning to release it to the community at large. Even though the user base for vpop is relatively small, I still think it will be of help to smaller businesses.