1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Laravel app server delays response with extra 10 seconds on the first request

Discussão em 'Outras Linguagens' iniciado por Martin Dimitrov, Outubro 10, 2024 às 12:22.

  1. I am having an issue with a server (actually multiple different servers) that host a Laravel app.

    Infrastructure: The app is hosted at a couple of windows machines in AWS EC2 instance. The machines are good enough, so they do not run out of resources. They work ok. We expect huge load in a week or so, so I tried to set up a new instance to be able to hold the traffic. I set up a brand new instance as an absolute copy of one of the old ones - AMI, template, the whole deal. However, here comes the problem. The app works out of the box, but the first requests takes +10 seconds. The rest of the requests work fine. The machine is set up properly, confirmed with Amazon support, and the issue happens at localhost also - so not a networking issues. I have tried with both IIS server and the Laravel local server with artisan serve. The issue is the same. Here is the strange thing. If instead of returning the response, I dump the response with var_dump, then the first request takes 0.004 seconds instead of 10.004 seconds and then the next request takes +10 extra seconds. So the first return response from a controller is causing the issue. I tried all the stuff with IIS - disable recycling, auto-start, remove timeout and so on and so on. I removed all the middlewares, the DB is the same, the other instances work fine. I have cleaned the cache, not that also.

    At this point I am out of ideas. Any insight would be great!

    Continue reading...

Compartilhe esta Página