首页 > 其他 > 详细

nginx参考

时间:2019-02-27 15:28:40      阅读:168      评论:0      收藏:0      [点我收藏+]

参考链接:http://blog.sina.com.cn/s/blog_4f9fc6e10102uxib.html

【1】接口请求时间

1、request_time
官网描述:request processing time in seconds with a milliseconds resolution; time elapsed between the first bytes were read from the client and the log write after the last bytes were sent to the client 。
指的就是从接受用户请求的第一个字节到发送完响应数据的时间,即包括接收请求数据时间、程序响应时间、输出
响应数据时间。
 
2、upstream_response_time
官网描述:keeps times of responses obtained from upstream servers; times are kept in seconds with a milliseconds resolution. Several response times are separated by commas and colons like addresses in the $upstream_addr variable
 
是指从Nginx向后端(php-cgi)建立连接开始到接受完数据然后关闭连接为止的时间。
 
从上面的描述可以看出,$request_time肯定比$upstream_response_time值大,特别是使用POST方式传递参数时,因为Nginx会把request body缓存住,接受完毕后才会把数据一起发给后端。所以如果用户网络较差,或者传递数据较大时,$request_time会比$upstream_response_time大很多。
 
所以如果使用nginx的accesslog查看php程序中哪些接口比较慢的话,记得在log_format中加入$upstream_response_time。

【2】其他参数

参数具体含义如下:

$remote_addr :与$http_x_forwarded_for用以记录客户端的ip地址;

$remote_user :记录客户端用户的名称;

$time_local  :访问时间及时区;

$request     :请求的URL与HTTP协议;

$status     :记录请求状态

$body_bytes_sent:记录发送给客户端文件主体内容大小;

$http_referer:用来记录从那个页面链接访问过来的;

$http_user_agent:记录客户端浏览器的相关信息

access_log /usr/local/nginx/var/log/access.log  main ;   这句话是日志文件存放的位置



这里是默认的配置,但是有的时候我们需要自己配置我们的nginx日志格式,下面给出一些常用的参数配置。

$bytes_sent :客户端发送的字节数

$request_length:客户端请求的长度

$http_host   :客户端请求的地址请求地址,即浏览器中你输入的地址(IP或域名)

$upstream_status:upstream状态

$upstream_addr   :后台upstream的地址,即真正提供服务的主机地址 

$request_time        : 整个请求的总时间 

$upstream_response_time:请求过程中,upstream响应时间 

$request_body   :POST数据

 

nginx参考

原文:https://www.cnblogs.com/daysn/p/10443939.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!