Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

chefxu's avatar

A way made laravel API more faster

Hello everyone, I recently made API performance optimization experiments when a way is to use a laravel fastcgi TSR, replace the php-fpm. According to the results of the current test, you can get great performance, about 50 + X. Currently only used in the stateless interface calls the scene, there are still shortcomings and deficiencies, hoping to get everyone's views.

Here is a example on github: https://github.com/chefxu/stone-laravel-example

Forgive my poor English.

0 likes
6 replies
ohffs's avatar

Those are really very impressive results! When you say 'Currently only used in the stateless interface calls' - what do you mean?

chefxu's avatar

@ohffs

Thank you for your reply. That meant that at present only suitable for some API, like json api, there is no cookies, no sessions.

The main reason is:

  1. Run the command line mode, session, cookie, etc. are not available, Http middleware is also unavailable.
  2. No complete implementation fastcgi protocol, file upload is unavailable.
  3. Since the TSR, laravel some originally in the request shared instance, will become shared between requests, like 'Auth', 'Session', which will bring bug.

In fact, in order to solve the above problem, In laravel I do a lot of changes, but there are still some problems. For purposes of discussion simple, I just consider optimizing the API without cookies.

ohffs's avatar

Ah - ok! It looks very cool though! Is it worth working with lumen rather than laravel - it's focused on API's from the start?

chefxu's avatar

Scene I actually used some running laravel online application, some data need to be open to other applications by way of some APIs, and a relatively high performance requirements. If an application is designed to start a pure API way, I think most scenarios lumen performance should be sufficient.

By avoiding every request to initialize the framework of resources, based on laravel optimization or optimization based on lumen, there is not much difference.

chefxu's avatar

Great! Thank you for giving me a great inspiration for the project.

Please or to participate in this conversation.