Postfix smtp outgoing load balancing

I got good workaround for balancing smtp outgoing from postfix mailing list archives(not using expensive real load balancer). suppose we have 4 smtp servers for outgoing email, and we need to configure/load balance like this:

                                                         +------------+
                                                         |            |
                    +----------> smtp backend a -------->|            |
                    |                                    |            |
clients --------> smtp lb -----> smtp backend b -------->|  Intenet   |
                    |                                    |            |
                    +----------> smtp backend c -------->|            |
                                                         |            |
                                                         +------------+

Here’s the configuration :

Postfix section

main.cf (smtp lb/load balancer)

/etc/postfix/main.cf:
relayhost = example.com

Dns sections

named.conf

/etc/named.conf:

options {
        directory "/var/named/data";
};

zone "example.com" in {
        type master;
        file "example.com";
};

example.com zone file

/var/named/data/example.com
$TTL 2D;

@ IN SOA a.ns.example.com hostmaster.example.com (
            1            ; Serial
            10800           ; Refresh after 3 hours
            3600            ; Retry after 1 hour
            604800          ; Expire after 1 week
            3600 )          ; Minimum TTL of 1 hour
@ IN NS a.ns
@ IN NS b.ns
a.ns IN A 192.0.2.1
b.ns IN A 192.0.2.2

@ IN MX    0 a.mx
@ IN MX    0 b.mx
@ IN MX    0 c.mx

a.mx IN A 192.0.2.3
b.mx IN A 192.0.2.4
c.mx IN A 192.0.2.5

By default relayhost(in main.cf) will listing all available mx on example.com and randomly shuffles mx with equal preference(Postfix client makes a random selection between equal-preference MX hosts), in this case these mx are our smtp backend for balancing outgoing mail.

Source :

postfix manual (relayhost)

Victor Duchovni (postfix-users mailing list)

Tags: , , , , , ,

Incoming search terms for the article:

postfix load balancing (5), postfix load balance (4), postfix loadbalance between 2 relayhosts (4), outgoing email telkom flash (3), postfix outgoing load balance (2), postfix outgoing load balancing ip (2), postfix relay balance (2), load-balance postfix (2), postfix load balancing outgoing (1), postfix loadbalance (1), postfix load balance smtp (1), postfix load balance relayhost (1), postfix load balance mx (1), postfix loadbalancer (1), postfix mx load balancing for outgoing (1)

One Response to “Postfix smtp outgoing load balancing”

  1. Frank says:

    If there’s additional interest in load balancing take a look at the affordables offered by companies like KEMP Technologies or the large enterprise ones offered by companies like F5 networks.

    http://www.kemptechnologies.com/?utm_source=blog&utm_medium=pv&utm_content=zs&utm_campaign=home

Leave a Reply