术语说明:
QPS = req/sec = 请求数/秒
remote_addr=10.229.164.37 remote_user=- time_local=[05/Aug/2021:11:54:54 +0800] request="POST /omnipotent/level/getAppAbility HTTP/1.1" status=200 body_bytes_sent=383 http_referer="-" http_user_agent="RAL/2.0.32.1 (internal request)" request_time=0.008 http_x_bd_logid=3293945350 http_x_bd_routerip=- server_addr=10.228.146.142 server_port=8160 upstream_addr=unix:/home/work/orp/php/var/php-cgi.sock host=baijiahao-author.baidu.com http_x_forwarded_for="-" product=ORP subsys=ORP tracecode=32939453502391991306080511 msec=1628135694.003 http_x_bd_uniqid=1881705890 uniqid=1371967198 http_sid=- http_x_bd_idc=sy upstream_response_time=0.008 connections_active=1 msec=1628135694.003 cost=0.008 stable=- accpet_encode="deflate, gzip" http_cuid=- http_client_logid=- arg_cuid=- arg_seq_id=- spanid=0.5 request_length=423 bduid=
remote_addr=10.229.164.37 remote_user=- time_local=[05/Aug/2021:11:55:00 +0800] request="POST /omnipotent/level/getAppAbility HTTP/1.1" status=200 body_bytes_sent=383 http_referer="-" http_user_agent="RAL/2.0.32.1 (internal request)" request_time=0.006 http_x_bd_logid=3300026905 http_x_bd_routerip=- server_addr=10.228.146.142 server_port=8160 upstream_addr=unix:/home/work/orp/php/var/php-cgi.sock host=baijiahao-author.baidu.com http_x_forwarded_for="-" product=ORP subsys=ORP tracecode=33000269052391991306080511 msec=1628135700.078 http_x_bd_uniqid=3725483047 uniqid=1920555956 http_sid=- http_x_bd_idc=sy upstream_response_time=0.006 connections_active=1 msec=1628135700.078 cost=0.006 stable=- accpet_encode="deflate, gzip" http_cuid=- http_client_logid=- arg_cuid=- arg_seq_id=- spanid=0.5 request_length=423 bduid=
cat access_log | grep /omnipotent/level/getAppAbility | awk '{print $3}' | awk -F '/' '{print $3}' | uniq -c
【QPS计算PV和机器的方式】
QPS统计方式 [一般使用 http_load 进行统计]
QPS = 总请求数 / ( 进程总数 * 请求时间 )
QPS: 单个进程每秒请求服务器的成功次数
单台服务器每天PV计算
公式1:每天总PV = QPS * 3600 * 6
公式2:每天总PV = QPS * 3600 * 8
服务器计算
服务器数量 = ceil( 每天总PV / 单台服务器每天总PV )
【峰值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