Last active
September 10, 2019 06:12
-
-
Save eagleon/05b468dc8945469d58876518e0b372a3 to your computer and use it in GitHub Desktop.
实时QPS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
某个时刻的实时qps监控: | |
tail /var/log/nginx/2012-08-25-taobao-access_log -f --pid=19139|grep "`date +%Y:%m:%d:%T`"|wc -l; | |
统计10秒中的总qps: | |
tail /var/log/nginx/2012-08-25-taobao-access_log -f -s 10 --pid=19139|wc -l | |
统计10秒中的平均qps: | |
echo "`/var/log/nginx/2012-08-25-taobao-access_log -f -s 10 --pid=19139|wc -l`/10"|bc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
概念说明
QPS : queries per second 每秒查询(请求)数
TPS : Transactions Per Second 每秒事务数
并发: 系统同时处理的请求/事务数
吞吐量:
响应时间 :客户端从发出请求到接受响应包的时间,一般为平均响应时间
一个系统的吞吐量(承压能力) 与request对CPU的消耗、外部接口、IO等等紧密关联。
单个request对CPU消耗越高,外部系统接口、IO影响速度越慢,系统吞吐能力越低,反之越高。
对服务器的意义
WEB服务器
QPS(TPS) = 并发数/平均响应时间
对WEB服务器而言,QPS/TPS是一样的
举例:现在有一台WEB服务器,测试访问某页面
当并发100时,响应时间为0.1S ,则QPS = 100/0.1 =1000
当并发500时,响应时间为1S ,则QPS =500/1 =500
得出结论,并发100时,QPS最高。
有什么意义呢?个人看法,如下:
当并发超过100,响应时间变大,可以去排查瓶颈,进行优化;
如果高峰期并发有300,考虑到用户体验及成本,可以配置3台WEB服务器。
另外提到QPS时,应该指定什么场景,多少并发。
数据库
QPS :平均每秒SQL 语句执行次数
==参考文档
http://www.ha97.com/5095.html
http://lxy2330.iteye.com/blog/1570312