PHP7 vs PHP5 API Benchmark


PHP 5.6 vs PHP 7 with API PlugHi There,

Our backend team here @ API Plug constantly tests and benchmarks various frameworks and technologies. Today we’ll be publishing our benchmark for PHP7 vs PHP5.6 running Laravel 5.2 framework.

###Test Environment
Environment has a big effect on outcome. For this test we initialised DigitalOcean’s smallest droplet. With no additional caching mechanism or optimizations.

####Server Specs:
– Ubuntu 14.04
– NGINX 1.4.6
– MySQL Server 5.5.46
– 512 MB RAM
– 1024 MB SWAP Space
– DigitalOcean smallest droplet

We tested an endpoint that gives out 50 results from MySQL Sakila database and Actors table. Each item consists of 4 fields as shown below:


“actor_id”: “1”,
“first_name”: “PENELOPE”,
“last_name”: “GUINESS”,
“last_update”: “2006-02-14 21:34:33”
####Tester & Load
We used a Free account from for convenience. We used “Maintain Client Load” to generate a constant flow of ever-increasing traffic. We specified %1 error threshold.

###PHP5.6 Results

Screen Shot 2015-12-23 at 18.11.58

PHP5.6 exceeded our error threshold of %1, and test stopped around ~ 130 clients/sec. As you can see from image Average Response Time is 1380ms.

###PHP7 Results

Screen Shot 2015-12-23 at 17.52.30
PHP7 exceeded our error treshold too and our test stopped around ~ 140 clients/sec. Average Response Time is 779 ms.


Red Line - PHP7 Blue Line - PHP5.6 Green Line - #clients
Red Line – PHP7 , Blue Line – PHP5.6 , Green Line – #clients


PHP7 comes with a highly optimised OpCache and it makes up for the difference between two results. PHP7 held an upper bound of ~ 2000ms (2s) while PHP5 had a bound of ~ 3000ms.

Our tests show that our droplet works best between ~ 50 – 75 clients/sec. However keep in mind that this is client/sec and quite a good number an average mobile app.

Since we wanted to test performance difference between PHP versions, we did not use any caching, connection optimisations etc. In a real world production environment, you can get more juice out of this tiny droplet.

###Final Words

It seems that PHP team is really moving forward performance-wise. Since it’s just released there are some third-party libraries and extensions that are not production quality, but we expect to make a switch soon. If you want to switch from PHP 5.6 to PHP 7 you could check official PHP 7 migration guide.

In our next blog we will be testing PHP against NodeJS.

Also API Plug now supports Laravel 5.2 for PHP7. With API Plug you can get your API in PHP7 Laravel 5.2, PHP5.* Laravel5.1, PHP5.* Laravel 4.2 and NodeJS today.




Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *