In the last few weeks I have built from scratch a new SMTP server (based loosely on the concepts in Qpsmtpd) using Node.JS. A number of people have asked me why, so I thought I would create a blog and start writing about it.
The main reason really was to just learn something new. I’ve been coding mostly in perl now for 15 years, and while I still appreciate the language, the rough edges do start to wear on you. A few years ago I decided that new thing would be Ruby, but the performance of the language just wasn’t there, and so I gave up. I tried Python for a while, but didn’t like it either. I had coded in Java before, and so I knew that wasn’t what I wanted.
The other thing that really got me interested is that I’ve been programming async-IO systems in Perl for a while now, and the major problem I find there is that none of the other perl coders are used to writing async systems, and so all the libraries out there are synchronous. This is a real problem if you plug those into an asynchronous system because it blocks the event loop.
With Node.JS everyone is coding async libraries, because the core libraries are asynchronous, and so everyone just expects it to work that way. Genius!
So I got cracking with some coding, figured out how the weird and slightly fragile OO system works, and came up with Haraka.
What I am really enjoying about hacking on this (rather than Qpsmtpd for example) is I have some really solid plans from the start of how I want monitoring, configuration, etc to work across a cluster of mail servers, rather than just an individual server. This will at some point (it hasn’t yet, but it’s early days) influence my design. One way we’re seeing this right now is very early on I have implemented a web-based graph built-in to it which shows you which plugins rejected your mail. I hope to advance that some day to include a full breakdown on things like which DNSBL rejected your mail, which will be very sweet indeed. And then maybe at some point even have it going down to the individual domain and recipient level… Oh that would rock.
So how is performance? Well so far it looks pretty good. I can process and save to disk about 5000 mails/sec on my iMac. I’m not sure yet how that stacks up to other mail servers (even Qpsmtpd) but I’m willing to bet it’s not bad.