【mysql 性能关键指标】获取mysql关键性指标

关键性指标:

1、CPU利用率
2、内存利用率
3、磁盘空间
4、IOPS
5、QPS
6、TPS

名词解释:
IOPS:IOPS (Input/Output Operations Per Second),即每秒进行读写(I/O)操作的次数,多用于数据库等场合,衡量随机访问的性能。

两大瓶颈主要体现在2个方面:吞吐量与IOPS。

QPS:
QPS - Queries Per Second(每秒查询处理量)同时适用与InnoDB和MyISAM 引擎

计算方法:

QPS=QUESTIONS/UPTIME

mysql 计算QPS

use information_schema;  
select VARIABLE_VALUE into @num_queries from GLOBAL_STATUS where VARIABLE_NAME ='QUESTIONS';  
select VARIABLE_VALUE into @uptime from GLOBAL_STATUS where VARIABLE_NAME ='UPTIME';  
select @num_queries/@uptime as QPS;  
QPS
12.83454397056813

TPS:
TPS - Transactions Per Second(每秒传输的事物处理个数),这是指服务器每秒处理的事务数,支持事务的存储引擎如InnoDB等特有的一个性能指标。

计算方法:

TPS = (COM_COMMIT + COM_ROLLBACK)/UPTIME

mysql 计算TPS

use information_schema;  
select VARIABLE_VALUE into @num_com from GLOBAL_STATUS where VARIABLE_NAME ='COM_COMMIT';  
select VARIABLE_VALUE into @num_roll from GLOBAL_STATUS where VARIABLE_NAME ='COM_ROLLBACK';  
select VARIABLE_VALUE into @uptime from GLOBAL_STATUS where VARIABLE_NAME ='UPTIME';  
select (@num_com+@num_roll)/@uptime as TPS;  
TPS
2.7262609163580516

猜你喜欢

转载自blog.csdn.net/u013421629/article/details/79571012