Loading..
Processing... Please wait...

Product was successfully added to your shopping cart.



Magento 2 on PHP7 - 25% increase in performance

Magento 2.0.1 now supports php 7. In the blog post that followed the release they mentioned quote dramatic performance improvements unquote.

I decided to find out if Magento 2 on php 7 is really faster than the same installation running on php 5.

But first we will need to build PHP 7.

PHP7 building from source

I downloaded the latest php 7.0.2 archive and compiled it on my debian 7 machine:

./configure  --enable-fpm --enable-mbstring --with-curl --with-mcrypt --with-libzip --with-openssl --with-gd --with-xsl --enable-intl --enable-zip --with-pdo-mysql --with-mysql-sock=/var/run/mysqld/mysqld.sock   --with-jpeg-dir=/usr/lib64
make install

I had to make sure I enabled all the necessarily extensions Magento 2 requires.

Magento 2 Installation

I would not go into much details on how to install Magento 2. There are many tutorials available on the web that cover it step by step.

I installed Magento 2 with sample data to have some real life pages for the test.

Magento 2 on PHP 7 vs Magento 2 on PHP 5

Let's create some JMeter test plans to find out how fast magento and php 7 really is comparing to php 5.

We will have two magento websites both are Magento 2 but one is running on php 7 and the other is running on php 5.

We will be using PHP 7.0.2 and PHP 5.6.16-1.

Server specs - 1G RAM and 1 core.

We will be changing the number of users who simultaneously try to visit the websites and will see what will be the difference in response times.

All the users will visit the predefined set of urls:

  • homepage
  • women.html
  • men.html
  • /checkout/cart

5 users

5 users on each website. Y axis - response time in milliseconds.

5 users | Magento 2 | PHP 5 vs PHP 7 | Goivvy.com 5 users | Magento 2 | PHP 5 vs PHP 7 | Goivvy.com

Here we don't really see any difference although PHP 7 is slightly faster in my opinion.

10 Users

Here we see the difference in response times clearly. Magento 2 on PHP 7 test plan even went faster and ended earlier as you can see in the graph below.

10 Users | PHP 5 vs PHP 7 | Magento 2 | Goivvy.com 10 Users | PHP 5 vs PHP 7 | Magento 2 | Goivvy.com

30 Users

The difference is clear - magento 2 / php 7 outperforms magento 2 / php 5. By as much as 25%.

30 Users | PHP 5 vs PHP 7 | Magento 2 | Goivvy.com 30 Users | PHP 5 vs PHP 7 | Magento 2 | Goivvy.com

 

50 Users

Still php 7 is faster than php 5 although the load is enormous for 1G 1 core server - 50 users on the website!

50 Users | PHP 5 vs PHP 7 | Magento 2 | Goivvy.com 50 Users | PHP 5 vs PHP 7 | Magento 2 | Goivvy.com

 

Results

We see that magento 2 / php 7 is consistently faster than magento 2 / php 5. You might want to upgrade to php 7 to speed up your store.

Share your experience with Magento 2 on PHP 7 in comments below.

 

If you find this post interesting do not hesitate to sign up for our newsletter and join the 636 people who receive Magento news, tips and tricks regularly.

Thank You!

 

 

4 thoughts on “Magento 2 on PHP7 - 25% increase in performance”

  • Paul Hutchinson

    Good tips Konstantin. I would recommend to also use Redis+Varnish for cache as shown in this fine article: https://www.rosehosting.com/blog/magento-2-with-redis-varnish-and-nginx-as-ssl-termination/

    Combining the tips from your tutorial and the one at Rosehosting improved my Magento website speed by more than 50%.

    Thank you a lot for sharing this.

  • Fahad Rafiq

    Well I found some more benchmarks of Magento 2 with PHP 7 and Magento 1 with PHP 7. Super Combination.

    Magento 2 Source: http://www.cloudways.com/blog/magento-2-with-php-7-on-cloud/

    Magento 1.9 Source: http://www.cloudways.com/blog/configure-magento-with-php-7/

  • Azaz

    I saw a blog post where there were benchmarks of Magento 2 running with PHP 7. The numbers were quite impressive. The response time was 86ms with 100% hit rate. This is quite an improvement over the previous versions of Magento and PHP. Here is the blog post I was talking about: http://www.cloudways.com/blog/magento-2-with-php-7-on-cloud/

  • Alex

    Just stumbled upon your blog,
    Great stuff guys! This is the kind of analytical stuff that the community needs:)