Identify how much different CPU models, affect WordPress website backend performance and find which DigitalOcean droplet is the most feasible

How much different CPU models affect WordPress performance Identify how much different CPU models, affect WordPress website backend performance and find which DigitalOcean droplet is the most feasible

A Standard $20 DigitalOcean droplet will give you a better PHP performance in average than a $640 DigitalOcean droplet. Best DigitalOcean CPU droplet gives us 63.88% better results than low budget CPU. But at the same time, the same high CPU model is 588.33% more expensive.

Introduction

Goals

To identify how much, different CPU models , affect WordPress website backend performance. (Thus, there is no use of cache in any part of architecture).

, affect WordPress website backend performance. (Thus, there is no use of cache in any part of architecture). To find which DigitalOcean droplet is the most feasible for WordPress websites

What exactly we tested? The following picture will explain the best:

What has not been tested?

This research did not focus

on load testing

on WordPress profiling results

on front-end performance

Abbreviation and Terminology

WBT - WordPress Backend time - time which PHP take to process website scripts

CPU time - time PHP spent in CPU

TTFB - time to first byte

Stan * - standard droplet (stan5, stan10, stan 20, ..)

Mem * - high memory droplet (mem120, mem240, ...)

CPU * - high CPU droplet (cpu40, cpu80, ...)

Test environment

Typical LEMP environment is used, without any caching whatsoever (Opcache disabled, no MySQL cache, no WordPress cache plugins).

Wordpress

Three different WordPress installations are used. All websites used WordPress 4.8.2.

Plain WordPress installation

Default WordPress installation.

1 post published

0 plugins installed

Twenty Seventeen theme

18 MySQL queries

Uses ~15MB of RAM memory during runtime

11.919 PHP function calls

Magazine WordPress installation

Real-world magazine setup.

~3k posts published

21 active plugins

Herald Magazine Theme

311 MySQL queries

Uses ~45MB of RAM memory during runtime

395.136 PHP function calls

WooCommerce Demo Shop

WordPress with WooCommerce plugin and Avada theme with modern shop demo presets.

~10k products published

50 blog posts published

15 active plugins

Avada Theme v5.1.6 (Modern Shop Demo imported)

Uses ~55MB of RAM memory during runtime

435.626 PHP function calls

VPS

DigitalOcean is used as cloud provider where tests and benchmarks are performed. All droplets are created with LEMP one-click app, in Frankfurt zone.

Important: Standard $5 droplet is not in results because was not possible to even conduct installation and test of WordPress websites due to lack of RAM.

PHP Version 7.1 (latest)

MySQL v5.7.19

Ubuntu 16.04.3 LTS 64 bits (kernel: 4.4.0-93-generic)

Nginx v1.10.3

Benchmark and test tools

Methodology

After droplet was created, bash script was executed on droplets which resulted in the creation of three different subdomains and deployment of three WordPress installations.

On successful deployment, following tools are used for testing and benchmark.

Blackfire

This great profiling tool for PHP applications is used to get the CPU processing time, CPU IO wait time, a number of PHP calls and MySQL Query time.

Blackfire agent was executed on all three versions of the WordPress website using the curl sub-command.

Benchmark-PHP

PHP script is used to perform the benchmark of following functions on VPS instance:

Math functions (abs, acos, asin, atan, bindec, floor, exp, sin, tan, pi, is_finite, is_nan, sqrt)

String functions (addslashes, chunk_split, metaphone, strip_tags, md5, sha1, strtoupper, strtolower, strrev, strlen, soundex, ord)

Loops (for and whiles)

If Else (if, elseif)

MySQL (mysqli_connect, SELECT BENCHMARK(1000000,ENCODE('hello',RAND())))

Filesystem (writing and reading 700kB file)

Whinfo.sh

This bash script was used to get information about VPS: CPU, RAM, disk, network test, bogomips and disk inkling speed. More info about this script is available on Github.

CURL

Custom script is written which performs HTTP request using CURL command on websites. Each of the websites is tested 100 times with a delay of 1 second. CURLINFO_PRETRANSFER_TIME and CURLINFO_STARTTRANSFER_TIME timings are used to calculate the application level processing time.

From the results of 100 testing cycles, the average, minimum and maximum application processing times are calculated.

Results

Backend loading time on different droplets

First, let us show how fast different WordPress websites are processed on all DigitalOcean droplets. The times presented in the following charts are WordPress backend times.





So, what do we see here? First, we notice that there is a small speed up on the Standard 20 droplet. After that, nothing significant happens until we reach the Standard 420 droplet. Then, at CPU 40, we see a significant increase in speed which slows down again afterward on memory droplets.

Also, it can be noticed that plain WordPress charts are flatter when magazine and shop websites have more spikes, especially at the maximum time.

In addition, high CPU droplets have narrower space between a maximum and minimum time. That's are benefits of dedicated vCPU.

CPU Processing Time vs CPU IO Wait Time vs MySQL Query Time

Let’s take a look at the CPU level and see what really happens here.







Now, things seem to be much clearer. From the above, it seems that:

CPU IO Wait Time doesn’t change significantly over droplets.

Also, MySQL query time doesn’t change significantly over droplets.

CPU time is the only timing that significantly changes – this is the time needed for PHP function calls to be processed in CPU

– this is the time needed for PHP function calls to be processed in CPU Finally, the points where significant changes occurred are droplets with different CPUs .

How CPUs really affect PHP applications

Now, we know where to take the next step. Let’s compare average CPU and CPU IO wait times between different CPU models. Below are all the CPU models which DigitalOcean has across droplets:

Below are the results of CPU timings of different websites on CPU models.

The next chart shows the CPU IO wait time for different websites on CPU models.



Now, let’s take a look at the average total backend times of different websites on CPU models:





What conclusions can be made at this point? This question is no brainer; faster CPU gives better results.

However, we would like to be more specific.

better CPU gives significantly better results with real-world WordPress websites

the more the total PHP function calls a website has, the greater the increase or decrease we have on different CPU models.

To support the above, let’s take a look.

What does the chart above show? We predicted an increase in CPU time with an increase in the number of PHP function calls in CPU, but the chart doesn’t entirely show that. We see an increase in the number of PHP function calls between magazine and shop websites, but this is accompanied by a decrease in CPU time needed to process that amount of function calls.

Obviously, it’s all about how expensive the functions called are. Let’s get the results of benchmarks of some PHP functions.





From the above, things seem to be much clearer:

string functions are much more expensive than math functions (logically)

If else blocks are more expensive than loops

In our case, either the magazine website uses more expensive functions or it uses it more often. As a result, the magazine website had much more benefits from running on better CPU than just on a plain WordPress website.

Let’s add one lower budget CPU and compare the Magazine website on all four CPU models.

Best DigitalOcean droplet gives us 63.88% better results than low budget CPU. But at the same time, the same high CPU model is 588.33% more expensive.

This explains why you can’t have fast WordPress websites when hosting with a cheap CPU.

Number of Cores Vs Performance

As we see on the chart above, the number of cores does not have any significant impact on WordPress performance. More cores will only help you handling high traffic.

WordPress performance vs VPS hardware and cost

Here, one big question pops out. Which VPS configuration is the most feasible for a WordPress website?

In our example, let’s put droplets’ prices in correlation with strings’ benchmark results.



For WordPress websites which are struggling with bad performance, the High CPU $40 droplet is the best option. If you have a good performance, the Standard $20 droplet will serve you just fine.

If you have a problem with high traffic - scale horizontally - add Load Balancer and more nodes.

Conclusions

Here is a summary of our conclusions.

PHP depends on CPU processing power meaning if you need better performance, it is important that you pick a CPU model that has a better official benchmark score – CPU matters.

meaning if you need better performance, it is important that you pick a CPU model that has a better official benchmark score – CPU matters. The number of CPU cores doesn’t affect the performance of PHP applications - PHP is not multi-threaded. The number of CPU cores will only help you handle a higher traffic.

- PHP is not multi-threaded. The number of CPU cores will only help you handle a higher traffic. PHP string functions are more expensive than math functions.

than math functions. VPS instances with a larger amount of RAM memory have little or no impact on PHP performance .

. The best decision will be to use a few high CPU VPS instances with a load balancer, with a separate instance for MySQL DB

A Standard $20 DigitalOcean droplet will give you a better PHP performance in average than a $640 DigitalOcean droplet.

A High CPU $40 DigitalOcean droplet will give you the best PHP performance among DigitalOcean droplets.

Dedicated vCPU give us more stable performance - no large loading time spikes

- no large loading time spikes Bad programmers are too expensive.

What does this research mean for WordPress website owners?

If your website suffers bad backend performance, first, try to hire an experienced backend PHP developer to optimize your code. In the case of a WordPress website, try using some WordPress cache plugin and optimize your LEMP/LAMP configuration. (Upgrade PHP to 7, enable opcache, optimize your Apache/Nginx configuration, optimize your MySQL configuration).

When optimization is not possible and your results are not good enough, consider hosting your website with a better CPU. Probably the most feasible thing to do will be to buy an optimized WordPress web hosting.

However, when shared hosting is not the option here is our recommendation.

A lot of WordPress website owners spend over $500 monthly to handle high traffic. Take a look at DigitalOcean architecture for WordPress and other PHP applications we recommending, which costs $120 monthly and also allows website owners to scale up/down as traffic gets higher or lower.

In case when your database is under heavy load - just take instance with more RAM memory and optimize your MySQL configuration and MySQL caching.

Funny facts & stats

Almost fully automated tests

Each droplet is tested under 1h

18 droplets tested with 4 scripts

Total 162 tests performed

~ 7200 HTTP tests requests are sent during test

Total 80 profilings done

over 30h spent

What’s next

We want to do much more research on web performance, security, tools, hosting providers, etc.

Which research you want to we do next?

benchmark of plain, magazine, shop WordPress websites on all Amazon AWS instances

perform load test of plain, magazine and shop WordPress websites on all DigitalOcean droplets

Share this article on social networks with your comments and the vote for next research.

Credits

Many thanks to

DigitalOcean for sponsoring credits for performing tests

CURL development team for creating such great tool

Daniel Opitz for creating PHP benchmark script

Rafa Marruedo for creating whminfo.sh script

DigitalOcean API developers for creating useful REST API

Test your website

Want your website to be tested on high CPU or high RAM droplets? Contact us: info [AT] learnwebdevelopment.review