X
    Categories: All Symfony Tutorials, Tips And Guides you needFeaturedLearn PHP Tutorials, Tips And Guides

PHP 5.6 Vs PHP 7 – Performance Benchmarks With Symfony 3

Symfony is rapidly becoming a popular choice for PHP projects. The framework has established its reputation after the release of version 3.x. In the same vein, PHP recently received a major update in the form of PHP 7.x. The latest PHP version is 7.1.x.

It is important to test the performance of these two new releases  to make sure that developers have a very good idea about the tools that they will be using in their next projects. In this context, it is important to understand that the previous versions of both Symfony and PHP will soon become obsolete. Thus, it is important to evaluate and understand the performance of the new versions so that the developers could better understand the implementation constraints of these tools.

In this test my main concern is to check which version of PHP (5.6 or 7.0) works in more optimized way with Symfony.

Test Scenario

I used the Blitz tool for this test.

The test scenario is divided into two cases:

The first case is:

  • Symfony 3.2 demo application
  • Cloudways Managed DigitalOcean server : 8GB
  • PHP 5.6
  • No caching libraries
  • Test Duration: 5 min
  • No of Users: 250

Now in the second case, I upgraded the server to PHP 7.0. The rest of the parameters remain the same:

  • Symfony 3.2 demo application
  • Cloudways Managed DigitalOcean server : 8GB
  • PHP 7.0
  • Test Duration: 5 min
  • No of Users: 250

To start the test, I signed up to Cloudways and launched a PHP Stack server from the London data centre. I left all the settings to default. To ensure more clarity of the statistics, I did not turn on any caching libraries such as Varnish or Redis on the server.

Related: How to Install Symfony 3 on Cloud Server

Symfony Benchmarking with PHP 5.6

This test was conducted using blitz.io. The test ran continuously for 5 minutes . The demo Symfony application I used here is created by Javier Eguiluz. You can find the Github repo here.

Here are the results of the test:

Response Time

The graph is pretty much self explanatory. Below 50 users, the server responded fast enough. As the number of users increased, the response time also increased. The maximum response time I got here is 5490 ms, when 246 users were present on the server

Hit Rate

The server saw around 10 hits/second for 50 users. However, as the users increased to 250, the hit rate rose to 43 hits/second. I saw a little glitch when the server reached above 200 users. However, the server stabilized itself and continued to handle the hits. I did not see any errors and timeout during the process.

In the span of 300 seconds, the server handled 10,237 hits without any visible signs of server overload.

The Complete Analysis

During the test, the blitz tool generated 10,237 hits successfully in 300 sec. In addition, the Symfony app transferred/received 172.65 MB of data. The average hit rate of 34/second translated to about 2,948,256 per day. Here is the summarized picture of the test:

Symfony Benchmarking with PHP 7.0

In the second half of the test, I upgraded my managed Digitalocean server to PHP 7.0. Cloudways has the PHP package update option in Server Management tab, where you can select PHP 5.6 or 7.0 from the options.

Once the server has been updated, I ran the blitz test again on the server with the same Symfony application.

Let’s see what results I got:

Response Time

This time, I saw significant improvement in the response time of the server. Below 50 users, the server responded within 500 ms. When the number of users increased to around 200+, the average response time was around 3 seconds. At this point, I saw significant differences between the two PHP versions. .

Hit Rate

I also saw improvement in the hit rate as well. When compared to PHP 5.6, the numbers almost doubled i.e 73/sec. Even with this load, the server did not see errors and timeouts.

In the span of 300 seconds, the server consumed 15,899 hits without any issues.

The Complete Analysis

During the test, the blitz tool generated 15,899 hits successfully in 300 seconds. The Symfony app transferred/received 252.37 MB of data. The average hit rate of 53/sec translates to about 4,578,912 per day. Here is the summarized picture of the test:

The Winner

The test generated the following statistics:

Parameters Symfony 3.2 + PHP 5.6 Symfony 3.2 + PHP 7.0
Region Ireland Ireland
Fastest Response Time 300 ms 274 ms
Slowest Response Time 5,491 ms 3,093 ms
Duration 300 seconds 300 seconds
Load 1-250 Users 1-250 Users
Total Hits 10,237 15,899
Average Hits 34/second 53/second
Transferred 1.95 MB 3.00 MB
Received 170.70 MB 249.37 MB

Related: PHP 5.6 Vs PHP 7 – Performance Benchmarks With Laravel 5

The results clearly highlight that PHP 7.0 outperforms PHP 5.6 in all major comparison points. This means that the upcoming widespread adoption of PHP 7.x will result in increased performance across the board. The result would be faster and higher performing PHP applications powered by all major frameworks.

Shahroze Nawaz: Shahroze is a PHP Community Manager at Cloudways - A Managed PHP Hosting Platform. He’s always in search of new frameworks and methods to implement them. Besides his coding life, he loves movies and playing soccer with friends. You can email him at shahroze.nawaz@cloudways.com