The recent Joomla! 3.5 release included many useful little features, but perhaps the biggest change was one that the average end user won’t notice immediately; support for PHP 7. Of course, more immediately-tangible features like drag-and-drop images in the default editor or UI additions such as count items help improve workflow and article management, but PHP 7 offers something even more useful in terms of improving the user experience and reducing bounce rate; faster page loads. If you’ve did any reading on the benefits of PHP 7, you’ll already know that the PHP team have claimed that PHP 7 leads to massive performance improvements, but what effect do these changes have on Joomla? In this article, we aim to find out!
Significant changes in PHP
The update to PHP 7 was noted as the most important change for PHP since release of PHP 5 in 2004, which is no small claim! In fact, the PHP team state that overall performance increases of 2x and reduction in memory consumption by up to 50% are possible. The latest PHP version also introduces several new features like return type declarations, anonymous classes or spaceship operator (<=>), but also converts a lot of fatal errors into exceptions. There’s some bad news too; due to Joomla! 3.5 supporting PHP 7 it is no longer backward compatible. In fact, most changes in the PHP core are also not backward compatible hence why Joomla! is in the same boat. If you’re a core PHP developer you can see a full list of the backward incompatible changes .
For this performance test I decided to use the most recent Joomla! update, Joomla! 3.5.1, in a fresh install with only the sample blog data. The tests are run on my localhost server using MAMP for OS X. In terms of PHP versions tested, I’ve compared Joomla’s performance in both the the well-known and widely-used PHP 5.6.10, and of course PHP 7.0.0.
I’ve focused on front-end tests as this will be the key area of benefit for the user experience for most Joomla! users. In my test installation I switched off caching in Joomla! and disabled the cache on my local server for a purer comparison. Gzip compression was also disabled for more accurate loading time results. By default a vanilla install of Joomla! displays several modules:
- modules list module
- menu module
- search module
- main menu module
- list of all front-end views
- secondary menu module
- login form module
I decided to leave them as is because every single module produces database queries and has affect on memory usage and load times, so leaving them in will create a more ‘real-world’ result. In this install the frontpage load generates 21 MySQL queries, which is quite a common value for content websites, depending of course on the number of third-party extensions installed, but part of the enquiries will always be at the same level because of the core Joomla! operations like session management or checking published modules/plugins.
Joomla! 3.5 performance comparison under PHP 5.6 and PHP 7
Before we get to the meat of the test, bear in mind that the effects of this test may be not be accurate when it comes to your live server; there are still a range of different parameters that can affect performance. The main purpose of this test is to examine pure Joomla! performance under PHP 7. With higher traffic websites one of the key areas will be the number of requests per second your server answers, but that doesn’t mean that any improvements offered by using Joomla with PHP 7 are not worth implementing, so a localhost test should be sufficient. When it comes to comparing performance I focused on two key parameters – the amount of memory used to load and display the website and the overall load time. We didn’t measure database speed in this test so that’s why we used the same MySQL version (MySQLi 5.5.42) in both tests, with exactly the same query execution time regardless of which version of PHP was active.
In this test I measured the results from three different pages:
- frontpage with 8 modules and a content article (com_content)
- search results view (com_search)
- random image view (com_content with module inside article)
Below you will find a graphic detailing the breakdown of loading times for individual page elements; as you can see the improvement under PHP 7.0.0 is very noticeable:
For small tasks like beforeRender for modules the difference is insignificant, but for the most important plugins like afterInitialise and afterRenderComponent Joomla! 3.5 really speeds up! We can see in the image above that afterInitialise originally took 149.40 milliseconds and afterRenderComponent took 141.23 milliseconds to load, while after the update these times reduced to 62.80 ms and 60.93 ms respectively.
|PHP 5.6.10||PHP 7.0.0|
|Application: afterIntialise||149.40 ms||62.80 ms|
|Application: afterRenderComponent||141.23 ms||60.93 ms|
So with Joomla! 3.5.1 and PHP 7 the load process of these plugins is completed more than 2x faster than with PHP 5.6.10. That’s quite the achievement considering it’s still the exact same CMS, just with a different PHP version. It’s not just faster; it also consumes far less memory. The memory usage value is really important for websites with hight traffic and here is where we will see the most significant changes.
A clean Joomla! installation with several basic modules and a com_content article on the homepage consumes less than 9 MB of memory – 8.49 MB. When using the older version PHP we need at least 12 MB (12.05 MB) to load the same page which means switching to PHP 7 saved 40% of memory.
|PHP 5.6.10||PHP 7.0.0|
|Memory usage||12.05 MB||8.49 MB|
A quick look at the loading time waterfall tells us lot more fine detail; the overall speed is much better.
What we can see is that it’s not just a isolated gain; every single task is loaded faster. This suggests that we’ll see similar gains in most, if not all, items in your load order. Don’t forget that in this test we disabled the entire cache and the data is provided to the browser uncompressed, so we can expect to see even greater gains once these optimizations are enabled.
Before you upgrade to PHP 7
For me, and as the results show, the introduction of PHP 7 support in the latest Joomla! release is the biggest improvement available, offering much more than simple feature updates. Though it’s not something you’ll necessarily notice at first glance the fact is that load speed is a significant factor in your site’s bounce rate, and improved memory consumption provides a more solid experience for sites that have a large amount of visitors and page views; naturally, though using a localhost server is a good place to examine overall performance there’s still going to be fluctuations in the gains each site sees depending on the hardware configuration on the live machine. Even so, the possibility of getting any kind of speed boost is not to be sniffed at; in these tests almost all the CPU’s power is being used to serve one page to one browser, whereas your hosting will likely be serving many visitors at the same time, so even minor improvements in load time will matter. Along with this, the memory management benefits are huge; 40% less memory per single page is really a lot! With all that in mind, the only question left is why not upgrade now?.
Obviously the speed and memory improvements are something that you’ll want to take advantage of as soon as possible, but it’s best not to be too hasty. Chances are that your site isn’t running a vanilla Joomla! installation; there’s always a few third-party extensions that we can’t do without.The fact that Joomla! 3.5 supports PHP 7 doesn’t mean that every extension for Joomla! 3.5 will work with latest major PHP release, so before you switch over your production website to PHP 7 take the time to research whether your extension providers support it also, or are intending to do so in the future so that you can plan the upgrade accordingly. Of course, reversing the upgrade is usually a possibility if you run into issues; with PHPMyAdmin most hosts allow for a simple option for selecting the PHP version to be used, but for smaller hosts it might be a problem rolling back the changes. Don’t forget to also check whether your hosting provider offers PHP 7.0.0 support; if not, then now might be the time to start looking for one that does so that you can take advantage of all that extra efficiency.
I hope this article gave you a good idea of what kind of gains you can expect from upgrading the PHP and Joomla! versions on your website; if you want to know what else has been changed in Joomla! 3.5 then you can take a look through our in-depth Joomla! 3.5 feature breakdown .