What is nginx $ request_time and why is it so much more than php-fpm runtime?

Background . The goal of my project is to create a very fast response website. There are only very few pages, many of them just redirect 302.

In Nginx, I register $request_time here .

In PHP, I register microtime start of a request and just before it microtime .

php-fpm (php 5.3.27) and nginx (1.4.4) work on the same computer, there is no database (just writing to the Beanstalkd queue), there are no complex nginx configurations.

Problem . There is a huge discrepancy between the PHP runtime and the Nginx $ request_time request. $ Request_time is usually 0.5 seconds, but within a few hours it looks more like 3 seconds . PHP runtime is always between 0.008 seconds and 0.02 seconds (using PhalconPHP ).

Question : Why can there be such a big discrepancy? Perhaps I do not quite understand what $request_time , or maybe my web servers have some kind of problematic configuration? I would be happy to provide more information about the environment.

+7
php nginx
source share
1 answer

$request_time - time from the first byte sent, until the registration is closed and completed. If you look at your nginx logs and the micro-time you are logging, how close are they to the start time? For those where request_time was closer to 3 seconds and the php runtime was 0.02 seconds, if you extrapolate the start time of the request and compare it to microtime inside php, they close or nginx need to wait a second or 2 (maybe for the php process for release, etc.). It would probably be interesting to also register $upstream_response_time to see how this compares.

+1
source share

All Articles