每秒查询率QPS是对一个特定的查询服务器在规定时间内所处理流量多少的衡量标准,在因特网上,作为域名系统服务器的机器的性能经常用每秒查询率来衡量。
原理:每天80%的访问集中在20%的时间里,这20%时间叫做峰值时间
公式:( 总PV数 * 80% ) / ( 每天秒数 * 20% ) = 峰值时间每秒请求数(QPS)
机器:峰值时间每秒QPS / 单台机器的QPS = 需要的机器
问:每天300w PV 的在单台机器上,这台机器需要多少QPS?
答:( 3000000 * 0.8 ) / (86400 * 0.2 ) = 139 (QPS)
问:如果一台机器的QPS是58,需要几台机器来支持?
答:139 / 58 = 3
1、概念:
2、日志输出格式:
172.16.0.70 - - [03/Jan/2019:23:57:20 +0800] "GET / HTTP/1.1" 302 0 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)"
172.16.0.70 - - [03/Jan/2019:23:57:20 +0800] "GET /ljzx HTTP/1.1" 302 5 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)"
172.16.0.70 - - [03/Jan/2019:23:57:20 +0800] "GET /ljzx/ HTTP/1.1" 302 0 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)"
172.16.0.70 - - [03/Jan/2019:23:57:20 +0800] "GET /ljzx/logout HTTP/1.1" 200 9228 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)"
172.16.0.70 - - [03/Jan/2019:23:58:20 +0800] "GET / HTTP/1.1" 302 0 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)"
172.16.0.70 - - [03/Jan/2019:23:58:20 +0800] "GET /ljzx HTTP/1.1" 302 5 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)"
...
3、统计
总PV量:
[root@localhost logs]# awk ‘{print $6}‘ host.access.log | wc -l
独立IP:
[root@localhost logs]# awk ‘{print $1}‘ host.access.log | sort -r |uniq -c | wc -l
UV统计:
[root@localhost logs]# awk ‘{print $10}‘ host.access.log | sort -r |uniq -c |wc -l
摘自
https://www.cnblogs.com/cangqiongbingchen/p/6434509.html
https://www.cnblogs.com/weiyiming007/p/10272258.html