Skip to main content

Highly Available Wordpress Deployment on AWS

Highly Available and Scalable Wordpress Installation on AWS

Highly Available and Scalable Wordpress Installation on AWS

The initial version of Wordpress was released in May 2003 and it has been nearly 17 years. Wordpress is still going strong after all these…

Highly Available and Scalable Wordpress Installation on AWS

The initial version of Wordpress was released in May 2003 and it has been nearly 17 years. Wordpress is still going strong after all these years, according to report WordPress powers over 1/3rd of the top 10 million sites. We can safely assume that Wordpress is not going away anytime soon. Many cloud companies are now targeting Wordpress users directly with Wordpress specific hosting. Although that might sounds optimal for the average Wordpress user, these offerings have limitations and shortcomings. Most of them provide poor hardware support and scaling a Wordpress instance can become a really hard task.

We would like to treat Wordpress as a web application that is no different from other web applications that we deploy. That’s why it’s a good practice to focus on horizontally scalability aspect, as well as data integrity and security. We don’t want to lose our data because of a sudden instance failure.

In this tutorial, we are going to deploy a Wordpress installation using different AWS services. We are going to use ECS as a computing layer, Aurora MYSQL as a database layer and ALB(Application Load Balancer) for load balancing. We will use AWS CDK(Cloud Development Kit) to package everything together and deploy via CDK CLI.

All sounds good, let’s start with describing the main stack.

We are getting the necessary information via environment variables. We need to create a VPC first, then a database layer, ECS Cluster with Autoscaling capability and ECS Service at last. Our cluster will scale based on CPU metrics that we are setting here.

We also need to provide the necessary information in .env file.

# .env file
AWS_ACCOUNT_ID=""
AWS_REGION="us-east-1"
DB_USER="admin"
DB_PASSWORD=""
DB_PORT="3306"
DB_NAME="wordpress"

Now let’s deploy the Wordpress installation. For that we have to install dependencies first, then use CDK CLI command to initiate the deployment process.

# Install dependencies
npm install
# Deploy
cdk deploy

After a successful deployment, we should be seeing the Wordpress URL.

Cool, let’s try that URL.

Continue with the setup.

All looks good, you can head over to ECS console and see the running tasks(replicas).

You can use tools like siege to load test the new Wordpress installation. It should scale according to the CPU metric that we’ve set earlier.

EC2 instances in the Autoscaling group will also scale automatically with the increasing load.


After you’ve done with the stack, destroy via CLI.

cdk destroy

The final project can be found here

Popular posts from this blog

Concurrency With Boto3

Concurrency with Boto3 Concurrency with Boto3 Asyncio provides set of tools for concurrent programming in Python. In a very simple sense it does this by having an event loop execute a… Concurrency in Boto3 Asyncio provides a set of tools for concurrent programming in Python . In a very simple sense, it does this by having an event loop execute a collection of tasks, with a key difference being that each task chooses when to yield control back to the event loop. Asyncio is a good fit for IO-bound and high-level structured network code. Boto3 (AWS Python SDK) falls into this category. A lot of existing libraries are not ready to be used with asyncio out of the box. They may block, or depend on concurrency features not available through the module. It’s still possible to use those libraries in an application based on asyncio by using an executor from concurrent.futures to run the code either in a separate thread or a separate process. The run_in_executor() method of the event...

AWS Lambda Function URLs

AWS Lambda Function URLs AWS Lambda Function URLs AWS Lambda is a Serverless computing service offered by Amazon Web Services (AWS) that allows developers to run code without provisioning… AWS Lambda Function URLs AWS Lambda AWS Lambda is a Serverless computing service offered by Amazon Web Services ( AWS ) that allows developers to run code without provisioning or managing servers. In this tutorial, we will explore AWS Lambda Function URLs , which are the endpoints that allow you to invoke your Lambda functions. AWS Lambda Function URLs are unique HTTP endpoints that you can create using AWS Console, SDK or any other IaC tool. These URLs are used to trigger your Lambda function, and they can be integrated with a variety of workloads. Function URLs are dual stack-enabled, supporting IPv4 and IPv6. After you configure a function URL for your function, you can invoke your function through its HTTP(S) endpoint via a web browser, curl, Postman, or any HTTP client. Once you create ...

DNS Failover with Route53

DNS Failover with Route53 DNS Failover with Route53 Route 53‘s DNS Failover feature gives you the power to monitor your website and automatically route your visitors to a backup site if it… DNS Failover with Route53 Route 53 ‘s DNS Failover feature gives you the power to monitor your website and automatically route your visitors to a backup site if the main target is not healthy. To showcase this feature, we are going to deploy an application, which we built in this blog post , to two different AWS regions. We are also going to set active-passive failover in Route53, then we will remove the application from one region and we’ll observe how DNS queries will react to the changes. AWS describes the failover scenarios in 3 different categories Active-passive : Route 53 actively returns a primary resource. In case of failure, Route 53 returns the backup resource. Configured using a failover policy. Active-active : Route 53 actively returns more than one resource. In case of failure...