衡量指标
TPS - Transactions Per Second(每秒传输的事物处理个数),即服务器每秒处理的事务数,如果是InnoDB会显示,没有InnoDB就不会显示。
TPS = (COM_COMMIT + COM_ROLLBACK)/UPTIME
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;
QPS - Queries Per Second(每秒查询处理量)MyISAM 引擎
QUESTIONS/UPTIME
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;
MySqlSlap
MySQLSlap是从Mysql5.1.4版开始官方提供的压力测试工具
过程分为:
创建schema,table,test data;
运行负载测试,可以使用多个并发客户端连接;
测试环境清理(删除创建的数据,表等,断开连接)
MySqlSlap测试
./mysqlslap -uroot -proot1234% --concurrency=500 --iterations=3 --number-char-cols=5 --number-
int-cols=5 --auto-generate-sql --auto-generate-sql-add-autoincrement --engine=myisam,innodb --
create-schema='enjoytest1' --debug-info