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:
5 users on each website. Y axis - response time in milliseconds.
Here we don't really see any difference although PHP 7 is slightly faster in my opinion.
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.
The difference is clear - magento 2 / php 7 outperforms magento 2 / php 5. By as much as 25%.
Still php 7 is faster than php 5 although the load is enormous for 1G 1 core server - 50 users on the website!
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 651 people who receive Magento news, tips and tricks regularly.