Emails are sent from a machine running Postfix 2.5.0. They are generated by software as a batch (triggered by certain events from outside), and injected very quickly into the local Postfix instance, which never sends out email directly to the Internet, but only through some Postfix gateways on other machines.

Destinations are very diverse, by domain and by username, but there's only one destination per message (no mass distribution of same message).

I want to "load balance" the outbound email between two Postfix gateways, each one running 2.7.0. Each gateway should receive an approximately equal amount of outbound messages.

I created a fake domain with the two gateways as MX records:

foobar.local. 604800 IN MX     0 thingone.local.
foobar.local. 604800 IN MX     0 thingtwo.local.

Then I created a sender_dependent_relayhost_maps table with the fake domain as the nexthop:

[email protected]    foobar.local

Tested it - seems to work.

But in reality there's no even distribution between the two nexthops. The local nexthop always receives 3x ... 4x more messages than the nexthop across VPN in the other datacenter. Local nexthop is also slightly faster hardware - not sure if that matters.

One way to do equal-volume load balancing would be to tell the initial Postfix instance to only send, like, 10 or 100 messages through any given SMTP connection to the nexthops, then hang off and connect again. Due to the way DNS works, this would ensure a statistically fair distribution, by volume, between nexthops.

Correct me if I'm wrong, but that doesn't seem possible with Postfix. I couldn't find any setting that says "cut off delivery after N messages".

Is there another way?

Also, can someone clarify how and why I end up with the 3:1 or 4:1 distribution? What makes one system receive more emails? Is it because it's more responsive? (closer topologically, also faster hardware) What's the algorithm?

--
Florin Andrei
http://florin.myip.org/

Reply via email to