How to run a WordPress website on AWS for less than 50c per day

Why should I run my WordPress site on AWS?

There are many choices to make when planning your website infrastructure. You can go the easy route and outsource web hosting to a third-party and for some organisations this might be a sensible solution, especially if you are not technically aware. The disadvantage to this is the administration of the webserver is not under your control, and you are limited in how much configuration/customisation you can do. You are tied into the hosting providers administration tools and for some that is unacceptable. You could opt for a web hosting VPS (Virtual Private Server) which does give you the flexibility and freedom (within certain limits) to implement your own customised infrastructure.

The other alternative is to utilise an Cloud provider such as AWS or Azure to host your website. Another term people might use for this is IaaS (Infrastructure as a Service) . Although the provision of hardware could be seen as broadly comparable with a VPS, there are differences and advantages to utilising this type of model. Think of it as a utility service. You consume a resource, and you get billed accordingly for it, conversely If you don’t use a resource, you don’t get charged. This is great as we can start small, but we have the ability to scale out (very quickly if required) our infrastructure as our website/business grows. We do have to be careful to monitor and manage our costs, but that is a discussion for another day!

Another advantage of using a provider such as AWS is the sheer availability of “in-house” solutions that can integrate into your website. Do you need a Content Delivery Network, no problem use CloudFront. You want a Relational Database, which one suits you best? MySQL, MariaDB or PostgreSQL? Sorry, you actually wanted a fully managed, scalable, fault tolerant database, okay then use Aurora. The sheer choice of products and solutions can at first be overwhelming, but like anything else after you’ve used it for a while it all starts to make sense.

The final advantage I’d like to talk about in this article is pricing. When you sign up for an AWS account for the first 12-months, many AWS services are free. I realise that Amazon want to reel us in and get us addicted to their lovely Cloud goodness, but for startups or organisations starting to explore the Cloud and how it can benefit their business it is a great way to dip your toe in the water.

Don’t eat all the candy in the sweetshop

Choosing a hosting infrastructure is always about cost versus functionality. You want something, mostly you’re going to have to pay for it. Striking a balance between the two is about hitting the sweetspot and being strict on what your website needs as opposed to what you would like it to have.

In my case this site will be starting off small, I don’t have an existing large base of viewers and my hosting needs are modest. One of the reasons I launched this website was to help me document my journey through the AWS ecosphere, as well as hopefully imparting some of my hard won experience.

Having designed and implemented websites previously I had a good idea of what I wanted. I have used Joomla extensively in the past and it is a great Content Management System, but frankly it was overkill for what I wanted. I decided to go with WordPress as it offers a good balance between ease of use and functionality. I mean, I wanted a blogging website and that’s what WordPress was designed for right?

Okay so what about infrastructure? Well in my case I wanted to prioritise costs over functionality. If the site grows I can always redesign the infrastructure to take account of that. In the end I went with the following:

AWS WordPress Logical Infrastructure Overview

Although I would liked to have implemented load balancers, ElastiCache, EC2 auto scaling and the kitchen sink it was not practical or necessary. I could quite happily cope with a small amount of downtime in exchange for lower operating costs.

A primary requirement was to have the infrastructure creation automated using CloudFormation. In a worst case scenario I could easily move my website to a new AWS region and have it up and running again in a matter of minutes.

Although I did not want to reinvent the wheel I did feel it would be beneficial to start a WordPress implementation from scratch. If nothing else, I would gain a better understanding of CloudFormation. Also, as someone relatively new to AWS having recently passed my AWS Certified Solutions Architect Associate accreditation I felt it wouldn’t hurt to do a deep-dive into some of the AWS product set.

  • CloudFormation – AWS CloudFormation is a service that helps model and set up AWS resources so that we spend less time managing those resources and more time focusing on your applications that run in AWS. We create a template that describes all the AWS resources that you require and CloudFormation takes care of provisioning and configuring these resources. You don’t need to individually create and configure AWS resources.

    I am very interested in CloudFormation and this was a perfect project to help me learn all about it. I will be doing an in-depth article on CloudFormation and how to use it to automate your infrastructure and why IaC is so important in modern Cloud infrastructure.
  • Single Availability Zone – Think of an availability zone as a physical network. There are some down sides to using a single availability zone, primarily if the entire availability zone goes down then so does my website (oh the horror!!). Look, I’m prioritising performance and cost over reliability at this point. If my website happens to go down for a bit due to reduced redundancy it’s not a big deal, it’s not like I’m Samsung or Apple 🙂
  • Content Delivery Network – Think global, not local. Your website might work great locally when you users are near to your server, but if you’re on the other side of the world people aren’t going to wait several seconds for your content to load. CloudFront is Amazons Content Delivery Network and is surprisingly affordable. It is also very configurable.
  • Database – I selected MariaDB as it scales well and is more performant than MySQL especially on more limiting hardware. If you are interested a good article about MySQL vs MariaDB performance can be found here.

    I don’t need at this stage a fully redundant database. There are additional costs involved in running a redundant MySQL database (Multi-AZ DB deployment) as you need a standby EC2 instance to allow replication of your data in the event of a failure of your primary DB instance.

    To reduce costs further I could have installed WordPress and MariaDB community edition (MariaDB is a MySQL compatible database) on the same EC2 instance but this would impact overall performance on my t4g.micro EC2 instance and the overall cost increase for separate webserver and database servers is minimal, especially if you utilise the RDS free tier.

    There are several good reasons to use AWS RDS for MariaDB including nice to haves such as automatic software patching, easy configuration, database snapshots etc. For a non DB admin type like myself RDS is very convenient. I eventually settled on a a single AZ RDS for Maria DB instance running on a db.t3.micro instance.
  • EFS – One of the decisions I made with a nod to future was to utilise EFS (Elastic File Store) to store my WordPress configuration data. This is basically an NFS share if you’re familiar with Unix network storage. I could have used local block storage (EBS) instead but if I scale-out my website later on using auto-scaling (another topic for future discussion) then EBS starts to make things very difficult. With EFS, my ability to migrate to a horizontal server architecture is a trivial task.
  • SSL/TLS certificate management – You can’t have a website without an HTTPS certificate nowadays. Amazon has its own Certificate Management service, Amazon Certificate Manager (ACM). The good news is that you can get an SSL certificate free of charge if you use certain AWS services. CloudFront is one such qualifying service, so free SSL certificates woohoo!
  • DNS Server – Amazons’ DNS service is called Route 53, and it’s actually pretty good. I’ve always used third-party registrars but the AWS pricing for domain registration is pretty competitive at USD9.00/year for a .UK domain. The ease of integration with other services such as Amazon Certificate Manager make using this service a no brainer.

Okay so how much is this going to cost me?

This is a screenshot from AWS Cost Explorer which shows my website cost for the month of June 2021:

AWS Cost Explorer – website cost per day

This includes the AWS free-tier allowances (see below for more information) but as you can see it is pretty consistent at around USD0.50 per day.

Important – I decided to got with a db.t3.micro DB instance to provide a little more scalability/headroom to the database. This is a chargeable instance at USD0.019 per hour (USD0.46 per day). If I had opted to use the RDS free tier and go with a db.t2.micro DB instance then essentially my infrastructure would be free for the first year!

So what do you actually get for free with the AWS Free Tier?

AWS offer a free-tier to new customers for 12 months following your AWS sign-up date. Not everything is free, as you will see from the AWS Pricing section, but it does offer substantial cost savings for companies new to AWS.

With AWS pricing the devil is in the details. Many people are confused when they see their AWS bills, not understanding where certain charges originated from. The takeaway here is to read the pricing sections of the relevant AWS services you will be using carefully.

This section details what free-tier AWS resources are available and utilised within the WordPress environment.

Important – These free tier offers are only available to new AWS customers, and are available for 12 months following your AWS sign-up date. When your 12 month free usage term expires or if your application use exceeds the tiers, you simply pay standard, pay-as-you-go service rates (see each AWS service page on their website for full pricing details).

CloudFormation Free Tier

CloudFormation isn’t on the free-tier, however there is no additional charge for using AWS CloudFormation as long as we use it to create AWS resources (there are some outliers that will are chargeable i.e. custom namespaces but you are very unlikely to use these). In summary, you only pay for the resources created using CloudFormation.

EC2 Free Tier

EC2 instances on the Free Tier are t2.micro and t3.micro. There is also t4g.micro instances which are available under a Free Trial. EC2 Free Tier and Free Trial eligibility can vary depending upon region, you should always check that an instance first before starting to use an EC2 instance.

The easiest way to check an instance type is to look in the AWS EC2 console. In the section “Choose an Instance Type” you will see highlighted under the “Type” column whether an instance is eligible as follows:

This image has an empty alt attribute; its file name is t2micro-freetier.pngThis shows the instance type t2.micro is eligible for the AWS Free Tier
This image has an empty alt attribute; its file name is t4gmicro-freetier.pngThis shows the instance type t4g.micro currently eligible under a Free Trial.
See https://aws.amazon.com/ec2/faqs/#t4g-instances for more details.
EC2 instances free tier eligible

The t4g.micro has been on Free Trial for quite a while now, I’ve seen the end date for this pushed back several times this year already. As of July 2021 the end date for this free-trial is showing as December 2021. I expect it will get pushed back again. As an aside these t4g instances are very performant. They use Amazons custom Graviton2 ARM processors and are definitely worth a look if cost/performance is your thing and your application can support the ARM architecture.

The AWS free tier provides 750 hours per month of Linux, RHEL, SLES or Windows t2.micro or t3.micro EC2 instance. AWS defines 730 hours in a month, (see paragraph below) so this will cover our WordPress server cost for the first 12 months.

Note – See Pricing assumptions and variations for AWS Pricing Calculator – AWS Pricing Calculator assumes 730 hours in a month, (365 days in a year x 24 hours in a day / 12 months in year). The estimated, first twelve month’s total is calculated by ((12 x monthly total cost) + upfront total costs). The Calculator does not account for leap years, which adds one day.

Amazon EBS Free Tier

The AWS Free Tier includes 30GB of Storage, 2 million I/Os, and 1GB of snapshot storage with Amazon Elastic Block Store (EBS). Storage is any combination of General Purpose (SSD) or Magnetic storage. Note that although we are using EFS (see below) we will need a small amount (8GB) of local EBS storage for our EC2 instance for the operating system/boot etc.

Amazon EFS Free Tier

You can use up to 5 GB/month on the EFS Standard storage class for free.

Amazon RDS Free Tier

You get 750 hours of a Amazon RDS Single-AZ db.t2.micro Instance usage – this is enough hours to run a DB Instance continuously each month. you also get:

  • 20 GB of General Purpose (SSD) DB Storage
  • 20 GB of backup storage for your automated database backups and any user-initiated DB Snapshots

Backup storage is free up to 20 GB or the size of your DB storage, whichever is less, and requires you to have at least one DB instance running in your account. If you exceed these limits, or if you terminate all DB instances in your account, backup storage will be charged at standard RDS rates. Currently General Purpose (GP2 SSD) storage pricing for a DB instance deployed in a Single-AZ Zone is $0.133 per GB-month (eu-west-2 region).

AWS S3 Free Tier

Amazons S3 storage is used to store our website assets i.e. WordPress themes, plugins etc. that will be installed when our WordPress infrastructure is created. New AWS customers receive 5GB of Amazon S3 storage in the S3 Standard storage class; 20,000 GET Requests; 2,000 PUT, COPY, POST, or LIST Requests; and 15GB of Data Transfer Out each month for one year.

Amazon Certificate Manager (Free but not Free-Tier)

AWS Certificate Manager is not included within the Free Tier as some ACM services are chargeable, however Public SSL/TLS certificates provisioned through AWS Certificate Manager are free.

Amazon CloudFront Free Tier

The Free Tier for CloudFront provides the following for free per month:

  • 50 GB of data transfer out
  • 2,000,000 HTTP or HTTPS Requests
  • 2,000,000 CloudFront Function Invocations

Amazon CloudWatch Free Tier

CloudWatch is a monitoring and management service for AWS resources. It is a vital tool as it enables you to monitor the website and also provides pro-active tools such as alarms and events in the event issues with our infrastructure (i.e. automated EC2 instance reboot).

Most AWS Services send metrics automatically for free to CloudWatch. Many applications should be able to operate within the free tier limits shown below.

  • Metrics – Basic Monitoring Metrics (at 5-minute frequency). 10 Detailed Monitoring Metrics (at 1-minute frequency). 1 Million API requests (not applicable to GetMetricData and GetMetricWidgetImage)
  • Dashboard – 3 Dashboards for up to 50 metrics per month
  • Alarms – 10 Alarm metrics (high-resolution alarms are chargeable)
  • Logs – 5GB Data (ingestion, archive storage, and data scanned by Logs Insights queries)
  • Events – All events except custom events are included
  • Contributor Insights – 1 Contributor Insights rule per month. The first one million log events that match the rule per month
  • Synthetics – 100 canary runs per month

Amazon Route 53

Amazon Route 53 is not on the free tier, however you don’t have to pay any upfront fees or commit to the number of queries the service answers for your domain. For my website the monthly DNS charges are very minimal.:

  • Managing hosted zones: You pay a monthly charge for each hosted zone managed with Route 53. This is currently $0.50 per hosted zone / month for the first 25 hosted zones (not pro-rated).
  • Serving DNS queries: You incur charges for every DNS query answered by the Amazon Route 53 service, except for queries to Alias A records that are mapped to Elastic Load Balancing instances, CloudFront distributions, AWS Elastic Beanstalk environments, API Gateways, VPC endpoints, or Amazon S3 website buckets, which are provided at no additional charge. Current charges are $0.40 per million queries for the first 1 Billion queries / month.
  • Managing domain names: You pay an annual charge for each domain name registered via or transferred into Route 53.

I also have the recurring annual cost for the domain name. In my case USD9.00 for a .UK domain renewal.

Summary

Starting out with AWS can be very inexpensive. You can build workable and reliable hosting solutions for little to no cost during the first year the free tier is active. For me this solution suits my requirements as I have the expertise to build and maintain my own website.

Okay, so it wont be free forever and you will have to start paying Amazon money at some point, however I will be writing another article to show that if you are careful you can still implement a WordPress website on AWS that compares favourable pricewise to the competition.

If you don’t feel comfortable with building out your own infrastructure then Amazon Lightsail is a good alternative and is also very cost effective.

Thanks for reading, I hope you found this helps you in selecting a suitable architecture for your WordPress environment.

Dean Dunn

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.