MySQL响应时间监测

本文涉及的产品
RDS AI 助手,专业版
RDS MySQL DuckDB 分析主实例,基础系列 4核8GB
RDS MySQL DuckDB 分析主实例,集群系列 4核8GB
简介:

 大家习惯于以响应时间来衡量性能表现,实际响应时间指的正是从接收请求开始到发送响应之间的时间跨度。我们通常的做法是在代码里加入日志计算时间,这个是不准确的,该方式只是单单计算应用程序内部经过的时间,没有计算网卡到应用程序,应用程序到网卡的时间。这个会由于系统的负载发生很大的变化!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






本文转自 位鹏飞 51CTO博客,原文链接:http://blog.51cto.com/weipengfei/941918,如需转载请自行联系原作者

相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。   相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情: https://www.aliyun.com/product/rds/mysql 
目录
相关文章
|
Prometheus 监控 Cloud Native
手把手教你Prometheus + Granafa实现mysql 性能监测部署
数据库性能监控可以说是十分重要,能否自行搭建环境实现像阿里云或是腾讯云那样直观的展示不同维度数据的功能?答案是肯定的。下面详细说明一下安装部署过程以及过程中出现的问题,希望对你有所帮助!
手把手教你Prometheus + Granafa实现mysql 性能监测部署
|
监控 关系型数据库 MySQL
MySQL性能调优与监控:优化查询与实时监测
本文深入探讨了MySQL数据库的性能调优与监控,通过详细的代码示例,介绍了优化器与执行计划、查询性能调优策略,以及性能监控工具与指标。优化查询性能是数据库管理中的关键环节,通过合理的查询设计、索引的使用和避免不必要的操作,可以显著提升数据库操作效率。性能监控工具如MySQL Performance Schema和MySQL Enterprise Monitor能够实时监测数据库的性能指标,帮助管理员及时发现和解决性能问题。
1673 0
MySQL性能调优与监控:优化查询与实时监测
|
关系型数据库 MySQL
mysql监测工具tuning-primer.sh
mysql监测工具tuning-primer.sh
146 0
|
关系型数据库 MySQL Perl
使用innotop监测mysql
一. 安装   INNOTOP是一个通过文本模式显示MySQL和InnoDB的监测工具。
1277 0

推荐镜像

更多