Viktor Dukhovni <postfix-us...@dukhovni.org> schrieb:
>On Mon, Jan 13, 2014 at 03:18:12PM +0100, Peer Heinlein wrote:
>
>> > We want to load balance mails from the intranet to the
>> > postfix-relayserver-farm for outgoing traffic.
>> > Can we abuse A-records to load-balance in the same way MX-records
>> > have been designed?
>> 
>> No, because in that case MX-Records would be useless.
>
>MX records can redirect mail delivery across organizational
>boundaries, where using A records that track the IP addresses of
>remote hosts would be impractical and allow for backup-MX hosts,
>which round-robin A records cannot.  When all MX preferences are
>equal one may be able to achieve a similar effect with "round-robin"
>DNS A records, provided the DNS server or client actually randomizes
>the address list.
>
>Unfortunately, as Wietse notes, the text in RFC 5321, Section 5.1:
>
>  The destination host (perhaps taken from the preferred MX record) may
>   be multihomed, in which case the domain name resolver will return a
>   list of alternative IP addresses.  It is the responsibility of the
>   domain name resolver interface to have ordered this list by
>  decreasing preference if necessary, and the SMTP sender MUST try them
>   in the order presented.
>
>(incorrectly) discourages address randomization by the SMTP client.
>What kind of address RRset ordering, if any, is performed by
>nameservres is configuration and implementation dependent.
>
>When the client is Postfix, it sensibly ignores the advice in RFC
>5321 and randomizes the addresses.  The randomization algorithm
>was made more uniform in Postfix 2.11-20130513.  When the reply
>order from DNS is not uniformly random, previous versions of Postfix
>exhibit a bias in the first selected host when shuffling more than
>2 records.  There was a noticeable bias to choose the second element
>more frequently than the rest and the last element less frequently
>than the rest.  The Perl code below computes the relative frequencies
>for 3 to 7 address records and the ratio of least to most frequent:
>
>    $ perl -e '
>       for ($n = 3; $n < 8; ++$n) {
>           $N = $n**$n;
>           my %c;
>           for ($i = 0; $i < $N; ++$i) {
>                   @x = (1 .. $n);
>                   $k = $i;
>                   for ($j = 0; $j < $n; ++$j) {
>                           $m = $k % $n; $k = ($k - $m) / $n;
>                           ($x[$j], $x[$m]) = ($x[$m], $x[$j]);
>                   }
>                   ++$c{$x[0]};
>           }
>           for (sort {$c{$b}<=>$c{$a}} keys %c) {printf "%d:%d ", $_, $c{$_}}
>           printf "%4.2f\n", $c{$n}/$c{2};
>       }'
>    2:10 1:9 3:8 0.80
>    2:75 1:64 3:63 4:54 0.72
>    2:756 3:656 1:625 4:576 5:512 0.68
>    2:9605 3:8525 1:7776 4:7625 5:6875 6:6250 0.65
>    2:147498 3:133092 4:120744 1:117649 5:110160 6:101088 7:93312 0.63
>
>The more mathematically astute among you might guess that "0.63"
>is close to the limiting ratio, and that the limit is the ever
>common "1 - 1/e".  So the least frequent host is used at least 63%
>as often as the most frequent.
>
>If your DNS server returns address RRs in a fixed order, and you
>want Postfix SMTP clients to impose a more uniform load on a pool
>of hosts specified via a "round-robin" A record, upgrade to 2.11.0
>which will be released this month!  Alternatively, configure your
>DNS nameserver to shuffle A records.
>
>As noted by others, various SMTP implementations will process
>multi-homed (aka round-robin) relay hosts and MX hosts as they see
>fit.

Besides the lack of randomization in the mail client, there is another question:
Should the mail client implement support for multiple MX or implicit MX (A when 
no MX is given) records when sending all traffic to smarthosts which are 
loadbalanced by DNS regarding to the rfc 5321?

Example: client sends mail to the internet. It relays to the smarthost with the 
fqdn smart.example.com. smart.example.com has 3 A records. How does the client 
treat the A records and what does he, if one is done?

--
toerb

Reply via email to