[plug] Maildir vs mbox

Craig Ringer craig at postnewspapers.com.au
Thu Apr 1 14:46:57 WST 2004


On Thu, 2004-04-01 at 14:23, Ben Jensz wrote:
> I'm just curious as to what people think the cons / pros are of the two 
> mail storage formats?
> 
> Basically I've got a new server (IBM x225 - Xeon 3Ghz, 1Gb RAM etc.) to 
> build our new email machine with.  But I'm tossing up whether to go with 
> mbox as on our old email server, or to go with the Maildir format.

If the choice is maildir vs mbox, I'd pick maildir every time.

Given a full choice, I'd use Cyrus IMAPd (which uses a very maildir-like
backend format) instead.

> I'm 
> using Postfix as the MTA, so either format isn't a problem as I'm pretty 
> sure it supports both.

The MTA does direct delivery? I thought most "serious" mail systems took
message delivery over LMTP rather than letting the MTA do the delivery
directly into the mail spools.

> The machine has dovecot on there already for 
> pop3/imap support and according to the docs, that also appears to 
> support either mbox or Maildirs also.

I've been hearing a lot about dovecot lately. Is it new, or just
"recently risen to prominence"? Does it have any particularly notable
features that might interest me in it? I've found Cyrus IMAPd a little
tricky to get going, but absolutely wonderful from that point on.

> Now one of the issues we have had with the old server with mbox, is that 
> several users have spools that are rather large (i.e. several hundred 
> megs), due to leaving copies of messages on the server.  So what has 
> become a real issue is that when receiving a new message, it has to 
> rewrite this large file again, which does take a bit to do... and then 
> of course there is the fact that when they do a POP3 query, it spends a 
> bit of time reading the file as well.  So then of course the email 
> client may decide to remove certain messages from the server because 
> they've been deleted by the user during a POP3 query, so then it again 
> has to rewrite this rather large file. 

This is why mbox is _bad_. Corruption etc also tends to trash the entire
mailbox, rather than one message.

Most decent mail servers that use mbox keep a separate index file so
that POP / IMAP users don't have to read th entire file - but they can't
avoid the write problem. I've also seen index corruption with such
things occasionally - "I opened message <blah> and got <message2> with
half of <message3> on the end instead!".

> My understanding of Maildirs, is that they basically write the emails as 
> single files into a directory.  So there is no bog down of rewriting 
> (potentially) large files constantly.

Indeed. You need a filesystem that's good with many small files,
however. I've had great results with ReiserFS. Converting my mail spools
from ext3 to reiserfs actually gave me a speedup of somewhere between 2x
and 10x depending on the mailbox and operation.

Craig Ringer




More information about the plug mailing list