leslie-tsang commented on issue #5146: URL: https://github.com/apache/apisix/issues/5146#issuecomment-928927753
> For somebody who doesn't read the link, here is Maxim Dounin's answer: > > > This is because now on Linux $upstream_response_time > > is counted via clock_gettime(CLOCK_MONOTONIC_COARSE), and with > > typical values of CONFIG_HZ=250, it may be up to 4 > > milliseconds. At the same time, the time to calculate $request_time > > is not a monotonous time, but the result of gettimeofday(), i.e. > > that is, the time according to the wall clock. So in some cases > > $upstream_response_time may be slightly larger than > > $request_time. > > https://forum.nginx.org/read.php?21,284448,284450#msg-284450 > > Here is part of my letter sent to Nginx devel mail list this morning, which also give other details: > > > Currently, the request_time uses ngx_timeofday to get the time, which > > finally will call gettimeofday. Meanwhile, the upstream_x_time series > > uses ngx_current_msec to calculate the time, which finally will call > > ngx_monotonic_time. > > On Linux, the gettimeofday will call clock_gettime(CLOCK_REALTIME, > > &ts) while the ngx_monotonic_time will call > > clock_gettime(CLOCK_MONOTONIC_COARSE, &ts). > > So the request_time uses CLOCK_REALTIME and the upstream_x_time series > > uses CLOCK_MONOTONIC_COARSE. As they are different sources, Got. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
