Home > Back-end >  NGinx PHP-FPM - Response time of 2.2x minutes for the first request
NGinx PHP-FPM - Response time of 2.2x minutes for the first request

Time:11-17

I deployed NGinx, php-fpm and php 8 on a EC2 / Linux 2 instance (T4g / ARM) to run a php application. As I had done for the previous version of this application and php 7.

It runs well, excepted for all first requests. Whatever the actions (clicking a button, submitted a text, etc.), the first request always takes 2.2x minutes, then the following ones run quickly. The browsers (Firefox and Chrome) are just waiting for the response, then react normally.

I see nothing from the logs (especially, the slow-log is empty) and the caches seem to work well.

I guess I missed a configuration point. Based on my readings, I tried a lot of things about the configuration of php-fpm and php, but unsuccessfully.

Is someone already encountered this kind of issue?

Thanks in advance

Fred

  • Activation of all logs for php-fpm and php,
  • Augmentation of the memory for the process,
  • Checking of the system parameters (nlimit, etc.),
  • etc.

CodePudding user response:

You've not provided details of the nginx config, nor the fpm config.

I see nothing from the logs

There's your next issue. The default (combined) log format does not show any timing information. Try adding $upstream_response_time and $request_time to your log file. This should tell you if the issue is outside your host, between nginx and PHP, or on the PHP side.

You should also be monitoring the load and CPU when those first couple of hits arrive along with the opcache usage.

CodePudding user response:

first of all, thanks to @symcbean for your point. It helped me to find the script taking a long time to render and to fix the problem.

The problem was not due to the configuration of NGinx, PHP-FPM or PHP. It occurred because of an obscure parameter for auto-update of the application running on these components, forcing the application to call a remote server and blocking the rendering.

  • Related