Is your WordPress website scalable? There are many examples of large-scale WordPress installations in the wild. WordPress.com for instance is a huge multisite installation that gets tens of millions of pageviews each month. It also serves thousands of users at any given moment.
Other examples include Time, TechCrunch, and CNN. There’s no doubt about it. You can definitely build a scalable website with WordPress that is powerful enough to handle any amount of traffic, as long as you create the right environment. Configuring your installation to scale can be complex, but it is a worthwhile investment for any site owner. In this post, we go over a few areas that you can focus on to ensure scalability, and offer tips on how to set up a scalable environment.
What Do We Mean by Scalable?
What makes a WordPress website scalable? A scalable WordPress website has the ability to increase capacity by scaling up or scaling out.
- Scale up – increase the power of the hardware (more RAM, a more powerful CPU).
- Scale out – increase the capacity by adding more nodes (having identical copies of your site distributed among multiple machines).
Doing so gives you the flexibility to accommodate growth. Basically, you want to be able to extend your site without any problems. With WordPress, you won’t have to worry about the software. The WordPress core implements layered software architecture conventions, like separating markup (HTML and CSS) from data (MySQL database). Below we will explore some ways that you can ensure maximum scalability.
Development Environment
One of the hardest parts of scaling a WordPress site is setting up a development environment. A good development environment will mirror the production environment without any problems. If you have a small site, you can get away with developing live, although it definitely won’t scale.
You will need some sort of version control to make sure that the developers don’t step on each other’s toes. Version control software records changes to you files over time so that they can be recalled later. Plus it’s a much more efficient, professional way to develop a scalable WordPress website.
There are many elegant solutions available thanks to the hard work of the open source community. Git is a distributed version control software that allows multiple developers to work remotely on separate repositories. It is reliable, fast, and able to handle incredibly large projects. After all, Git was created by Linus Torvalds for Linux development.
You can build a killer development environment with VVV (Varying Vagrant Vagrants). This free open source software is ideal for creating distributed development environments with WordPress. Check out our The Ultimate Guide to Setting Up Your WordPress Development Environment for an in depth tutorial on this. WordPress.org also has a helpful tutorial on Installing VVV.
Horizontal Scalability
Scaling out, or horizontal scaling, is one of the most important concepts of creating a scalable environment. This allows you run your website on many different machines (servers). Some people call the infrastructure “elastic architecture” – because the amount of resources you have can expand or diminish based on how much is needed.
This is done through cloud computing methods such as clustering, load balancing, and virtualization. In computer science, clustering is the process of organizing similar objects into groups. So, a single cluster will contain your website’s files, database, and software. Clustering ensures that your website has high availability by eliminating problems due to hardware and software failure. How does it work?
If your site gets a spike in traffic, a load balancer will determine how to appropriately allocate more resources to pick up the slack by scaling out – this happens dynamically, and your visitors never notice a thing. The idea is that you have identical copies of your website distributed among multiple machines, and they all know about each other. So there is always a computer in the cluster on standby if there is an increase in traffic or a component of the stack fails.
Cloud hosting providers like Amazon Web Services (AWS) or Cloudways are two popular cloud hosting providers that enable horizontal scalability. Check out this tutorial on Deploying a Highly Available WordPress Website with AWS for an example of a typical server infastructure with elastic architecture.
Caching
A cache is a temporary storage space for memory. Caching can help you deliver content faster, and avoid problems with concurrency. Every CMS needs some sort of caching, WordPress is no different. The bad news is that caching can be ridiculously complex. The good news is that the open source community has come up with many different solutions on the matter. There are plenty of tools to help you, including WP Super Cache, and Batcache.
Reverse Proxy Caching (Page Caching)
Reverse proxy caching is an efficient way to load dynamic web pages. The reverse proxy is a service that acts as the middleman between WordPress and the browser. This can help reduce the load on your main server and decrease perceived page loading time.
The problem is that PHP servers are resource heavy. They execute a large number of complex tasks, which can bog down your server. You can lighten the load on your server by implementing a reverse proxy.
For example, say you get a visitor on the home page of your website. It is the first visit of the day. At this point, there is no cached version of the home page yet.
- User enters URL in address bar, requesting a page from the server.
- The request passes through the proxy, which doesn’t have a cached version of the page yet, to WordPress.
- WordPress generates the homepage, and serves the response back to the reverse proxy.
- The proxy then sends the response to the browser, and it saves a cached copy of that page.
- As long as the cache is there, any user requesting that page will receive the cached version of the page.
Object Caching
The concept behind object caching is similar to page caching, except it works on individual objects. Many concurrency issues can pop up when there are lots of users logged into your site. Object caching saves an application object (such a video, image, document) in a data store. By caching application objects, you are less dependent on the database, freeing up lots of memory.
There are many options for caching. Content delivery networks like Cloudflare, Akamai, EdgeCast and KeyCDN can act as massive reverse proxies. Varnish and WP Super Cache are two popular options to implement caching with WordPress.
Query Performance
The database can often be the cause of the worst bottlenecks. Slow queries can tie up the PHP application on your server, and bring all activity to a standstill – even if you have an elastic architecture. As I mentioned before, PHP servers can slow down the server signifigantly. If caching isn’t getting the job done, you can find ways to improve your query performance by identifying slow queries.
Slow queries are due to problems with the SQL database, the network running your site, or the server. There are a variety of reasons why this can happen. There is definitely no one-size fixts all. The first step to improving query performance is identifying slow queries.
Once you identify the problem, you can take action. Sometimes the answer can be as simple as buying more bandwidth, other times you may need tweak the code, which can get tricky.
Check out the WordPress Query Monitor plugin if you are looking for a tool to monitor queries.
Improving Search
If you have a large amount of posts, say 1 million, you will have to be mindful of how your databases are setup. Most larger sites have an optimized search index. Which is a custom search engine added to WordPress.
The content search query in WordPress doesn’t work well if you have a large number of posts on your site. It also leaves something to be desired in terms of speed. A common fix for this problem is to create a dedicated search index. Doing this keeps those queries out of the database, giving users a better browsing experience, as well as increasing the performance of your database.
Popular search engines for large-scale WordPress sites include ElasticSearch and ApacheSolr.
Wrapping Up
Starting at the right scale is also important. Start simple, then optimize later. To quote Donald Knuth, “premature optimization is the root of all evil.” Accommodate for growth, but don’t try to squeeze a huge ecommerce site on a tiny foundation or vise versa. You may not need to build a scalable site if it’s for something simple like an event page.
Typically, elastic architecture is the standard for eCommerce websites. While some of this stuff can seem incredibly complex, you don’t really need to understand it all. As long as you have a grasp of the basics, you can build a robust environment for a large-scale site. All you need to do is find the right cloud services, and hook yourself up with the right CDN.
Feel free to share your experiences in the comments section. What steps did you take to make your WordPress website scalable?
Article thumbnail image by turbodesign / shutterstock.com
Seems simple, but guaranteed many businesses don’t build their website with this in mind. Should be part of the initial build list.
Thanks for the reminders.
One feature I love about WordPress is I was able to migrate all content from Joomla, it was hassle free, though there’s some broken links issue.
I will apply your steps to my site.
Many things must improve.
Thank you for your useful article.
Something to keep in mind. Thanks
My website is not scalable. I must do that. Thank you for the information.
Different kind of considerations is needed to build a scalable website with WordPress. Typically here is the easy way you discuss to improve the build quality of the website not only in the sense of an increase the traffic but also handle this without any failure. Thanks for the interesting article to share with us.
Good article. We have found most share hosting accounts can run slow even with the likes of SuperCache installed. Keeping the number of plugins to a minimum is crital and you can check on the number of requests made by analysing your site with a service such as GTMetrix.
What I would love to see from Elegant themes is optimizations within the Divi theme. A great number of premium themes (envato) have development/production settings which combine/compress/minify the themes js and css files.
I usually run the divi/style.css through a minifier tool and save almost 90kb in file size! Each theme update resets my hard efforts and I end up having to upload this file over and over.
I second this!
As a non-developer site owner (one man show), I spend hours trying to get my site go faster – time that would be better spent writing or updating the site.
If Divi could be updated to deal with some of the most important issues highlighted by Google (and other) site speed test tools, then it would save me and I’m sure many others, from a big headache!
This is a great topic. Have their been any articles on scaling the administration interface for content, or how do the mentioned big sites manage their content with the WordPress admin interface.
Thanks for posting this, Brenda. This is actually a huge issue for us as our many WordPress sites have grown busier, much more sophisticated over time — and web hosting companies continually fail to upgrade, limit performance on “unlimited” accounts, lessen their customer service, and raise their prices.
Actually, as we’ve researched various solutions, I tried using the Uniform Server, a WAMP install (WordPress + Apache web server + MySQL + PHP) for Windows, which is secure by default (most WAMP installs are made for staging servers and are not secure). It is free. It’s very easy to install and configure, and free dynamic DNS services are readily available. Google treats our site well, and we have regular traffic on a site whose performance requirements would drive our shared-hosting company to its knees. Unfortunately, it isn’t very stable and requires multiple restarts per day.
Also, we recently realized, with no fanfare, our local ISP (CenturyLink) has switched to a fiber-only policy and now offers gigabit service to everyone. Our modest 40 Mbps service works fine for our server, though.
Meanwhile, like all of us, my 4- and 8-core PCs mostly sit idle all day/night.
So, I wanted to suggest that Elegant Themes develop its own WAMP solution for paid subscribers, for use as a production or staging server. It could help WordPress publishing reach the next level with “free.”
Right now, the weak link is the cost and performance of hosting. You could change that.
It doesn’t look like the various WAMP developers right now have any real vision for the future. Surely, eventually, someone will. I hope it will be you.
Insightful and informative.
Thanks
Good topic, a lot of websites from previous years has gained in visitors, posts, media etc.
Caching as first step, after that some CDN.
Multiple domains as last probably.
Post is good but its very complex topic, maybe some tutorial about how to server media from another domain would be good.