Speedup REST API Service Laravel 5 Speedup REST API Service Laravel 5 laravel laravel

Speedup REST API Service Laravel 5


First step of PHP optimization is enabling a bytecode cache engine OPcache.

As each PHP script is being compiled at runtime, a part of the execution time gets used for transforming the human readable code into code that can be understood by the machine.

A bytecode cache engine does it only once – during the first execution of a specific PHP file. Then the precompiled script is being stored in memory, which should lead to performance boosts in your PHP applications.

That is the reason why you have 300ms response time for the first request, and 100ms for all other requests.

Understanding OPcache: http://www.sitepoint.com/understanding-opcache/

Enabling OPcache: https://stackoverflow.com/a/17304671/1331425

PS. There's a nice dashboard for monitoring memory consumption - OPcache Dashboard:

enter image description here


One of the solution is to update your PHP version to PHP7

As per Rasmus Lerdorf presentation, the greatest part about PHP 7 is the incredible performance boosts it provides to applications. This is a result of refactoring the Zend Engine to use more compact data structures and less heap allocations/deallocations.

enter image description here

https://github.com/php/php-src/releases

https://github.com/tpunt/PHP7-Reference#performance