我的服务器端架构,是一个nginx+4个python的tornado服务,nginx做负载均衡,我在nginx中使用以下日志来记录每次请求的服务器端处理时间:
log_format mylog '$remote_addr - $remote_user [$time_local] '
' "$request $status cost:$request_time" $body_bytes_sent '
' "$http_referer" "$http_user_agent" "$http_host" ';
其中:$request_time表示每次请求的耗费时间(秒)
但是我发现这个时间和tornado端打印出来的时间存在一个数量级的差距,,nginx显示几百毫秒,而对应接口在tornado端只用了几十毫秒
以下为tornado端日志
2015-11-23 11:00:09,586:web.py:log_request:[line:1816] INFO 200 GET /posts_act (144.0.8.123) 23.29ms
以下为nginx端日志:
"GET /posts_act HTTP/1.1 200 cost:1.346"
"GET /posts_act HTTP/1.1 200 cost:0.116"
请问,我应该以哪个为准,,为什么相差这么大?如何做到统一,至少不会差距这么大?也妨碍了我进行系统监控,不知道问题出在nginx还是tornado
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
认证0级讲师