Running several SMTP servers in EC2 behind one load balancer and single Elastic IP – will it work

amazon ec2load balancingpostfixsmtp

We have web application hosted on EC2. We use two Ubuntu servers: one is web server, second is database server. Web server has public Elastic IP assigned. Now we want to send notification mails from the application (notifications about changes in the system made by other users). The simplest solution would be to install postfix SMTP server on the web server, and register its Elastic IP in Amazon e-mail server registration form (so they register reverse-DNS, remove mail transfer restrictions etc). I hope this should work without much problem (correct me if I'm wrong).

If the load on the web server increases, we plan to start additional EC2 instances with replicas of web server, setup Amazon's load balancer in front of them, and remap the Elastic IP to this load balancer – so that from outside it still looks like single server. But what with SMTP server then?

I think the best solution would be to run local postfix server on each of those web servers – so that application running on every web server always contacts with local postfix server via localhost. Still, from outside it will look like one mail server running, because of one public IP. But i'm not expert in SMTP stuff, how the process of sending mails work etc.

Perhaps I'm not aware of something, which would cause such setup to break. What do you think, is this approach ok?

Best Answer

It's my impression that many (all?) of the AWS IP's have been blacklisted as spam sources already, so the deliverability of mail sent from them won't be very good.

Also, using an AWS host as a mailserver seems like a bad choice to me, because it may disappear at any moment - together with the undelivered E-mail.

It would make more sense to have each AWS host hand the mail off to either a service that's paid to handle your outbound mail, or a VPS or traditional server that you control that will be available approximately 24x7. This will make it much easier to get the SPF record set up, etc., to maximize the chances that someone will see your mail.

You might take a look at Recommendations for SMTP services for massive mailing or Sendmail relay out of Amazon EC2? for more ideas.

Related Topic