< AWON Blog

How AWS’s serverless database helps WordPress to scale infinitely

Aakash @ June 4, 2022

How AWS’s serverless database helps WordPress to scale infinitely

As the name serverless database sounds, you are thinking it right. It means a database that scales with your needs.

AWS Serverless Database

One line introduction is not enough if you are seeing the serverless database term first time or not actually sure how it works. Let me try to make it simple.

Traditionally databases run on instances/virtual machines or some kind of dedicated physical servers. Their capacity configuration was pre-set at the time of database creation. Generally capacity in terms of CPU/vCPU and storage. This capacity determines how much database can scale or how many database connection can be accepted at a time to keep the website performance at the accepted level.

Serverless database runs on virtual machines but unlike traditional databases, its compute part and storage parts are separated. This is an advantage because now both part can be scaled independently.

Generally, more compute power is required if there are more users on your website or database is under stress. Storage is often not the issue.

With the serverless database compute can scale from one capacity point to another if it comes under the load. In AWS, it takes may be 30 seconds to 1 minute, but it happens in the background. As soon as new instance with higher capacity is available and ready to take the connections, you will have database that works with increased load on your website.

AWS serverless database v1 have capacity scaling settings are something like the following image.

Aurora serverless database works on Aurora Capacity Units (ACUs). This are in range from 1 to 256. We can set minimum and maximum range when we create the serverless database cluster. Important thing to notice here is the Autoscaling timeout. This is the time after if there is no database load then it start scaling back.

So for example, we started the database with 1 ACU, and then under the load, it may reach 10 ACU. But now if there is no load or very less load on the database then it starts scaling back towards the minimum required ACU setting.

Understand ACUs performance

This part is better explain here in the post so give you the rough estimates how might it work for your workload.

WordPress with serverless database

When you host your website on AWS, you can take advantage of Aurora serverless database. For simple WordPress websites I would not recommend more than 2 ACUs. Also if you are using CDN service such as CloudFront or Cloudflare, your database server will not get that much load anyway.

If you are hosting a large eCommerce store where your traffic pattern is really unpredictable, and most importantly you don’t want to lose any sales because simply your website cant cope with a number of transactions. Then I would recommend setting max ACUs to 4 or 8. Again CDN generally plays a major role in keeping the database load down. If you reach 8 ACU levels while using CDN, then probably your CDN settings are not correct or probably there is some issue with your website!

Real world WordPress load test

While its hard to make the database scale from my side as I have to generate enough load to trigger the scaling event. I gave a few tries to do the setup right. I ran a few tests probably around 10, but I will focus on only 2 important tests here.

Things to focus on here is for the serverless database are:

  • Database connections
  • ACUs
  • CPU utilization

Scaling test 1

Before test condition of the serverless database was like the following.

Basically, CPU utilization was well below 20, almost no database connections, and ACU was 1 as it was set to run on a minimum 1 Aurora capacity unit.

After running the test with the 192.43 requests per second with average bandwidth 4.27kb for 10 minutes

I was failed to make serverless database scale. Following were the result.

So I tried to increase the load with the second test.

Scaling test 2

Again, before the test condition of the database was like the following.

Similarly this time as well, CPU utilization was well below 20, 0 database connection, and database was running at 1 ACU.

I did the second test with the 617.69 requests per second with average bandwidth of 2.2kb for 15 minutes

This time it did work and I managed to create the load enough for the database to scale.

Following were the details after the test.

After test 2, you can see that database was scaled to 2 ACU, and the database connection was climbed to around 100. However, there weren’t many noticeable changes on the CPU utilization side. It may be because the database was scaled to a larger instance so average CPU utilization remained the same.

Autoscaling event of the AWS serverless database

The above tests shows how AWS’s serverless database works in the real world.

Once again, if your website is a large eCommerce store or running some sort of campaign when you are expecting a good amount of traffic, a serverless database gives you peace of mind from the back-end side scaling when you really have to deal with the database queries.

Founder of AWON

AWS Solution Architect and WordPress Developer.


You may like following posts too...

Why my WordPress website is slow?

Your WordPress website can be slow for many reasons. The most common reasons could be one or a combination of a few of the following: Your WordPress Webhosting environment Plugin conflicts or circular dependencies Too many plugins Unoptimized theme Blocking third-party dependencies Unoptimized custom code Unoptimized images No CDN Lets check all of above in […]

3 simple steps to create WordPress headless website

This article assumes that you already have a WordPress website and you would like to use it as a headless content management system (CMS). What is headless WordPress Headless WordPress simply means that back-end of the site remains separated with front-end. Backend of the WordPress manages the data and front-end simple queries it and display […]

Subscribe for updates

Deploy your WordPress to the cloud.