Skip to Content

Creating a Scalable WordPress Deployment on AWS

Posted on October 28, 2022 by

Categories: AWS


Your website’s visitors will rise as your company expands, placing more strain on the WordPress hosting environment. Your WordPress website will lag, your visitors’ experience will deteriorate, and they will go in search of another website if you don’t scale the hosting infrastructure for the increased traffic.

Once you know exactly how you want to expand your WordPress site, cloud computing services like Amazon Web Services (AWS) make it simple and affordable to do so. In this post, we’ll go through two popular methods for growing a WordPress site on AWS and offer advice on making your AWS infrastructure more effective for hosting WordPress.

Scaling your website entails adjusting the hosting infrastructure to handle increased traffic needs as your clientele and organisation expand.

To increase the amount of processing power available to your site, vertical scaling in AWS refers to modifying the size of your Elastic Compute Cloud (EC2) instance(s). Simply changing your current EC2 instance for one with more memory or virtual CPUs, or swapping your Relational Database Service (RDS) instance for one with a larger instance size, is generally the first move done by budding WordPress administrators. You could eventually exceed the maximum size that one EC2 or RDS instance can expand, though.

In AWS, adding more resources refers to adding more EC2 instances to serve web pages and/or more RDS (database) instances to host data, for example. To divide traffic among many EC2 instances, you’ll need a load balancer like AWS Elastic Load Balancing. If your single instance’s vertical scaling capabilities have been exhausted or you need to be able to upgrade your infrastructure without experiencing any downtime, this form of scaling might be helpful.

It’s difficult to foresee when your WordPress site could suffer an unexpected spike in traffic. Therefore it makes sense to be ready to scale your site by ensuring that your architecture is built to extend horizontally as necessary.

Waiting until your site becomes sluggish will require you to make hasty architectural adjustments; instead, you should take proactive measures to improve your design today so that scaling will be simple. This post will demonstrate how to implement these preventative measures and go one step further by configuring your WordPress infrastructure to automatically scale to handle traffic peaks.

If you haven’t already, import your WordPress site into AWS to ensure that your site can be easily scaled. AWS offers a variety of tools that let you expand horizontally and vertically. The most straightforward configuration is hostingg the complete website—including the database—inside a single EC2 serven. To accomplish this, create an EC2 instance using an Amazon Machine Image for WordPress (AMI). This serves as a template to automatically pre-populate your instance with a blank WordPress site.

Then, export your WordPress website as a file using the All-in-One WP Migration plugin, and import it into your new instance. This plugin is robust and functions well with established WordPress setups that call for the importation of both themes and plugins.

You should now modify your infrastructure so that you are employing a multi-tier design to best support your site’s horizontal scaling. This entails separating your WordPress site’s code, database, and storage parts and storing them on separate, purpose-built hosting infrastructure. By creating a blank MySQL database in RDS and then importing the WordPress database tables into it, your database may be hosted in an RDS server.

An S3 bucket, a quick and inexpensive way to store a lot of data, may be used to host website assets, including scripts, stylesheets, photos, and other media. The WP Offload Media Lite plugin may be used to connect to the S3 bucket from your WordPress website. Your EC2 instance will continue to serve the remaining portions of your WordPress website.

Now that your site has a multi-tier design, you may grow it horizontally by adding and deleting EC2 instances or databases as needed. You must deploy the same code to every EC2 instance before registering them with a load balancer to load balance multiple EC2 instances. You may use a service like AWS Elastic Beanstalk to assist you in deploying code to several instances.

You can choose to create additional RDS instances to horizontally expand your database to handle high quantities of database requests. Installing the HyperDB WordPress plugin, which enables simultaneous connections to several databases on your WordPress website, is required.

By choosing “Create read replica” from the Actions menu after selecting your database instance in RDS, you may make read replicas (read-only copies) of your database. The possibility of database write conflicts is eliminated by having read replicas, which let many database servers execute queries to your database while restricting write operations to the primary database.

RDS deals with all the asynchronous replication to keep the read replicas up to date with the primary database. The current RDS restriction is five read replicates. If you need to scale to higher numbers of read replicas, you can instead use Amazon Aurora, which allows you to scale to up to 15 read replicas.