High Availability — When (Server)Less Is More

Carsten Owerfeldt
Current architecture of https://serverless-blog.com

I have been working with Amazon Web Services (AWS) for several years and since I learned about AWS Lambda at the AWS re:Invent 2015 I am pretty enthusiastic about serverless architecture. So when I eventually had a bit of spare time I thought: Why not setup a serverless blog and write about it?

Usually, if you like to host your own blog and not use one of the many blog services, you will install WordPress on an EC2 instance or if you opt for the state-of-the-art solution, you will pull the WordPress image from docker store and run the container. But still you will need to take care of the docker swarm host: setup a backup system with a load balancer, replicate your (MySQL) database, patch the OS, etc.

You will also want to have 24/7 presence so an availability of 99.99% would be something you should aim for. It might not be quite justified for a blog, but if you think about your productive system — this is what you want. Four nines have round about an hour downtime per year — giving you a 4 minutes update, patch and upgrade window per month. Even with a NoSQL database this is not easy to achieve — with a serverless approach you get it for free!

The blog https://serverless-blog.com/ is not “hosted” on any virtual machine (EC2 instance) at all. It is “only” using (almost*) free services provided by AWS. All static content like images, html and js files are served via a S3 bucket. Blog posts and comments are stored in DynamoDB. Any code that needs to be computed to retrieve and store comments in DynamoDB is using AWS Lambda.

* The used services are free even after the one year Free Tier — at least if you assume a normal usage — and only S3 buckets will be charged, however they are really cheap ($0.0245 per GB).

AWS S3 is designed to have a nine nines durability (99.999999999%) and no planned downtime. S3 buckets are stored in several availability zones within a region. So you don’t need to worry about backups nor replication at all and it will act as a web server, too. So you won’t need Apache or nginx anymore.

Amazon DynamoDB is a managed NoSQL database made for IoT scale requests. If you accept the DynamoDB limitations and quirks, you will get a fully managed database with out-of-the-box sharding and replication in 3 availability zones as well as up to 200 million read and write requests for free!

AWS Lambda: FaaS — Functions-as-a-Service takes microservices to the next level. You actually upload only your function source code in your preferred language (i.e. Java, C#, PHP) — in my case it is node.js. Amazon will compute the code whenever needed and at any scale, as long as you can pay the bill .

You don’t need to auto scale, load balance or orchestrate anything.

AWS API Gateway: Lambda functions require the AWS SDK, so if you have a „legacy“ application or you want to avoid a vendor locking, you can hide your Lambda code behind a normal REST API. Your frontend — for this blog I use Angular 2 — will work seamlessly without any code changes.

Amazon CloudFront is a global content delivery network (CDN) service that accelerates delivery of your websites, APIs or other web assets. It also allows you to add a SSL certificate, so your S3 bucket can now be accessed via https.

In one of my next posts, I will describe how you can migrate your MEAN stack to this serverless approach.

Carsten Owerfeldt

Written by

Experienced research and development manager with a demonstrated history of working in the computer software industry. Co-founder and former CTO of Gastrofix.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade