Wednesday, July 22, 2009

PostgreSQL Really Slow During Backups

These are my notes from debugging a website problem caused by backing up the underlying database. Symptom: When backing up the database, the website is very sluggish The old backup technique amounted to
pg_dump database > file.sql \
&& rysnc file.sql remote:file.sql
I removed the rsync component and the symptom persisted. Obviously that wasn't the cause. Based on a hint in the PostgreSQL mailing list, I reduced the total IO load by completely eliminating writes with
pg_dump database > /dev/null
That fixed the problem but unfortunately it makes a lousy backup strategy. By compressing the SQL before it hits the disk, I was able to reduce the total IO load and the symptom went away. The final backup incantation amounts to
pg_dump database | gzip --rsyncable > file.sql.gz \
&& rysnc file.sql.gz remote:file.sql.gz

Saturday, July 11, 2009

SMS MIME Type

Background

The MIME standards specify a Content-Type header for indicating the kind of information included in a MIME part. They also specify the multipart/alternative type which allows one to specify multiple representations of a single message.

For example, you can send an email message with a text/plain part and a text/html part. Each part contains essentially the same content but the latter is an HTML representation and the former is a plain text representation. If the recipient doesn't understand HTML, he can show the text version. A sender can craft each part to provide the best representation possible for each particular format.

Use Case

Nearly every mobile phone provider has an email to SMS gateway. Anywhere an email address is used, I can provide my gateway email address and receive the email as a text message. The problem is that neither the phone provider nor my phone knows how to summarize an arbitrary email into a 160 character text message. It does the best it can, but important information is almost always lost.

I would like to see a MIME content type for SMS messages: text/sms. One could then provide an SMS alternative along with HTML, plain text and others. The one sending the email — who presumably knows what information in the email is most important — would perform the summary. The end result would be much more useful SMS representations of emails.

It looks like there's an application/vnd.3gpp.sms which might be intended for this use although I can't tell for sure.