Skip to content

Instantly share code, notes, and snippets.

@charlescui
Created August 29, 2012 03:03
Show Gist options
  • Save charlescui/3506380 to your computer and use it in GitHub Desktop.
Save charlescui/3506380 to your computer and use it in GitHub Desktop.
分析http请求从网关机到反向代理开始处理的响应时间
查看方法:
tail -fn100 /var/log/nginx/access.log
例子:
58.16.228.134 - - [29/Aug/2012:10:47:20 +0800] "200" POST /api/v1/users/update_device_token?user_credentials=Z2caLs3BuAfZ0LKPe0 HTTP/1.1 "微电视 2.05 (iPhone; iPhone OS 5.1.1; zh_CN)" upstream_response_time 0.341 msec 1346208440.833 request_time 0.431
日志格式:
'$remote_addr - $remote_user [$time_local] "$status" $request "$http_user_agent" '
'upstream_response_time $upstream_response_time '
'msec $msec request_time $request_time';
解读:
1.$upstream_response_time,前段Nginx扔给后端服务并且后端服务接受请求花费的时间
2.$msec当前写入日志的时间
3.$request_time网关机Nginx处理这个请求直到扔给后端时候花费的时间
以上这些时间都是毫秒
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment