Spamassassin load balancing with HAProxy
With my old company I still maintain the email services. The mail load increased over the last year so the server itself isn’t able to handle both email handling and spam tagging. For that purpose I started to deploy a dedicated Spamassassin server which didn’t perform well in the beginning. A second server with the same configuration was installed to help the first one.
Later on it turns out that the networking stack of spamc is not scaling very well as we suffered a lot of connection resets and a bunch of mails were not scanned at all due to connection losses. I started to think of a better load balancing and started to play around with LVS which turns out to be very complicated.
I remembered a fine program which can handle HTTP and TCP load balancing and is acting as a transparent proxy: HAProxy. With this load balancer installed on the mailserver both Spamassassin machines are balanced depending on their actual connections which ensures a better connection handling than simply DNS round robin.