Did you know that there is a single fact that hugely influences the performance of your WordPress website?
When searching for fast WordPress performance, you may end up with articles offering up to 20 or 30 pieces of good advice. Factors such as using certain plugins, running a lean WordPress website, using caching and modern software. But often, there is an important factor left out for fast WordPress performance – even by hosting companies.
And that’s the fact that WordPress performance is hugely influenced by the CPU. The CPU of the server WordPress is running on. It’s mainly because WordPress is single-threaded and uses PHP and MySQL . And what does that mean? We’ll discover this in this article.
WordPress is Single-Threaded
WordPress, like a lot of software, is single-threaded. This means that one process can execute at a time, and the instructions in a process execute in a linear fashion. One at a time.
And as you may know, if you host a WordPress website on a server, it actually runs on a computer that is connected to the internet (which is basically the definition of a server). And that server has a certain amount of memory, a certain CPU and a certain amount of storage.
A CPU can have one or more cores, and each of these cores run with a certain clock speed – usually indicated with Mhz or GHz. Usually, the higher the clock speed, the faster the processer can process instructions.
And as you may also know, WordPress uses MySQL to store its data, and PHP to process pages. Each process by MySQL or PHP is attached to a single core of the server. Once a core finished a given process, it can move on to the next process.
Let’s say you are loading a simple WordPress post to edit. Even for such a case, multiple processes are taking place.
- WordPress needs to get the post from the database
- Subsequently, any post meta information needs to be loaded from the database.
- The page also needs to be generated.
If your server just has one core, all of these processes take place subsequently. Now, if you for example open up multiple tabs for editing a post, the website has to wait before the processor finishes the earlier load.
And that’s why if you open multiple tabs for editing a post at once, they may all load slower. With multiple cores, it can however distribute each of these processes to another core and it may run faster. But again, each core can only take one process at a time – this process can not be cut into pieces and spread over multiple cores.
Fast CPUs, Fast Memory, Fast WordPress Performance
In essence, this means that the faster your core is, the faster it can process the instructions. The bottleneck is the clock speed of your CPU. The processes will only finish as soon as the CPU completed them, and the faster the clock speed is, the faster it will complete it.
For example, the faster the CPU clock, the faster your WordPress back-end will load each time you navigate to an admin page or do an action in your backend.
However, with multiple cores, you can run multiple (different) processes at the same time. This basically means that the server can handle more users at the same time – or more processes running simultaneously. And allow you to open more edit post tabs at once.
Oh, and for MySQL, it helps a lot if you have fast memory as well.
Let’s Do Some BenchMarking
I have created a benchmark plugin (it’s here on Github as well) that I use for testing hosting companies. This plugin inserts queries and deletes a number of posts and records the time for each action. It’s a great test for the CPU and memory performance of your server. In addition, I am doing a load testing benchmark, simulating a certain amount of users visiting the website.
I did this benchmark on a very fast server from Webdock, which is a great server provider.
Inserting Posts: A Single-Threaded Benchmark
In the below image, I ran a test twice. The first test was on a server with just one CPU core, and in the second test, I scaled the server to two cores.
As you can see, there is hardly a difference.
10000 posts | One Core | Two Cores |
Inserting | 7.13 seconds | 7.373 seconds |
Querying | 0.098 seconds | 0.096 seconds |
Deleting | 13,591 seconds | 13,788 seconds |
This clearly demonstrates what it means for WordPress to be single-threaded. The benchmarking process can just be handled by one CPU core at a time, and this it will run as fast as the core is.
Multiple Users: The influence of Multiple Cores
However, when do you need multiple cores then? The most common case is that the more cores you have, the more (uncached) users or visitors your website can handle.
I did a simple benchmark using h2load which tests the requests per second, and these are the results:
One Core | Two Cores |
25.84 requests per second | 45.32 requests per second |
As you can see, the processes that are initiated by multiple users can usually be distributed over the cores. In the benchmark, this is clearly demonstrated.
In this test, I am simulating 10 users, and firing 100 requests. The test will show how many requests per second the server can handle. The faster your CPU clock speed is, the higher this number will be. But this number will also scale if you have more cores.
A Great CPU, A Fast WordPress Site
So if you are looking for a great WordPress hosting provider, also check if they are using fast CPUs. Not only the amount of cores count but also the clock speed.
And if you like to manage your servers on your own, check out the offerings from Webdock, Upcloud or Vultr High Frequency. These parties all offer fast cores. Great CPUs for a Fast WordPress performance!