mysql存储性能测试

本次安装是在机械硬盘上
用的mysql 5.7.29版本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# mysqlslap 参数
-concurrency代表并发数量,多个可以用逗号隔开,concurrency=10,50,100, 并发连接线程数分别是10、50、100个并发。
--engines代表要测试的引擎,可以有多个,用分隔符隔开。
--iterations代表要运行这些测试多少次。
--auto-generate-sql 代表用系统自己生成的SQL脚本来测试。
--auto-generate-sql-load-type 代表要测试的是读还是写还是两者混合的(read,write,update,mixed)
--number-of-queries 代表总共要运行多少次查询。每个客户运行的查询数量可以用查询总数/并发数来计算。
--debug-info 代表要额外输出CPU以及内存的相关信息。
--number-int-cols :创建测试表的 int 型字段数量
--auto-generate-sql-add-autoincrement : 代表对生成的表自动添加auto_increment列,从5.1.18版本开始
--number-char-cols 创建测试表的 char 型字段数量。
--create-schema 测试的schema,MySQL中schema也就是database。
--query 使用自定义脚本执行测试,例如可以调用自定义的一个存储过程或者sql语句来执行测试。
--only-print 查看语句做了什么

local存储

三副本 高可用mysql

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# 第一次测试
[root@node4 ~]# mysqlslap -a --concurrency=100 --number-of-queries 1000 --iterations=1 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=mixed --engine=myisam,innodb --debug-info -uroot -pPassword -h 10.221.1.43 -P 30267
Benchmark
Running for engine myisam
Average number of seconds to run all queries: 31.524 seconds
Minimum number of seconds to run all queries: 31.524 seconds
Maximum number of seconds to run all queries: 31.524 seconds
Number of clients running queries: 100
Average number of queries per client: 10

Benchmark
Running for engine innodb
Average number of seconds to run all queries: 1.679 seconds
Minimum number of seconds to run all queries: 1.679 seconds
Maximum number of seconds to run all queries: 1.679 seconds
Number of clients running queries: 100
Average number of queries per client: 10


User time 0.03, System time 0.14
Maximum resident set size 8520, Integral resident set size 0
Non-physical pagefaults 2560, Physical pagefaults 0, Swaps 0
Blocks in 0 out 0, Messages in 0 out 0, Signals 0
Voluntary context switches 4019, Involuntary context switches 20

# 第二次测试
[root@node4 ~]# mysqlslap -a --concurrency=10 --number-of-queries 1000 --iterations=1 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=mixed --engine=myisam,innodb --debug-info -uroot -pPassword -h 10.221.1.43 -P 30267
Benchmark
Running for engine myisam
Average number of seconds to run all queries: 39.956 seconds
Minimum number of seconds to run all queries: 39.956 seconds
Maximum number of seconds to run all queries: 39.956 seconds
Number of clients running queries: 10
Average number of queries per client: 100

Benchmark
Running for engine innodb
Average number of seconds to run all queries: 14.040 seconds
Minimum number of seconds to run all queries: 14.040 seconds
Maximum number of seconds to run all queries: 14.040 seconds
Number of clients running queries: 10
Average number of queries per client: 100


User time 0.03, System time 0.09
Maximum resident set size 5108, Integral resident set size 0
Non-physical pagefaults 1116, Physical pagefaults 0, Swaps 0
Blocks in 0 out 0, Messages in 0 out 0, Signals 0
Voluntary context switches 2366, Involuntary context switches 2

单副本 mysql

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# 第一次测试
[root@node4 ~]# mysqlslap -a --concurrency=100 --number-of-queries 1000 --iterations=1 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=mixed --engine=myisam,innodb --debug-info -uroot -pPassword -h 10.221.1.43 -P 31208
Benchmark
Running for engine myisam
Average number of seconds to run all queries: 1.065 seconds
Minimum number of seconds to run all queries: 1.065 seconds
Maximum number of seconds to run all queries: 1.065 seconds
Number of clients running queries: 100
Average number of queries per client: 10

Benchmark
Running for engine innodb
Average number of seconds to run all queries: 1.562 seconds
Minimum number of seconds to run all queries: 1.562 seconds
Maximum number of seconds to run all queries: 1.562 seconds
Number of clients running queries: 100
Average number of queries per client: 10


User time 0.02, System time 0.11
Maximum resident set size 6272, Integral resident set size 0
Non-physical pagefaults 2352, Physical pagefaults 0, Swaps 0
Blocks in 0 out 0, Messages in 0 out 0, Signals 0
Voluntary context switches 3734, Involuntary context switches 30

# 第二次测试
[root@node4 ~]# mysqlslap -a --concurrency=10 --number-of-queries 1000 --iterations=1 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=mixed --engine=myisam,innodb --debug-info -uroot -pPassword -h 10.221.1.43 -P 31208
Benchmark
Running for engine myisam
Average number of seconds to run all queries: 0.603 seconds
Minimum number of seconds to run all queries: 0.603 seconds
Maximum number of seconds to run all queries: 0.603 seconds
Number of clients running queries: 10
Average number of queries per client: 100

Benchmark
Running for engine innodb
Average number of seconds to run all queries: 8.066 seconds
Minimum number of seconds to run all queries: 8.066 seconds
Maximum number of seconds to run all queries: 8.066 seconds
Number of clients running queries: 10
Average number of queries per client: 100


User time 0.01, System time 0.08
Maximum resident set size 5120, Integral resident set size 0
Non-physical pagefaults 1116, Physical pagefaults 0, Swaps 0
Blocks in 0 out 0, Messages in 0 out 0, Signals 0
Voluntary context switches 2355, Involuntary context switches 11

longhorn

不推荐使用机械硬盘安装!!!(ps:初始化mysql用了10分钟才完成)
使用helm安装

单副本 mysql 机械硬盘

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# 第一次测试
[root@node4 ~]# mysqlslap -a --concurrency=100 --number-of-queries 1000 --iterations=1 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=mixed --engine=myisam,innodb --debug-info -uroot -pPassword -h 10.221.1.43 -P 30685
Benchmark
Running for engine myisam
Average number of seconds to run all queries: 1.077 seconds
Minimum number of seconds to run all queries: 1.077 seconds
Maximum number of seconds to run all queries: 1.077 seconds
Number of clients running queries: 100
Average number of queries per client: 10

Benchmark
Running for engine innodb
Average number of seconds to run all queries: 6.757 seconds
Minimum number of seconds to run all queries: 6.757 seconds
Maximum number of seconds to run all queries: 6.757 seconds
Number of clients running queries: 100
Average number of queries per client: 10


User time 0.03, System time 0.12
Maximum resident set size 6340, Integral resident set size 0
Non-physical pagefaults 2394, Physical pagefaults 0, Swaps 0
Blocks in 0 out 0, Messages in 0 out 0, Signals 0
Voluntary context switches 3847, Involuntary context switches 52


# 第二次测试
[root@node4 ~]# mysqlslap -a --concurrency=10 --number-of-queries 1000 --iterations=1 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=mixed --engine=myisam,innodb --debug-info -uroot -pPassword -h 10.221.1.43 -P 30685
Benchmark
Running for engine myisam
Average number of seconds to run all queries: 0.628 seconds
Minimum number of seconds to run all queries: 0.628 seconds
Maximum number of seconds to run all queries: 0.628 seconds
Number of clients running queries: 10
Average number of queries per client: 100

Benchmark
Running for engine innodb
Average number of seconds to run all queries: 63.204 seconds
Minimum number of seconds to run all queries: 63.204 seconds
Maximum number of seconds to run all queries: 63.204 seconds
Number of clients running queries: 10
Average number of queries per client: 100


User time 0.02, System time 0.09
Maximum resident set size 5112, Integral resident set size 0
Non-physical pagefaults 1118, Physical pagefaults 0, Swaps 0
Blocks in 0 out 0, Messages in 0 out 0, Signals 0
Voluntary context switches 2381, Involuntary context switches 11

单副本 mysql 固态硬盘

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# 第一次测试
[root@node4 ~]# mysqlslap -a --concurrency=100 --number-of-queries 1000 --iterations=1 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=mixed --engine=myisam,innodb --debug-info -uroot -pPassword -h 10.221.2.188 -P 31075
Benchmark
Running for engine myisam
Average number of seconds to run all queries: 0.164 seconds
Minimum number of seconds to run all queries: 0.164 seconds
Maximum number of seconds to run all queries: 0.164 seconds
Number of clients running queries: 100
Average number of queries per client: 10

Benchmark
Running for engine innodb
Average number of seconds to run all queries: 0.203 seconds
Minimum number of seconds to run all queries: 0.203 seconds
Maximum number of seconds to run all queries: 0.203 seconds
Number of clients running queries: 100
Average number of queries per client: 10


User time 0.02, System time 0.13
Maximum resident set size 6776, Integral resident set size 0
Non-physical pagefaults 2353, Physical pagefaults 1, Swaps 0
Blocks in 6144 out 0, Messages in 0 out 0, Signals 0
Voluntary context switches 3873, Involuntary context switches 12

# 第二次测试
[root@node4 ~]# mysqlslap -a --concurrency=10 --number-of-queries 1000 --iterations=1 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=mixed --engine=myisam,innodb --debug-info -uroot -pPassword -h 10.221.2.188 -P 31075
Benchmark
Running for engine myisam
Average number of seconds to run all queries: 0.065 seconds
Minimum number of seconds to run all queries: 0.065 seconds
Maximum number of seconds to run all queries: 0.065 seconds
Number of clients running queries: 10
Average number of queries per client: 100

Benchmark
Running for engine innodb
Average number of seconds to run all queries: 0.538 seconds
Minimum number of seconds to run all queries: 0.538 seconds
Maximum number of seconds to run all queries: 0.538 seconds
Number of clients running queries: 10
Average number of queries per client: 100


User time 0.01, System time 0.07
Maximum resident set size 5212, Integral resident set size 0
Non-physical pagefaults 1117, Physical pagefaults 0, Swaps 0
Blocks in 0 out 0, Messages in 0 out 0, Signals 0
Voluntary context switches 2312, Involuntary context switches 28

longhorn快照和备份

longhorn的备份可以推送对应的S3服务器上(比如minio),所以需要在进行备份之前设置好对应的备份存储服务器

在存储卷页面可以定制定时任务对存储卷进行快照和备份

  • 快照是当前时间点创建一个备份锚点,后续可以基于这个快照进行备份
  • 备份是直接把当前磁盘数据备份到对象存储上去

longhorn快照和备份

根据备份的数据重新在longhorn中创建一个旧数据的数据卷
根据需求我们可以通过两种方式来回滚数据

  • 通过恢复的旧数据卷创建新的PV/PVC,更新应用挂载的PVC来实现数据回滚
  • 通过删除目前的PVC,然后用旧数据卷创建成删除前的同名PV/PVC来实现数据的回滚(如果PV设置的是Delete策略,那么当前的数据会丢失)

Rook 1.5.5

使用Ceph作为底层分布式存储
不推荐使用机械硬盘安装!!!(ps:初始化mysql用了10多分钟才完成)
使用yaml文件进行安装

单副本 块存储 mysql

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# 第一次测试
[root@node4 ~]# mysqlslap -a --concurrency=100 --number-of-queries 1000 --iterations=1 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=mixed --engine=myisam,innodb --debug-info -uroot -pPassword -h 10.221.1.43 -P 32582
Benchmark
Running for engine myisam
Average number of seconds to run all queries: 1.037 seconds
Minimum number of seconds to run all queries: 1.037 seconds
Maximum number of seconds to run all queries: 1.037 seconds
Number of clients running queries: 100
Average number of queries per client: 10

Benchmark
Running for engine innodb
Average number of seconds to run all queries: 49.686 seconds
Minimum number of seconds to run all queries: 49.686 seconds
Maximum number of seconds to run all queries: 49.686 seconds
Number of clients running queries: 100
Average number of queries per client: 10


User time 0.02, System time 0.14
Maximum resident set size 6260, Integral resident set size 0
Non-physical pagefaults 2310, Physical pagefaults 0, Swaps 0
Blocks in 0 out 0, Messages in 0 out 0, Signals 0
Voluntary context switches 3648, Involuntary context switches 24


# 第二次测试
[root@node4 ~]# mysqlslap -a --concurrency=10 --number-of-queries 1000 --iterations=1 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=mixed --engine=myisam,innodb --debug-info -uroot -pPassword -h 10.221.1.43 -P 32582
Benchmark
Running for engine myisam
Average number of seconds to run all queries: 0.630 seconds
Minimum number of seconds to run all queries: 0.630 seconds
Maximum number of seconds to run all queries: 0.630 seconds
Number of clients running queries: 10
Average number of queries per client: 100

Benchmark
Running for engine innodb
Average number of seconds to run all queries: 109.171 seconds
Minimum number of seconds to run all queries: 109.171 seconds
Maximum number of seconds to run all queries: 109.171 seconds
Number of clients running queries: 10
Average number of queries per client: 100


User time 0.02, System time 0.08
Maximum resident set size 5120, Integral resident set size 0
Non-physical pagefaults 1115, Physical pagefaults 0, Swaps 0
Blocks in 0 out 0, Messages in 0 out 0, Signals 0
Voluntary context switches 2351, Involuntary context switches 4

单副本 文件系统 mysql
文件系统存储上mysql的初始化要比块存储快一些 大概8分钟左右

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# 第一次测试
[root@node4 ~]# mysqlslap -a --concurrency=100 --number-of-queries 1000 --iterations=1 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=mixed --engine=myisam,innodb --debug-info -uroot -pPassword -h 10.221.1.43 -P 32582
Benchmark
Running for engine myisam
Average number of seconds to run all queries: 1.413 seconds
Minimum number of seconds to run all queries: 1.413 seconds
Maximum number of seconds to run all queries: 1.413 seconds
Number of clients running queries: 100
Average number of queries per client: 10

Benchmark
Running for engine innodb
Average number of seconds to run all queries: 6.548 seconds
Minimum number of seconds to run all queries: 6.548 seconds
Maximum number of seconds to run all queries: 6.548 seconds
Number of clients running queries: 100
Average number of queries per client: 10


User time 0.03, System time 0.12
Maximum resident set size 6424, Integral resident set size 0
Non-physical pagefaults 2492, Physical pagefaults 0, Swaps 0
Blocks in 0 out 0, Messages in 0 out 0, Signals 0
Voluntary context switches 3961, Involuntary context switches 46


# 第二次测试
[root@node4 ~]# mysqlslap -a --concurrency=10 --number-of-queries 1000 --iterations=1 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=mixed --engine=myisam,innodb --debug-info -uroot -pPassword -h 10.221.1.43 -P 32582
Benchmark
Running for engine myisam
Average number of seconds to run all queries: 0.618 seconds
Minimum number of seconds to run all queries: 0.618 seconds
Maximum number of seconds to run all queries: 0.618 seconds
Number of clients running queries: 10
Average number of queries per client: 100

Benchmark
Running for engine innodb
Average number of seconds to run all queries: 42.528 seconds
Minimum number of seconds to run all queries: 42.528 seconds
Maximum number of seconds to run all queries: 42.528 seconds
Number of clients running queries: 10
Average number of queries per client: 100


User time 0.02, System time 0.08
Maximum resident set size 5120, Integral resident set size 0
Non-physical pagefaults 1118, Physical pagefaults 0, Swaps 0
Blocks in 0 out 0, Messages in 0 out 0, Signals 0
Voluntary context switches 2372, Involuntary context switches 5

Rook+Ceph快照和备份

JD

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# 第一次测试
[root@node4 ~]# mysqlslap -a --concurrency=100 --number-of-queries 1000 --iterations=1 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=mixed --engine=myisam,innodb --debug-info -ukwl -pPassword -h mysql-internet-cn-south-1-9a547542c65440d1.rds.jdcloud.com
Benchmark
Running for engine myisam
Average number of seconds to run all queries: 2.229 seconds
Minimum number of seconds to run all queries: 2.229 seconds
Maximum number of seconds to run all queries: 2.229 seconds
Number of clients running queries: 100
Average number of queries per client: 10

Benchmark
Running for engine innodb
Average number of seconds to run all queries: 5.380 seconds
Minimum number of seconds to run all queries: 5.380 seconds
Maximum number of seconds to run all queries: 5.380 seconds
Number of clients running queries: 100
Average number of queries per client: 10


User time 0.03, System time 0.16
Maximum resident set size 7508, Integral resident set size 0
Non-physical pagefaults 3219, Physical pagefaults 0, Swaps 0
Blocks in 0 out 0, Messages in 0 out 0, Signals 0
Voluntary context switches 4311, Involuntary context switches 36


# 第二次测试
[root@node4 ~]# mysqlslap -a --concurrency=10 --number-of-queries 1000 --iterations=1 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=mixed --engine=myisam,innodb --debug-info -ukwl -pPassword -h mysql-internet-cn-south-1-9a547542c65440d1.rds.jdcloud.com
Benchmark
Running for engine myisam
Average number of seconds to run all queries: 1.855 seconds
Minimum number of seconds to run all queries: 1.855 seconds
Maximum number of seconds to run all queries: 1.855 seconds
Number of clients running queries: 10
Average number of queries per client: 100

Benchmark
Running for engine innodb
Average number of seconds to run all queries: 1.316 seconds
Minimum number of seconds to run all queries: 1.316 seconds
Maximum number of seconds to run all queries: 1.316 seconds
Number of clients running queries: 10
Average number of queries per client: 100


User time 0.01, System time 0.09
Maximum resident set size 5116, Integral resident set size 0
Non-physical pagefaults 1232, Physical pagefaults 0, Swaps 0
Blocks in 0 out 0, Messages in 0 out 0, Signals 0
Voluntary context switches 2395, Involuntary context switches 11

总结

机械硬盘下耗时 LOCAL < CEPHFS < LONGHORN < CEPH RBD