Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Speedup REST API Service Laravel 5

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.

Thank's.

like image 637
Pixel Avatar asked Dec 11 '15 10:12

Pixel


1 Answers

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

like image 90
Limon Monte Avatar answered Oct 21 '22 14:10

Limon Monte