There is a lot of interesting things going on in the Moodle & PHP worlds recently – Moodle 3.0 has just been released and PHP 7 release is coming soon. Among other things, PHP 7 promises a great performance improvement over PHP 5.6 – PHP 7 is supposedly up to 2 x faster.
We have decided to put that into the test by simulating real-world Moodle 3.0 usage scenario. After a quick Moodle PHP 7 bug fix and hack to ignore Moodle version check, we were able to install Moodle using PHP 7.
The environment used for testing:
The test was performed with jmeter running on the same machine. This has affected the performance of the system but it should be the same overhead for running both PHP versions, so it should not matter for the comparison. We have tested 200 users answering 100 quiz questions each. Each user had a separate account and started his run by login, followed by answering 100 questions and submitting the quiz. Every question was on a separate page, so each user generated over 200 page hits. The test was set up to run 20 threads in parallel. The timings are taken from jmeter statistics and from Moodle performance reporting (MDL_PERF). After switching PHP version we have run & discarded dozens of jmeter tests to warm up all caches. All tests were executed with opcache enabled.
The results are grouped by PHP script that was run and show:
The most relevant values for a comparison like this are CPU time and memory used, so let’s see how well did PHP 7 do compared to PHP 5.
The table below show how much % of time / memory was consumed by PHP 7 compared to PHP 5.5.
In summary, PHP 7 performed more than 2 time faster compared to PHP 5.5 while consuming only 60% of the memory that PHP 5.5 did. Statistics from jMeter confirm that – PHP 5.5 was able to process on average 10 requests per second, while PHP 7 20 requests/second.
Keep in mind that the above does not mean that your users will get this kind of performance improvement as soon as you switch to new PHP version. The time measured here is a CPU time on the server side, which is just a fraction of the whole time needed to render the page for end user. Once you add network latency, loading media and rendering the page by the browser – the end result will be much less spectacular. Having said that the results are quite impressive – go PHP 7!