|
How do I load balance an outgoing mail queue with Proto Balance Mail?
This question pertains to admins who want to use Proto Balance Mail
for outgoing mail and are not interested in POP or incoming SMTP.
You would be asking this question if you found your outgoing SMTP
servers experiencing high load and very long queue lengths.
There are two ways to load balance outgoing SMTP:
The preferred way is to use Proto Balance Mail's capabilities to
direct SMTP sessions. Begin by adding an "SMTP Cluster" in the
config web page. Add "Boxes" for each outgoing mail server and set
their traffic lights to green. In the cluster configuration set
"Client relay address ranges" to cover all the IP addresses that are
allowed to relay email. Then set "Recipients per MAIL FROM..." to a
high value like 10000. Set "Allow notifications..." at your
preference. Set "How to choose relay box" to [Load balance over
SMTP-relay-enabled boxes]. Under the "Info" tab, set the four
settings "Distinct FROM emails/domains per IP address", "MAIL FROM
quota", and "Recipient exceeded quota" to a high values like 10000.
Then go to each box and select "SMTP relay" to [Enabled].
Such settings will result in outgoing SMTP deliveries being
more-or-less randomly distributed between the boxes. Proto Balance
Mail will use "consistent hashing" based on the sender address to
choose the box. This means that the same sender will tend to send
through the same box unless that box is unavailable.
The second way to load balance is to use Proto Balance Mail's pure
TCP load balancer with queue monitoring. Click on "Add Cluster" to
add a pure TCP load balancer listener on port 25. Add a Box for each
outoging SMTP server. Set all traffic lights to yellow. You now need
to write scripts that run on your SMTP server that can turn the
box traffic lights from green to yellow based on the mail queue
length:
Begin by going to the "Login" tab and clicking on [Change password].
Here you will be able to enter your XML access key. Let us say that
your XML access key is "qwerty12345" and your cluster is called
"Cluster001". In order to change BOX001's traffic light to green,
your SMTP server needs to issue the following XML to port 8080 of
Proto Balance Mail:
<?xml version="1.0" encoding="UTF-8" ?>
<green>
<accesskey>qwerty12345</accesskey>
<clusterid>Cluster001</clusterid>
<boxid>BOX001</boxid>
</green>
If your mail queue becomes too full, you can issue the XML:
<?xml version="1.0" encoding="UTF-8" ?>
<yellow>
<accesskey>qwerty12345</accesskey>
<clusterid>Cluster001</clusterid>
<boxid>BOX001</boxid>
</yellow>
An example python script to do this is:
import socket, string
from myconfig import *
balance_address = "192.168.0.1"
def xmlsubmit(xml):
c = socket.socket()
c.connect ((balance_address, 8080))
c.send("POST /xml HTTP/1.0\r\n")
c.send("content-length: %s\r\n" % len(xml))
c.send("\r\n%s" % xml)
r = ""
while 1:
v = c.recv(4096)
if not v:
break
r = r + v
return r
red_yellow = """
<?xml version="1.0" encoding="UTF-8" ?>
<yellow>
<accesskey>qwerty12345</accesskey>
<clusterid>Cluster001</clusterid>
<boxid>BOX001</boxid>
</yellow>
"""
print xmlsubmit(red_yellow)
How you establish the length of your mail queue depends on the
SMTP software you have available.
|