It would be nice if you could run WordPress without a server, right? Even better if it is a scalable solution?
There are many ways to skin a cat! No, I do not harm cats, ha ha 🙂
Likewise, there are many ways to run WordPress without a server. There is no one best way. Docker containers, container orchestration solutions like Kubernetes and Amazon Web Services ECS Fargate are considered great methods because they are scalable and secure.
My favorite method is to run WordPress Docker containers on AWS’ proprietary platform called ECS Fargate.
A few more details…
The number of containers and the amount of vCPU and Memory available to the containers can be adjusted in ECS. The containers share files which are stored in AWS EFS. I used Aurora Serverless MySQL DB for the database. This can also be scaled up / down! I also used a custom VPC with 2 public subnets and a bastion host for mounting the file system or querying / backing up the database.
This is the first time that I succeeded in running WordPress without a server that can automatically scale in and out. I am really excited to share this with you guys!
Why is WordPress without a server this interesting?
Packaging apps into containers seems to be the trend these days. Docker containers have become the standard way of deploying applications, and for good reason! Containers run in the same way in all environments.
With normal server deployments, developers used to say, “But this works on my PC! How come it does not work in staging?”
Virtual Machines came into existence, but they needed a lot of resources to run. Also, it was not easy to distribute those huge images (Virtual Appliances) over the Internet…
Then Docker came along, where the OS kernel (Linux) is shared among all containers, but the processes of the containers are isolated from each other by default. After all, a container is a single process isolated from other containers and the host system.
This led to the Microservice architecture in app development. An app can consist of multiple containers that each perform a specific task.
Necessity is the mother of Invention, right? There was a pressing need to scale container based apps to meet the demand and to distribute incoming client requests. This led to the development of container management solutions like Kubernetes and AWS ECS. Please note that AWS ECS is a proprietary solution, while Kubernetes is open source.
With ECS, we can scale containers according to the load. There are 2 types of ECS deployments – EC2 and Serverless (Fargate). In the EC2 mode, EC2 instances are started by ECS to serve as the container host OS. Fargate is a proprietary platform that does not involve server instances, but is managed by AWS. It is a PaaS (Platform as a service) – a platform on top of which Tasks are run.
First, you ned to create a “Task Definition”. It is a JSON file that describes how your containers should be run. A Task definition supports upto 10 containers. We need not create the JSON from scratch; the AWS console does that for us.
Next, you create a new Cluster. Clusters contain Services and Services contain Tasks. A Service is used to define how Tasks should be run and also handles auto scaling of Tasks to meet the demand. You may also run a single task without creating a Service.
Thus ECS Fargate is interesting as it is Serverless and can scale up or down according to the demand.
There will be a series of articles on running WordPress without a server and the detailed process of deploying it…
What do you think about Serverless WordPress? Let me know in the comments!