mysql's qps and tps

When doing db benchmarks, there are 2 metrics that are important.

QPS: Queries Per Second Queries per second, which is the number of queries a server can perform per second, and is a measure of the number of queries processed by a specific query server within a specified time.
TPS : Transactions Per Second is the number of transactions per second, which is the number of transactions processed by a database server per unit of time. 
 
How to calculate:
There are two ways to get the qps and tps of mysql from the Internet:
1. Calculate qps based on questions, and calculate tps based on com_commit com_rollback
questions = show global status like 'questions';
uptime = show global status like 'uptime';
qps=questions/uptime. In addition, it can be tested separately every 10s to get ( questions2 -questions1)/10
 
com_commit = show global status like 'com_commit';
com_rollback = show global status like 'com_rollback';
uptime = show global status like 'uptime';
tps=(com_commit + com_rollback)/uptime
2. Calculate tps and qps based on the status variable of com_*
Use the following command:
show global status where variable_name in('com_select','com_insert','com_delete','com_update');
Get the value of com_* with an interval of 1s, and perform the difference operation
del_diff = (int (mystat2 ['com_delete']) - int (mystat1 ['com_delete'])) / diff
ins_diff = (int(mystat2['com_insert'])    - int(mystat1['com_insert']) ) / diff
sel_diff = (int(mystat2['com_select'])    - int(mystat1['com_select']) ) / diff
upd_diff = (int(mystat2['com_update'])   - int(mystat1['com_update']) ) / diff
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326267425&siteId=291194637