Re: Load balancing PostFix Mail Out

From: Willy Tarreau <w#1wt.eu>
Date: Thu, 3 Dec 2009 06:40:14 +0100


On Thu, Dec 03, 2009 at 06:09:06AM +0100, boris17480#gmail.com wrote:
> We are "handle" arround 500'000 mails 3 times by week, but we have to
> load balance because we used dkimproxy for signing emails, and we have
> to use 3 IPs to don't be "bad" for mail services receiver.

But your first postfix or whatever relay should be able to do that by itself if you specify multiple outgoing gateways, am I wrong ?

> Yes I read that for the header manipulation (that's why I said "maybe
> request").

confirmed, it's just for HTTP.

> It's not *only* for redundancy, it's also for buying cheap server and
> send emails faster. I really love this MTA but if you want to use more
> than one postfix on the same server (with multiple IP) it's quite simple
> to create virtual machine and use haproxy to do balancing.
>
> Currently my stats of sending are like this with HAProxy:
> ara:/var/log# time smtp-source -s 40 -l 10120 -m 100097 -c -f
> root#mydomain -4 -t root#another_domain_of_me localhost:10025
> 100097
>
> real 6m39.309s
> user 0m5.864s
> sys 0m13.913s

6 minutes for how many mails ? Also something looks wrong here. Your tool took 19 seconds of CPU and waited for something else for 6m20. Most likely this is the remote end but I find it disturbing that the remote end needs about 19* more time than the local sender to deliver a mail, looks like some DNS resolver issues.

> We just want to "put in postfix/haproxy queue" mails to "unload"
> apache/php server as fast as possible.

haproxy will not queue your mails anyway. This is a job for your local postfix server. By the way, it's very common to use a local MTA from web applications to send mails out. That way you use local queuing which is very cheap and offers excellent response times. And it's easy to recover from network issues. At worst, you just have to wipe out the queue in case of problem.

> My "smtp source" test work nice directly on HAProxy, my php script
> (using fgets for smtp) really sucks to do it.

I have really no idea about what your php script does. But your mention of "fgets" seems strange to me because in the libc and in other languages, "fgets" is what you use to read one line from a file/pipe/socket. So I don't see the relation between that and emitting a mail :-/

> I just begin to improve haproxy performance for load balancing mail, and
> my email to the mailing list is just here to have tips and mistakes I've
> done ;)

Quite honnestly, it has little added value for SMTP because the standard tools already do that very well. I really think that you're using it to try to solve a wrong problem. If your mails take a long time to be forwarded from the local postfix to the remote ones, you have another problem you need to solve. Haproxy might only slightly hide the problem, which does not mean it will be solved.

Regards,
Willy Received on 2009/12/03 06:40

This archive was generated by hypermail 2.2.0 : 2009/12/03 06:45 CET