Benchmarking the CPU of a cloud server

With a virtual or cloud server you get very little information on how fast the processor actually is. A fast processor is an important factor in a fast WordPress site where hundreds of thousands of lines of PHP code need to be executed.

You can gain a rough idea by timing the CPU performing an intensive task like calculating prime numbers or in this instance calculating Pi to 5000 decimal places.

Run the following:

time echo "scale=5000; 4*a(1)" | bc -l

Results:
Ionos VPS L, 4 vCores,  8 GB: 16.660s, 16.775s, 16.804s
DigitalOcean Basic (Cloudways) 1 vCPU, 2 GB: 21.117s, 19.791s, 20.939s
DigitalOcean Basic, 1 vCPU, 2 GB: 23.525s, 26.642s, 29.319s
DigitalOcean Premium, 2 vCPU, 4 GB: 21.384s, 22.779s, 21.587s

2024 Kinsta PHP Benchmarks

Kinsta have evaluated of the most popular PHP content management systems (including WordPress) and frameworks using multiple PHP versions including recently released PHP 8.3.

It is well worth reading to take in all the details but a few highlights are CodeIgniter 4, my favourite framework achieving 1684 requests per second.

WordPress and WooCommerce weren’t so great but then you shouldn’t be choosing WordPress for speed, it’s advantages are that it’s easy to use and the third party themes and plugins make it inexpensive to get a rich website created quickly.

https://kinsta.com/blog/php-benchmarks/

CodeIgniter 4 hide the Debug Toolbar for certain routes

To hide the debug toolbar for a certain route, edit Config/Filters.php and add  a new constructor at the bottom of the file containing the following

public function __construct()
{
    if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], 'your_URL_here')) unset($this->globals['after'][0]);
}

WordPress custom page type pagination 404

During development if you get a 404 when trying to paginate with a custom post type there may be a simple explanation.

If there is a page with the same name as the custom post type the permalink rewrite rules will get confused e.g. a page called books and a custom post type with post_type key books. The solution is to name the custom post type key with the singular version, then it’s fine.

Prevent WordPress showing notice errors

When you are working with an older site it may be necessary to prevent notice level errors from appearing in the error log so that you aren’t swamped with too many messages.

Adding code to wp-config.php doesn’t work because WordPress itself tries to set the error level.

Instead create a ‘must use’ plugin and add the following:

error_reporting(E_ALL & ~E_NOTICE);