MYSQL基准测试

安装mysql(密码输入root)

apt update && apt install mysql-server -y

安装基准工具

apt install sysbench -y

创建测试数据库(有个警告,让你不要在命令行输入密码,无视它就行)

mysql -proot -e "create database test;"

创建500万测试数据

sysbench --test=oltp --oltp-table-size=5000000 --oltp-table-name=t_test --mysql-table-engine=innodb --mysql-host=localhost --mysql-db=test --mysql-user=root --mysql-password=root prepare

运行测试

sysbench --test=oltp --oltp-table-size=5000000 --oltp-table-name=t_test --mysql-table-engine=innodb --mysql-host=localhost --mysql-db=test --mysql-user=root --mysql-password=root run

清除测试数据

sysbench --test=oltp --oltp-table-size=5000000 --oltp-table-name=t_test --mysql-table-engine=innodb --mysql-host=localhost --mysql-db=test --mysql-user=root --mysql-password=root cleanup

一般我们比较关心:

1
2
3
transactions:                        10000  (514.48 per sec.)

read/write requests: 190000 (9775.14 per sec.)

这代表每秒能处理的事务数,以及每秒的读写次数。

附上我的测试结果:

1
2
3
4
5
6
7
8
9
10
11
1G内存VPS:
OLTP test statistics:
queries performed:
read: 140000
write: 50000
other: 20000
total: 210000
transactions: 10000 (88.77 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 190000 (1686.65 per sec.)
other operations: 20000 (177.54 per sec.)

1G内存VPS:
1
2
3
4
5
6
7
8
9
10
OLTP test statistics:
queries performed:
read: 140000
write: 50000
other: 20000
total: 210000
transactions: 10000 (115.97 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 190000 (2203.47 per sec.)
other operations: 20000 (231.94 per sec.)

512M内存VPS:
1
2
3
4
5
6
7
8
9
10
OLTP test statistics:
queries performed:
read: 140000
write: 50000
other: 20000
total: 210000
transactions: 10000 (81.30 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 190000 (1544.72 per sec.)
other operations: 20000 (162.60 per sec.)

阿里云1G内存VPS:
1
2
3
4
5
6
7
8
9
10
OLTP test statistics:
queries performed:
read: 140000
write: 50000
other: 20000
total: 210000
transactions: 10000 (158.12 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 190000 (3004.20 per sec.)
other operations: 20000 (316.23 per sec.)

鄂ICP备14007840号-1