Magento 1 and 2 speed comparison on PHP 5 and PHP 7

PHP 7.1.0 WAS RELEASED A COUPLE OF WEEKS BEFORE. ALL THE VERSIONS OF PHP LOWER THAN 5.6.X WERE ANNOUNCED AS OUTDATED AND ARE NOT SUPPORTED BY THE DEVELOPERS. SOME DISTRIBUTION VENDORS STILL SUPPORT SECURITY UPDATES IN TERMS OF LONG TERM SUPPORT, BUT YOU’LL NEVER GET THE NEW FEATURES WITH THEM.

Hello, Amasty blog readers!

We’ve been posting Magento performance tests for quite a while. For the last couple of months, our readers were asking us to test Magento 1 and 2 performance with the new PHP versions. And that day has come!

Why we are testing Magento speed again

Why are we testing Magento 1 and Magento 2 to check the speed and performance depending on different factors?

Site speed and performance is a crucial factor for e-commerce, both when it comes to SEO opportunities and customers behavior.

Despite the fact that PHP 7 adds more than 50% to site’s performance in general, still a significant number of Magento stores are using the old version of PHP. To stimulate shop owners to switch to faster options, we have compared different Magento versions performance on various PHP versions.

Also, this information can be useful for all the people who are working with Magento – agencies, developers, SEO specialists and the Magento community in general.

What we used to test Magento performance

Software
  • Debian 8.6 (64-bit) distribution kit
  • Apache 2.4.10
  • Percona Server 5.6.33
  • PHP 5.6.27, PHP 7.0.13, PHP 7.1.0
Magento versions
  • CE 1.9.3.1 with sample-data
  • EE 1.14.2.1 with sample-data
  • CE 2.1.2 (the data was generated via performance-toolkit, medium.xml profile)
  • EE 2.1.1 (the data was generated via performance-toolkit, medium.xml profile)

*With Magento 1.x compilation was turned on, with Magento 2.x production mode was on, too.

Server (a virtual machine)
  • 4 CPU cores
  • 8GB RAM
  • SSD storage

* this configuration is recommended by Amasty as a starter kit for running a Magento store.

Magento 1.x and PHP 7

As Magento 1.x does not officially support PHP 7, we applied a simple patch for EE 1.14.2.1.

</pre>
--- app/code/core/Mage/Core/Model/Layout.php.orig      2016-12-01 09:09:13.392844463 +0000

+++ app/code/core/Mage/Core/Model/Layout.php   2016-12-01 09:08:36.516177798 +0000

@@ -552,7 +552,7 @@

$out = '';

if (!empty($this->_output)) {

foreach ($this->_output as $callback) {

-                $out .= $this->getBlock($callback[0])->$callback[1]();

+                $out .= $this->getBlock($callback[0])->{$callback[1]}();

}
<pre>

Note: this patch is not a complete solution to run Magento 1 on PHP 7 and is not recommended for usage on a production store. However, this version is enough for running the tests.

Magento performance testing scenario

Performance testing used the following scenario with Apache jMeter 3.1:

  • Homepage loading
  • Category page loading
  • Performing search
  • Product page loading

Some details of the test

  1. 5 threads are run simultaneously, each of them has 100 loops total. In this test, we don’t do load testing and we do not compare different versions of Magento. The main goal of this test is to see the speed of certain actions on various PHP versions.
  2. For Magento 2.x versions, I am using a built-in performance-toolkit for generating products, customers, orders, and such.
    php bin/magento setup:performance:generate-fixtures vendor/magento/magento2-base/setup/performance-toolkit/profiles/ce/medium.xml
  3. jMeter is run in headless mode on the same server where Magento is installed. It allows us to avoid network delays influence on the test results.

Test results: data and diargams

Values in the table are the average server response time in milliseconds.

Magento CE 1.93.1 on PHP5 and PHP7 speed comparison

Magento CE 2.1.2 on PHP5 and PHP7 speed comparison

Magento EE 1.14.2.1 on PHP5 and PHP7 speed comparison

Magento EE 2-1-1 on PHP5 and PHP7 speed comparison

Dissecting the test results

Apart from the results that do not need to be commented, here are some additional thoughts I would like to point out:

  • Using PHP 7.0.13 instead of PHP 5.6.27 adds more than 50% to Magento 2.x performance. In other words, if you have your Magento 2 store on a server with PHP 5, you’re losing a lot of opportunities better speed offers you in the world of e-commerce.
  • A clean Magento 2.x didn’t run on PHP 7.1.0, because it uses mcrypt extension, which was declared as deprecated in PHP 7.1. The result is a fatal error Deprecated Functionality: Function mcrypt_module_open() is deprecated in /var/www/vhosts/magento2ce.mage-php70.amasty.net/public_html/vendor/magento/framework/Encryption/Crypt.php on line 54. To avoid this error, I had to edit app/bootstrap.php and set «error_reporting(0);». Also on PHP 7.1.0, after the compilation php bin/magento setup:di:compile attempt an error appeared: PHP Fatal error: Cannot use ‘Void’ as class name as it is reserved in /var/www/vhosts/magento2ce.mage-php70.amasty.net/public_html/vendor/magento/module-sales/Controller/Adminhtml/Order/Invoice/Void.php on line 9. To avoid this one, I compiled on PHP 7.0.13, but the compiled code was run on PHP 7.1.0.
  • PHP 7.1.0 speed/performance results are almost the same if compared to PHP 7.0.13, with a little bit back and forth on both sides. As Magento 2.x still doesn’t support PHP 7.1.x officially, we don’t recommend this pairing on a production site right now.
  • The latest Magento CE 1.x runs on PHP 7, but I didn’t have a chance to test all the functionality, and also there’s no guarantee that third party extensions will work on PHP 7 as well. If you decide to use this pairing, please do test the changes on a staging version of your Magento shop.

If you need to see the detailed results, you are welcome to download the PDF with all the data included:

Download research PDF for free