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

计算访问路径频度

awk '{print $7}' access.log|sort | uniq -c |sort -n -k  -r|more |grep /路径 

ps

print & $
print 是awk打印指定内容的主要命令
awk '{print}' /etc/passwd == awk '{print $0}' /etc/passwd
awk '{print " "}' /etc/passwd //不输出passwd的内容,而是输出相同个数的空行,进一步解释了awk是一行一行处理文本
awk '{print "a"}' /etc/passwd //输出相同个数的a行,一行只有一个a字母
awk -F":" '{print $1}' /etc/passwd
awk -F: '{print $1; print $2}' /etc/passwd //将每一行的前二个字段,分行输出,进一步理解一行一行处理文本
awk -F: '{print $1,$3,$6}' OFS="\t" /etc/passwd //输出字段1,3,6,以制表符作为分隔符

【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 。
指的就是从接受用户请求的第一个字节到发送完响应数据的时间,即包括接收请求数据时间、程序响应时间、输出
响应数据时间。 、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优化参考的更多相关文章

  1. Nginx配置优化参考

    Nginx配置优化参考                                                                                          ...

  2. Nginx性能优化参考

    nginx性能优化参考 1)调整配置文件中的配置项的值(配置文件:nginx.conf) worker_processes auto;开启的进程数,一般配置为跟逻辑CPU核数一样worker_rlim ...

  3. 2.Nginx优化

    [教程主题]:Nginx优化 [课程录制]: 创E [主要内容] Nginx 优化 nginx介绍 Nginx是俄罗斯人编写的十分轻量级的HTTP服务器,Nginx,它的发音为"engine ...

  4. Nginx优化use参数epoll,kqueue,rtsig,eventport,poll

    转自:http://blog.sina.com.cn/s/blog_5eaf88f10100gkrq.html Nginx use参数分析对比 下图对比了poll select epoll和kqueu ...

  5. lnmp使用socket方式连接nginx优化php-fpm性能

    lnmp使用socket方式连接nginx优化php-fpm性能 Nginx连接fastcgi的方式有2种:TCP和unix domain socket 什么是Unix domain socket?- ...

  6. Nginx优化(十七)

    [教程主题]:Nginx优化 [课程录制]: 创E [主要内容] Nginx 优化 nginx介绍 Nginx是俄罗斯人编写的十分轻量级的HTTP服务器,Nginx,它的发音为“engine X”,是 ...

  7. NGINX: 优化 use 参数

    转自:http://blog.sina.com.cn/s/blog_5eaf88f10100gkrq.html Nginx use参数分析对比 下图对比了poll select epoll和kqueu ...

  8. nginx优化配置大全

    由于面试被问到nginx优化做过哪些 后来发现,其实做过的也不少,忘了的更不少,因此写个博客记录一下(里面有一些内容来源于其他作者). 配置文件样例为生产环境样例. 1.nginx基本优化 安装方式有 ...

  9. nginx优化、负载均衡、rewrite

    nginx优化 # 普通用户启动 (useradd nginx -s /sbin/nologin -M) user nginx; # 配置nginx worker进程个数 #worker_proces ...

随机推荐

  1. django-ajax post与get请求

    客户端    访问  服务器  方式:      地址栏          get      a标签           get      form表单     get/post      ajax ...

  2. 转载 Unity Text 插入超链接

    using System; using System.Collections.Generic; using System.Text; using System.Text.RegularExpressi ...

  3. 栈ADT

    栈 栈是限制插入和删除只能在同一位置的表,这一位置称为栈顶(top),也可能称为LIFO表 对于空栈的pop(弹栈)操作是一个ADT错误,但是若是push(压栈)时空间超限并不是ADT错误 实现:基于 ...

  4. fiddler学习总结--autoresponder替换资源

    意义:替换服务器返回的内容 1.找到需要替换的目标 2.选择目标后,点击“autoresponder”-->”add  rules” 3.在下图中,选择“find a file”,再选择需要替换 ...

  5. python工具的选择

    自己喜欢用pycharm,下载地址:https://www.jetbrains.com/products.html#lang=python 补丁地址:http://idea.lanyus.com/

  6. Django框架详细介绍---模型---ORM

    一.概述 ORM(Object Relational Mapping),全称:对象关系映射,简单的说就是通过创建类.实例化出对象的方法,使得类.对象.对象的属性能够和数据库中的表.记录.字段意义对应. ...

  7. React 最简单的入门教程

      一看就懂的ReactJs入门教程(精华版)   现在最热门的前端框架有AngularJS.React.Bootstrap等.自从接触了ReactJS,ReactJs的虚拟DOM(Virtual D ...

  8. Jmeter对jar包的调用赋值

    一.前言 在我们测试接口的过程中,可能有时需要用到第三方jar包来生成一些测试数据(如有时需要对参数的输入值使用第三方jar包进行加密操作),涉及到这种的情况,普遍做法是:手动调用jar包获得需要的值 ...

  9. 配置cron定时任务

    题:配置一个 cron 任务用户 natasha 必须配置一个定时执行任务,每天在本地时间 14:23 时执行命令* /bin/echo hiya 答: # 方法1 # su - natasha # ...

  10. 谷歌技术"三宝"之BigTable

    转自:https://blog.csdn.net/OpenNaive/article/details/7532589 2006年的OSDI有两篇google的论文,分别是BigTable和Chubby ...