MySQL响应时间监测

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
云数据库 RDS MySQL Serverless,价值2615元额度,1个月
简介:

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

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
Prometheus 监控 Cloud Native
手把手教你Prometheus + Granafa实现mysql 性能监测部署
数据库性能监控可以说是十分重要,能否自行搭建环境实现像阿里云或是腾讯云那样直观的展示不同维度数据的功能?答案是肯定的。下面详细说明一下安装部署过程以及过程中出现的问题,希望对你有所帮助!
手把手教你Prometheus + Granafa实现mysql 性能监测部署
|
6月前
|
关系型数据库 MySQL
mysql监测工具tuning-primer.sh
mysql监测工具tuning-primer.sh
33 0
|
9月前
|
监控 关系型数据库 MySQL
MySQL性能调优与监控:优化查询与实时监测
本文深入探讨了MySQL数据库的性能调优与监控,通过详细的代码示例,介绍了优化器与执行计划、查询性能调优策略,以及性能监控工具与指标。优化查询性能是数据库管理中的关键环节,通过合理的查询设计、索引的使用和避免不必要的操作,可以显著提升数据库操作效率。性能监控工具如MySQL Performance Schema和MySQL Enterprise Monitor能够实时监测数据库的性能指标,帮助管理员及时发现和解决性能问题。
426 0
MySQL性能调优与监控:优化查询与实时监测
|
2天前
|
关系型数据库 MySQL 数据库
docker MySQL删除数据库时的错误(errno: 39)
docker MySQL删除数据库时的错误(errno: 39)
|
2天前
|
关系型数据库 MySQL 数据库连接
用Navicat备份Mysql演示系统数据库的时候出:Too Many Connections
用Navicat备份Mysql演示系统数据库的时候出:Too Many Connections
|
3天前
|
存储 Oracle 关系型数据库
oracle 数据库 迁移 mysql数据库
将 Oracle 数据库迁移到 MySQL 是一项复杂的任务,因为这两种数据库管理系统具有不同的架构、语法和功能。
15 0