OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
Re: Postfix + php mail()

From: Matt Kukowski (elitescripts2000yahoo.com)
Date: Sun Nov 21 2004 - 09:47:31 CST


I run a mailing list service at www.planetxmail.com and send a lot of emails per day... I spent close to 1 1/2 years perfecting efficiency and here is what I came up with that will fix your problem about injection speed.
 
The only thing U really must do is place the PostFix queue in a RAM disk.. meaning the queue is in RAM.. the reason for slowless is due in most part to DISK writting/reading limits. Since the queue ( which is where the read/writes occur are in RAM.. it is about 10+ times faster! if not more.. ) I currently run on a XEON Dual 2gigertz CPU machine can inject about 80 emails per second.. which is 4800 injections per minute.
 
There is a thing called RamDisk and tmpfs. Ramdisk is the old way.. tmpfs is new.. but U need your kernel to support tmpfs ( temp files systems which exist in RAM/memory )
 
One person mentioned using SMTP to inject.. but if you require a different email per email address your mailing then you cant, since when U inject with SMTP the email must be the same email for ALL addresses your mailing to...
 
To set this up do the following:
 
1. Create a tmpfs in RAM of size 200 megs ( or what U can afford ) run:
mkdir /tmpfs
mount -t tmpfs -o size=200m,nr_inodes=999k,mode=775 tmpfs
 
2. Copy the postfix queue structure to new tmpfs ( which is in RAM ) run:
mkdir /tmpfs/postfix
cp -a /var/spool/postfix/* /tmpfs/postfix/
 
3. Tell postfix the location of your queue location: (edit /etc/postfix/main.cf)
postconf -e queue_directory=/tmpfs/postfix
postfix reload
 
4. add/edit /etc/fstab entry to create tmpfs on reboot:
tmpfs /tmpfs tmpfs size=500m,nr_inodes=999k,mode=775 0 0
 
5. add entry in /etc/init.d/bootmisc.sh which will create the tmpfs postfix queue
structure on reboot. ( Because, when rebooting everything is lost in RAM. )
mkdir /tmpfs/postfix; cp -a /var/spool/postfix/* /tmpfs/postfix/
 
Now, this method also saves Harddisk wear and tear! Since there is no drive access
happening since its all in RAM! ( You can also put your /var/log/maillog in this
tmpfs as well! becareful tho as the tmpfs can get filled up and cause problems... On
problem machines I just leave the maillog on disk since it can become quite large.
 
Hope this helps...
 
-matt

Magnus Bäck <magnusdsek.lth.se> wrote:
On Sunday, November 21, 2004 at 14:17 CET,
James
wrote:

> I have recently been moving on swapping out all of my older servers
> running qmail on linux. Ive done all of the migrations well except for
> our internal mailout servers. This is where we have not been able to
> tweak it to the same extent that we had on the old setup with qmail.
>
> The problem im having is the new servers are Redhat ES 3.0 with the
> standard RPMs of postfix. When I configure php's sendmail path I set
> it to sendmail.postfix. (From what I gather this is the postfix
> sendmail wrapper??? in Redhat).

Yes, but the alternatives system should setup a symlink
sendmail -> sendmail.postfix so that you always can refer
to the current sendmail-compatible injection program as
sendmail.

> It runs very slowly. Previously we where injecting around 100,000+
> emails into the queue in well less than an hour. Now it injects at
> about 1000/minute. The scripts are identical the only difference is
> qmail has been replaced with postfix and the OS is now Redhat ES 3.0
> where it was Slackware 7. I am using the mail() function in php.

If you need high performance, the sendmail interface just
won't do. Use SMTP instead.

[...]

--
Magnus Bäck
magnusdsek.lth.se

                        
---------------------------------
Do you Yahoo!?
 The all-new My Yahoo! – Get yours free!