This week I migrated my 13 years old Wordpress blog to a serverless architecture. Here is why.
The first version of the blog, between 2005 and 2013, was hosted at Dreamhost. Since I joined AWS in 2013, I migrated it to a simple cloud-based architecture : one Amazon EC2 instance, one Amazon RDS MySQL database and an Amazon CloudFront distribution, coupled with some AWS Web Application Firewall rules to filter out the bulk of unwanted traffic. I developed a couple of scripts to backup the AMI and collect logs with Cloudwatch, created alarms to be alerted about unusual events etc … Maintenance was minimal, my job was just to keep Linux, Apache, Wordpress up-to-date and monitoring the occasional alarms. But this was still too much for me, on top of my professional and family life.
So, I decided to get rid of Wordpress, and to host this blog using static HTML files instead. This new version is hosted on Amazon S3, using Amazon Cloudfront as CDN. No more Linux or Wordpress to patch, and pages are loading much faster.
In addition, I expect a major reduction of my personal AWS bill. An on-demand t2.micro
EC2 instance in Frankfurt (eu-central-1
) is ~$10/month and an on-demand db.t2.micro
RDS instance in Frankfurt, including storage for the backups, is about $17/month, for a total of $27/month. As I was using reserved instances, my real cost was lower than that (EC2 $4.5/month and RDS $6/month for 3 years reserved instance, upfront). The new cost will be limited to S3 storage (I don’t even have half a giga), S3 requests and the Cloudfront requests & outgoing bandwidth. I expect the new total to be less than $1/month.
Here are the tools I used for the migration :
origin-access-identity
to access to S3These are a few easy steps to follow to simplify your architecture and reduce your hosting costs to less than a price of a cup of coffee … per month !
UPDATE October 20th 2018
After a couple of days, I noticed many S3 403 Forbidden
errors in Cloudfront logs. I realized some of my old blog articles are being referenced from other locations and they do receive hourly traffic. Unfortunately, the new blog, the one generated with Jekyll, is hosted at the root /
and the old Wordpress site is hosted at /old/
, so I had to provide a redirection for these old permalinks to the new /old/
structure. I wrote 10 lines of Javascript to take care of that and hosted this as a Lambda @ Edge funtion, invoked by Cloudfront when content is sent back from S3. In case of an S3 403 error code and a matching URI pattern, the Lambda function sends a 301 Permanently Moved
redirect order to the new location.