Packetizer Logo

Using Amazon EC2 to Provide Email Services

May 25, 2009

Amazon's Elastic Compute Cloud (EC2) is an amazing cloud service that offers a lot of flexibility. One might use the service to perform complex or time-consuming calculations, employing any number of servers in parallel. It can be used by web-based companies to store tons of information, with virtually unlimited storage capacity. Or it might simply be used to provide web hosting or email services to businesses and individuals. has been around since 2000 and we have had a few hosting companies. Initially, we hosted our web site and email on a simple web hosting account. As time progressed, the site grew and we found ourselves in need of a dedicated or virtual server. We tried the use of a virtual server and found the performance less than satisfactory and so we ultimately leased two dedicated servers: one to serve up web pages and one to provide email services.

One of frustration points with a dedicated server is that one's web site and email services are at the mercy of the hardware upon which your services are running. And, that became painfully clear when one of our servers started crashing unexpectedly. In need of a quick solution, we moved to the Amazon EC2 service. For those who are not familiar with the service, it is very comparable to virtual dedicated servers offered by other hosting companies. However, unlike other hosting companies, Amazon also offers virtually unlimited storage space on the "pay for what you use" model.

Another thing that is really cool about the cloud computing model is that if you setup your server and do not like the way you have it configured, you can just terminate the "instance" (a virtual server) and start a new one. Changing operating systems or configuration is very quick and easy. With a dedicated server, one has to re-install the operating system and that takes time. What might be an all-day upgrade effort with a dedicated server becomes a 10-minute task with Amazon EC2. In fact, one can prepare a new instance and get everything just the way it needs to be before terminating the old instance.

Having been successful with moving to the Amazon EC2 infrastructure, we then decided to move our mail server over. In the past, people had been reluctant to use EC2 to provide critical email services for two reasons: 1) there was apparently no way to assign a static IP address to a mail server, and 2) when an instance was terminated, any data stored on the instance was lost. However, neither of those two issues exist with enhancements Amazon has made to EC2.

One can now allocate an IP address for such services as email servers. Once allocated, that IP address is, in effect, statically assigned. As long as one wishes to continue using Amazon's EC2 service, the IP address is reserved and does not change. One merely maps the IP address to the instance that provides email or web services. If one starts a new instance (such as when moving from one operating system to another), one can re-assign the given IP address to the new instance. So, to the outside world, the IP address remains static.

Another significant introduction is Elastic Block Storage (EBS). EBS is a means of allocating storage space, with storage volume sizes presently ranging from 1GB to 1TB. To a Linux machine, this storage space presents itself just like any other block I/O device. When mapped onto a Linux machine, it appears as a device with a name like /dev/sdh. One can then format the storage space with a preferred file system (e.g., ext3) and mount the file system as if it was a local hard drive.

By utilizing EBS and statically assigned IP addresses, we had everything we needed to move Packetizer's mail server to Amazon EC2. We run Linux and use sendmail for message delivery. So, to prevent loss of data in the event that the mail server instance gets terminated (e.g., such as when there is a hardware failure), we allocated block storage for /var/spool/mail and /var/spool/mqueue. We could easily terminate the currently running instance, start a new one, put configuration files in place (which is entirely scripted), and then re-mount the EBS-based file systems. It is really cool and definitely a big step forward in terms of management.

But, not everything is perfect. What we discovered was that there were some organizations that considered Amazon's EC2 service as a source of spam and our IP address was blacklisted. Most of the organizations were reasonable and unblocked our assigned mail server address. Unfortunately, we were unsuccessful at convincing some organizations to unblock our address. They would argue that Amazon's cloud service uses dynamically assigned IP addresses and I could only counter the argument with the fact that we have a statically assigned address. Unfortunately, they would not listen to reason.

Fortunately, we have not really encountered significant problems with messages being blocked by those organizations. It has happened a few times, but I can report that the Amazon EC2 service has been a great platform for operating Packetizer's mail services, including our public mailing lists. If you have not experienced Amazon EC2, I would invite you to check it out. It truly changes the way Internet applications and services will be deployed in the future.

Click here to view the main blog page.