*In this post I will attempt describe how you can prepare your WordPress site so that it can be scaled.
WordPress is generally not scalable
The usual deployment scenario is to have the database, core files, user files and web server, all on the same server.
In this scenario, the only scaling that can be performed, is to keep adding memory and power to a single server (vertical scaling).
Scaling Options
‘Scaling vertically’, which is also called ‘scaling up’, usually requires downtime while new resources are being added and encounter hardware limits. When Amazon RDS customers need to scale vertically, for example, they can switch from a smaller to a bigger machine, but Amazon’s largest RDS instance has only 68 GB of memory.
‘Scaling horizontally’ means that you add scale by adding more machines to your pool of resources. With horizontal scaling it is often easier to scale dynamically by adding more machines into the existing pool.
Horizontal Scaling For WordPress
To enable horizontal scaling for WordPress we need to first decouple the various parts from each other (web server, files and database). Once decoupled, we can place each part on separate servers and scale them as necessary.
Decouple Before Scaling
Decoupling the database is ‘easy’. You can easily move your WordPress database to its own server by taking a backup and migrating (guess what, there’s a plugin for that). Once moved, you just need to change the ‘DB_HOST’ value in your wp-config file.
Decoupling the web server from the files (WordPress core files and media library files) is more complicated. From what I can gather there are 2 options for doing this:
- Host only your library files on a remote cloud server. This article explains how to achieve this.
- Host both your core files and library files on a mounted volume linked to a remote cloud server. This article explains how to link your uploads folder to cloud storage, but you equally link your entire WordPress folder.
I prefer option 2 because:
- Option 1 keeps your core files coupled to the web server.
- It also only caters for new uploads, not existing files too.
- In addition, it involves rewriting the url links for your files.
- Option 2 keeps your url links the same so you revert back or change cloud provider easier.
However option 2 is way more complicated to set up. In my next post I will show how Docker can help with this process.
Decoupling complete, now scale!
You can now scale your WordPress site.
In the next post I will show how to use Docker, in particular Docker Cloud, to make this process painless.