gpt4 book ai didi

performance - nginx中的request_time如何小于upstream_response_time?

转载 作者:行者123 更新时间:2023-12-03 17:14:27 28 4
gpt4 key购买 nike

我了解 nginx 的 request_time can be larger than upstream_response_time ,这只是意味着nginx和客户端之间的网络连接很慢。

我不明白的是如何request_time可以少吗?

我分析了一个 nginx 日志,其中 nginx 位于 API 前面。大约有 260 万行,因此我认为这是一个很好的示例(仅分析了 API 请求,没有分析静态文件。)

比率计算如下:
ratio = request_time / upstream_response_time

比率的平均值为 1.04,因此平均 request_timeupstream_response_time稍大一点,这听起来很合理。

我做了一个直方图来形象化这一点。我不明白的是直方图的左侧,其中值 < 1.0。

histogram

最佳答案

$upstream_response_time 由 clock_gettime(CLOCK_MONOTONIC_COARSE) 计算得出,默认情况下它可以过去 4 毫秒,相反,$request_time 由 gettimeofday() 计算.所以最终upstream_response_time 可能大于response_time。

基于 nginx forum thread

关于performance - nginx中的request_time如何小于upstream_response_time?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53978695/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com