Sysbench测试指南
更新时间 2025-08-22 18:55:43
最近更新时间: 2025-08-22 18:55:43
本文介绍DRDS的性能测试指标和测试结果。
测试工具
Sysbench是一个基于LuaJIT的,模块化、跨平台、多线程基准测试工具,主要用于评估测试各种不同参数环境下的数据库负载情况。
测试环境
区域:华东1。
逻辑表数量:10。
分片数:2。
数据量:单表记录500w,2个分片,每个物理分片表记录250w;10张表总数据量5000w。
压力机: 1台sysbench,配置为4C8G。
压测时间:单次120S。
实例规格:
DRDS规格 | MySQL规格 |
---|---|
基础版12C24G | 2台配置为16C32G,500G SSD盘。 |
中级版24C48G | 2台配置为16C32G,500G SSD盘。 |
高级版48C96G | 2台配置为16C64G,500G SSD盘。 |
测试参数
压测表结构
CREATE TABLE IF NOT EXISTS `sbtest1` (
`id` int(10) unsigned NOT NULL,
`k` int(10) unsigned NOT NULL DEFAULT '0',
`c` char(120) NOT NULL DEFAULT '',
`pad` char(60) NOT NULL DEFAULT '',
KEY `xid` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
测试模型
Sysbench OLTP场景默认提交的事务中包含20条SQL语句,具体如下 :
主键SELECT语句:10条。
范围SELECT语句:4条。
UPDATE语句:2条。
DELETE语句:2条。
INSERT语句:2条。
测试指标
TPS:Transaction Per Second,数据库每秒执行的事务数,每个事务中包含20条SQL语句。
QPS:Query Per Second,数据库每秒执行的SQL数,包含insert、select、update、delete等。
测试步骤
使用sysbench命令压入测试数据到数据库中。
sysbench --mysql-host=<host> --mysql-port=<port> --mysql-user=<user> --mysql-password=<password> --mysql-db=<db_name> --mysql-table-engine=innodb --mysql-ignore-errors=1062,1213,1205,1020 --oltp-tables-count=10 --oltp-table-size=5000000 --db-driver=mysql --time=120 --report-interval=10 --oltp_create_secondary='off' --oltp_auto_inc='on' --oltp-test-mode=complex --rand-init=on --rand-type=uniform insert.lua --threads=64 prepare
说明: 需要注释掉common.lua脚本中的db_query(query)这一行。
使用sysbench命令执行压测。
sysbench --mysql-host=<host> --mysql-port=<port> --mysql-user=<user> --mysql-password=<password> --mysql-db=<db_name> --mysql-table-engine=innodb --mysql-ignore-errors=1062,1213,1205,1020 --oltp-tables-count=10 --oltp-table-size=5000000 --db-driver=mysql --time=120 --report-interval=10 --oltp_create_secondary='off' --oltp_auto_inc='on' --oltp-test-mode=complex --rand-init=on --rand-type=uniform insert.lua --threads=64 run
使用sysbench命令清理数据。
sysbench --mysql-host=<host> --mysql-port=<port> --mysql-user=<user> --mysql-password=<password> --mysql-db=<db_name> --mysql-table-engine=innodb --mysql-ignore-errors=1062,1213,1205,1020 --oltp-tables-count=10 --oltp-table-size=5000000 --db-driver=mysql --time=120 --report-interval=10 --oltp_create_secondary='off' --oltp_auto_inc='on' --oltp-test-mode=complex --rand-init=on --rand-type=uniform insert.lua --threads=64 cleanup
测试结果
测试规格 | 并发数 | TPS | QPS |
---|---|---|---|
基础版12C24G | 64 | 2239 | 44798 |
1024 | 3289 | 65785 | |
中级版24C48G | 64 | 2754 | 55093 |
1024 | 3438 | 68762 | |
高级版48C96G | 64 | 3186 | 63739 |
1024 | 4615 | 92318 |
注意
DRDS的内核有一定的过载保护能力,发生过载保护时压测结果可能会出现抖动,此时系统性能已经达到瓶颈,继续加压测试结果也无法得到明显提升。建议尝试降低压力,来获得更高的性能测试结果。