Date: Tue, 12 Dec 2000 16:27:47 -0700 From: "Matt Simerson" <mpsimerson@hostpro.com> To: "'Gustavo Vieira Goncalves Coelho Rios'" <gustavo@ifour.com.br> Cc: "'freebsd-hackers@freebsd.org'" <freebsd-hackers@freebsd.org> Subject: RE: very big mail spool directory Message-ID: <8D18712B2604D411A6BB009027F644980DD7D5@0SEA01EXSRV1>
next in thread | raw e-mail | index | archive | help
I do it a little bit differently for my million user mail server. Rather than perform any (more) hackery on my MTA/MDA than necessary, I set up each mail domain as it's own UID/GID on the system. This approach has some limits but so far it's working great for me. With FreeBSD's pw tool and a bit of scripting it's pretty simple to build yourself a /usr/home/a/aa/aar/aardvark.com style tree. This type of solution has some great advantages. Since DNS (and consequently email addresses) is a hierarchy, it makes sense to keep the highest level (the domain name) mapping in one database. Qmail does this for us via it's users mechanism so we use that. When mail arrives qmail checks the /var/qmail/users/assign.cdb file and find's the username and home directory of domain owner. Qmail-local then mosies over to that directory (/usr/home/a/aa/aar/aardvark.com/) and obeys the contents of that domains .qmail processing. From there you can do whatever you'd like with mail for that domain. I use the vpopmail (http://www.inter7.com/vpopmail) package which includes a vdelivermail program that gets called. So, your .qmail-default has a call to vdelivermail which checks the username and does a lookup in the vpasswd.cdb that's contained in the domains home dir. There it finds the mail users actual mail directory and then drops it in there (subject to quota and other configurable limitations). The vpopmail package also has some mechanisms built on so that if the number of users for a domain exceeds a given limit (I can't remember exactly how many) then it builds a hash tree. Other than some compile time tuning, I leave the /var/qmail/queue untouched. So, you end up with something like this: #grep test /etc/passwd test:*:1454:88:test.com:/usr/home/t/te/test:/sbin/nologin #grep test.com /var/qmail/users/assign +test.com-:test.com:1454:88:/usr/home/t/te/test/domains/test.com:-:: #more /usr/home/t/te/test/domains/test.com/vpasswd test:*:1:0:testing:/usr/home/t/te/test/domains/test.com/test:1000000 test2:*:1:0:TEST2:/usr/home/t/te/test/domains/test.com/test2:10000000 Every mail message ends up with two database lookups (assign.cdb & vpasswd.cdb) but the databases are fairly compact and easy to replicate across an array of machines. It also means every authentication request (POP, IMAP, & webmail) also has two database lookups but again, the lookups are from small databases, very fast, and distributed across an array of machines. This is a very simplistic overview of how it works but so far it's been a good solution. Best of luck to you. Matt > -----Original Message----- > From: Gustavo Vieira Goncalves Coelho Rios > [mailto:gustavo@ifour.com.br] > Sent: Tuesday, December 12, 2000 12:50 PM > To: hackers@freebsd.org > Subject: very big mail spool directory > > > Hi folks, > > i am planning a very big email server, currently i am > planning for about > 8*2^16 users. > > I known that ufs has not good performance for very big directories, > i.e., using a single directory to hold too many entries may lead to a > low level performance.Since, my approach is to hash the spool mail dir > for my users. > > Every user will have a single id that will map it's email > address into a > unique directory, this later will hold the user maildir. My spool mail > dir is: /var/qmail/mail and all directory will be created within' it. > > The functions that will hash the id, accepts an id as input > and returns > a string for the user dir, like: > > Id String returned > 0 0/0/0/0/0/0/0/0 > 1 0/0/0/0/0/0/0/1 > . ./././././././. > 15 0/0/0/0/0/0/0/f > 16 0/0/0/0/0/0/1/0 > 17 0/0/0/0/0/0/1/1 > . ./././././././. > 32 0/0/0/0/0/0/2/0 > . ./././././././. > > > Got the ideia ? This allow me to perform at most 8*16 > lookup_dir routine > to get the users mails. So, my approach only works better for a number > of users bigger than 96 in traditional /var/mail (that > creates one file > for each user, what can make performance drop down for a > large amount of > users). I believe my approach is very good, since if you have (for > instance) 2^32 users, seeking the user dir would not take too > much time! > Any way i would really enjoy your comments. > > What you wizard have to say about my approach? > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8D18712B2604D411A6BB009027F644980DD7D5>