Home » Php » Speedup REST API Service Laravel 5

Speedup REST API Service Laravel 5

Posted by: admin November 30, 2017 Leave a comment


I’m using Laravel 5.1 to make a REST API service, and i would like to lower the response time of the API.
There is somes solution to lower API response except the serveur performance ?
Actually the serveur respond in 250 ms. (In production)
My old API on Slim Framework responded in 170 ms.



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