什么原因导致 nginx 中的 upper_header_time 很大?

什么原因导致 nginx 中的 upper_header_time 很大?

设置:

Angular / Django / Nginx in ECS.

Route 53 -> ELB -> Target group ECS

With Nginx proxying /api | /admin calls to Django.

我们的某些 API 请求存在较大的滞后或延迟,日志显示如下:(为方便阅读,已换行)

timestamp="16/Jul/2019:16:24:43 +0000" 
client=10.96.192.168 
request="GET /api/redacted/?
redacted=0&
redacted=52.895649&
redacted=53.226591&
redacted=-2.900391&
redacted=-1.873169 HTTP/1.1" 
request_length=919 
bytes_sent=200514 
body_bytes_sent=200245 
referer=https://redacted.redacted.redacted.redacted.redacted/redacted 
user_agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36" 
upstream_addr=127.0.0.1:8000 
upstream_status=200 
request_time=19.077 
upstream_response_time=19.064 
upstream_connect_time=0.000 
upstream_header_time=19.064 
app_db_read_time=- 
app_db_write_time=- 
app_analysis_time=- 
app_other_time=-

引起我们注意的主要延迟是upstream_header_time大约upstream_response_time20 秒!

然而,由于我是 Nginx 新手,我不知道从哪里开始调试它,在本地工作时一切都按预期进行,没有这样的延迟。

问题:什么原因造成这个长达20秒的上游标头/响应时间?

配置文件:https://gist.github.com/jackdh/4fdffe6b11799f544d7cb211cc66bfe2

谢谢

答案1

根据 NGINX 文档:

$upstream_header_timekeeps time spent on receiving the response header from the upstream server (1.7.10); the time is kept in seconds with millisecond resolution. Times of several responses are separated by commas and colons like addresses in the $upstream_addr variable.

所以你的 Python 后端需要很长时间才能回答。

http://nginx.org/en/docs/http/ngx_http_upstream_module.html

相关内容