From owner-freebsd-hackers Tue Dec 12 15:34:53 2000 From owner-freebsd-hackers@FreeBSD.ORG Tue Dec 12 15:34:46 2000 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from relayout1.micronpc.com (meihost.micronpc.com [209.19.139.2]) by hub.freebsd.org (Postfix) with ESMTP id 3B4D437B400 for ; Tue, 12 Dec 2000 15:34:46 -0800 (PST) Received: from mei00wssout01.micron.com (mei00wssout01.micronpc.com [172.30.41.216]) by relayout1.micronpc.com (2.5 Build 2640 (Berkeley 8.8.6)/8.8.4) with SMTP id QAA21774; Tue, 12 Dec 2000 16:33:56 -0700 Received: from 172.30.41.146 by mei00wssout01.micron.com with ESMTP ( WorldSecure Server SMTP Relay(WSS) v4.5); Tue, 12 Dec 2000 16:27:58 -0700 X-Server-Uuid: 6b1d535a-5b27-11d3-bf09-00902786a6a3 Received: by imcout1.micronpc.com with Internet Mail Service ( 5.5.2650.21) id ; Tue, 12 Dec 2000 16:27:57 -0700 Message-ID: <8D18712B2604D411A6BB009027F644980DD7D5@0SEA01EXSRV1> From: "Matt Simerson" To: "'Gustavo Vieira Goncalves Coelho Rios'" Cc: "'freebsd-hackers@freebsd.org'" Subject: RE: very big mail spool directory Date: Tue, 12 Dec 2000 16:27:47 -0700 X-Mailer: Internet Mail Service (5.5.2650.21) MIME-Version: 1.0 X-WSS-ID: 16286BF48296-01-01 Content-Type: text/plain Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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