设为首页 收藏本站
查看: 711|回复: 0

[经验分享] MySQL响应时间监测

[复制链接]

尚未签到

发表于 2018-9-30 06:35:57 | 显示全部楼层 |阅读模式
  大家习惯于以响应时间来衡量性能表现,实际响应时间指的正是从接收请求开始到发送响应之间的时间跨度。我们通常的做法是在代码里加入日志计算时间,这个是不准确的,该方式只是单单计算应用程序内部经过的时间,没有计算网卡到应用程序,应用程序到网卡的时间。这个会由于系统的负载发生很大的变化!wireshark  和 tcpdump  这种抓包的方式,极需要耐心关键它不是持续的。
  今天说的是Percona公司开源的工具:Tcprstat。
  简介:Tcprstat 是 免费,开源的 TCP分析工具,它会检测网络的传输,并且计算请求和响应之间的delay。 它的输出格式 就像是linux里面的vmstat iostat 的格式一样进行输出。这个工具能够检测到某个端口的流量情况。所以呢它可以监听像mysqld httpd memcached 单个守护进程的请求和响应时间,或者其他的processer。(PS:这个工具不只是应用于MySQL哦)
  优点:
  1、轻量级,开销小,不用写入大量日志,不用分析大量的日志
  2 、 请求和响应的时间 精确到微妙级。
  3、输出的信息很容易导入到表格,或通过脚本格式化,或使用gnuplot的图形,等等
  4、这个与协议无关, works well for a large variety of client-server protocols that have a simple request-response model
  5、Tcprstat 关注于response的时间计算,并不是网卡流量的计算
  
  
  Response times 的计算方式:从最后的入站数据包的第一出站数据包锁经过的时间。。仅包含tcp控制信息的某些类型的数据包将被忽略。
  百分比计算方式:对响应时间进行排序再取出N%的结果。
  安装部分:
  下载地址:statically linked 64-bit binary (version 0.3.1)
  该文件是一个二进制文件,需要 重命名、加上可执行权限。
  执行:
  

  
./tcprstat -p 3306 -t 2 -n 2
  
timestamp count max  min avg med stddev 95_max 95_avg 95_std 99_max  99_avg  99_std
  
1343190264      72      2380    108     289     209     285     547     237     95      909     259     143
  

  输出格式定义为:  Format Code
  Header
  Default?
  Meaning
  %n
  count
  y
  Count of requests that completed during this iteration
  %a
  avg
  y
  Average response time
  %s
  sum
  y
  Sum of response times
  %x
  sqs
  Sum of squares of response times
  %m
  min
  y
  Minimum response time
  %M
  max
  y
  Maximum response time
  %h
  med
  y
  Median response time
  %S
  stddev
  y
  Standard deviation of response times
  %v
  var
  Variance of response times
  %I
  iter#
  Iteration number
  %t
  elapsed
  Seconds elapsed since the first iteration
  %T
  timestamp
  y
  Unix timestamp
  %%
  A literal %
  \ t
  A tab character
  \n
  A newline character
  95,99
  Adds a prefix
  y
  A percentile indicator; see later in this section for more


  

例如: tcprstat -f '%n\n' -p 3306 -t 1 -n 0  

  语法为:
  
Option Name
Short Name
Type
Default Value
Meaning
--format
-f
string
A format string; see above.
--[no]header
string
Enabled
If no argument is given, tcprstat auto-generates the header based on --format. If an argument is given,tcprstat uses that as the header instead. If --no-header is used,tcprstat will not print a header.
--help
Shows program information and usage.
--interval
-t
integer
10
The number of seconds tcprstatwaits between each successive line of output.
--iterations
-n
integer
1
How many iterationstcprstat should execute before exiting; 0 means infinity.
--local
-l
string
Accepts a comma-separated list of IP addresses to consider as local IP addresses, instead of getting a list from the operating system.
--port
-p
integer
Capture traffic only for the specified TCP port; if none, capture all traffic.
--read
-r
string
Read the specified pcap file instead of capturing traffic from the network.
--version  Shows version information.


  tcprstat 还可以分析一个 TCPDUMP 抓包文件。
  如果想将结果生成图像,可以利用gnuplot的图形,
  具体参考:http://www.ibm.com/developerworks/cn/linux/l-gnuplot/?ca=dwcn-newsletter-linux
  本文参考:http://www.percona.com/docs/wiki/tcprstat:start



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-606001-1-1.html 上篇帖子: Mysql cluster数据备份和恢复 下篇帖子: Java连接MYSQL数据库类
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表