MySQL的TPS和QPS 计算方式

  • Post author:
  • Post category:mysql



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






计算方法:


TPS = (COM_COMMIT + COM_ROLLBACK)/UPTIME



  1. use information_schema;



  2. select


    VARIABLE_VALUE


    into


    @num_com


    from


    GLOBAL_STATUS


    where


    VARIABLE_NAME =


    ‘COM_COMMIT’


    ;



  3. select


    VARIABLE_VALUE


    into


    @num_roll


    from


    GLOBAL_STATUS


    where


    VARIABLE_NAME =


    ‘COM_ROLLBACK’


    ;



  4. select


    VARIABLE_VALUE


    into


    @uptime


    from


    GLOBAL_STATUS


    where


    VARIABLE_NAME =


    ‘UPTIME’


    ;



  5. select


    (@num_com+@num_roll)/@uptime;







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


计算方法:


QPS=QUESTIONS/UPTIME



  1. use information_schema;



  2. select


    VARIABLE_VALUE


    into


    @num_queries


    from


    GLOBAL_STATUS


    where


    VARIABLE_NAME =


    ‘QUESTIONS’


    ;



  3. select


    VARIABLE_VALUE


    into


    @uptime


    from


    GLOBAL_STATUS


    where


    VARIABLE_NAME =


    ‘UPTIME’


    ;



  4. select


    @num_queries/@uptime;




版权声明:本文为isoleo原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。