My cake php can not handle more than one request simultaneously


I got a page that need a lot of time to process and that’s not a problem. but the problem is when I do a request on a page (or on any page that need time, all the page that need time use same model/controller and views) , then every other requests are queued. I use PHP-FPM, I have 3 workers and when I look at php-fpm state, two workers are active and one iddle (that make me think, the problem doesn’t come from fpm. I have try to disable cache, disable debugging. but no success.

I have try to use the server of cakephp (without php-fpm so) =>same thing
I have try a page that stupid read a file 1000 times and call a simple page during callin the first one =>same thing
I have try to set the layout to only fetch content=>same thing

Here are what the timer of the debugger show when processing one request that need time, and one one a simple page (even without sql request). we can see that the second request is queued and only process when the first one is done.

the second request displays only when the first one is totally process.

important thing : the first page displays took time, and then display in one second, there is no progressive display

My server has a Big CPU with 8 thread, lot of memory (64G), so it is not a hardware problem
same site on, an other server give the same results.
If i launch the server of cakephp and with nginx, if I call the page that took time on port 80, and the other one on port 8765, the request are simultaneously proceed. to sum up. on same server, cakephp is not able to proceed two requests.

any help is appreciate. I am stuck !

You probably get session locked

Try using e.g. sessions via file based cache config by adjusting your config/app_local.php to have

'Cache' => [
    // Maybe other custom cache configs here?
    'session' => [
        'className' => \Cake\Cache\Engine\FileEngine::class,
        'path' => CACHE . 'session' . DS,
        'duration' => '+1 week',

'Session' => [
    'defaults' => 'cache',
    'handler' => [
        'config' => 'session'

also see Sessions - 4.x on other possible session handlers.

you re the boss ! it works. I will now read the link to understand !

It is strange to think that it is not well configured by default…

thanks…and…again thanks !

While developing the default PHP sessions config is fine because the scenarios to run into session locking is pretty minimal / not that big of a deal. But we could add a notice to the Deployment doc page. :thinking:

BUT what I also wanted to mention here:

Since you seem to have some “computational heavy” stuff being done in your app I would highly recommend you look into implementing a queue like GitHub - dereuromark/cakephp-queue: Queue plugin for CakePHP - simple, pure PHP and without dependencies. or GitHub - cakephp/queue: A queue-interop compatible Queueing library

With that you can offload the heavy computational code to a background job so your users/clients don’t have to wait so long.

I have think about it and see that, but add some complexity, and have choose to cache all I can.

I have stupidly add a parameter ?wait= true that display a waiting page that call the same with wait=false. my chance is that the load is not progressive and display in one second after the process, so I don’t need ajx at all or something asynchronous.

I will have a look anyway and see if it is a good for my app.