有奖捉虫:办公协同&微信生态&物联网文档专题 HOT
本文主要介绍针对腾讯云数据库 MongoDB 实例进行标准化的性能测试,测试得出的性能数据仅供用户参考。

测试环境

测试时间:2020年8月。
客户端配置:云服务器 CVM 规格为8核32GB。经验证,实例规格较小时,一个8核32GB的 CVM 压测即可将副本实例 CPU 打满,且效果比多个 CVM 更好一些,当一个 CVM 压不到100%时,可用4个 CVM 均摊并发线程数来压测。
测试对象:MongoDB 4.0 实例(副本集架构)。

测试工具

测试场景

准备数据约10GB,对于每一种规格,用 YCSB 分别测试 0.5read/0.5update 和 0.95read/0.05update 场景下的 throughput(ops/sec)、RAL(us) 平均读时延、WAL(us) 平均写时延,主要关注100和200并发两种情况下的性能数据。

时延

CVM 到 MongoDB 实例的平均时延为0.35ms。n时延:Minimum = 0.30ms、Maximum = 0.44ms、Average = 0.35ms

相关命令

1. 准备数据 (约10GB)
nohup ./ycsb-0.15.0/bin/ycsb load mongodb -s -P workloads/workloada
-p mongodb.url=mongodb://mongouser:password@10.xx.xx.30:27017,10.xx.xx.28:27017,10.xx.xx.5:27017/admin?w=0 -p table=test -threads 300 -p recordcount=10000000>loadlog.txt &
2. 0.5read/0.5update
nohup ./ycsb-0.15.0/bin/ycsb run mongodb -s -P workloads/workloada -p mongodb.url=mongodb://mongouser: password @10.xx.xx.30:27017,10.xx.xx.28:27017,10.xx.xx.5:27017/admin?w=0 -p table=test -p recordcount=10000000 -p readproportion=0.5 -p updateproportion=0.5 -p insertproportion=0 -p operationcount=100000 -threads 100 >runlog.txt &
3. 0.95read/0.05update
nohup ./ycsb-0.15.0/bin/ycsb run mongodb -s -P workloads/workloada -p mongodb.url=mongodb://mongouser: password @10.xx.xx.30:27017,10.xx.xx.28:27017,10.xx.xx.5:27017/admin?w=0 -p table=test -p recordcount=10000000 -p readproportion=0.95 -p updateproportion=0.05 -p insertproportion=0 -p operationcount=100000 -threads 100 >runlog.txt &
说明
-p operationcount=100000根据具体执行时间动态调整,需要保证执行时间在二十分钟以上,否则时间过短没有代表性。
?w=0中的 w 表示 write concern。
w:1(应答式写入)要求确认操作已经传播到指定的单个 mongod 实例或副本集主实例,缺省为1。
w:0(非应答式写入)不返回任何响应,所以无法知道写入是否成功,但对于尝试向已关闭的套接字写入或者网络故障会返回异常信息。
w:>1(用于副本集环境)该值用于设定写入节点的数目,包括主节点。

测试数据

读&更新比50:50

MongoDB 规格
threads
throughput(ops/sec)
RAL(us)
WAL(us)
CPU 利用率
2核4GB
100
3188
24091
38254
100%
2核4GB
200
5510
34475
38022
100%
4核8GB
100
7058
8355
19887
100%
4核8GB
200
13590
14391
14983
100%
6核16GB
100
8970
22132
51
100%
6核16GB
200
10041
28696
10966
100%
12核32GB
100
29462
6727
35
100%
12核32GB
200
47815
4673
3681
100%
24核64GB
100
107047
1826
33
100%
24核64GB
200
51046
7802
27
100%
24核128GB
100
130811
1486
32
100%
24核128GB
200
49274
8054
27
100%
32核240GB
100
154253
1254
32
100%
32核240GB
200
52148
8243
1108
100%
48核512GB
100
174284
1103
28
100%
48核512GB
200
121713
3237
32
100%

读&更新比95:5

MongoDB 规格
threads
throughput(ops/sec)
RAL(us)
WAL(us)
CPU 利用率
2核4GB
100
2738
38216
178
100%
2核4GB
200
10093
20178
11561
100%
4核8GB
100
14380
6864
7631
100%
4核8GB
200
26459
7651
5369
100%
6核16GB
100
13707
7650
56
100%
6核16GB
200
45796
4383
3928
100%
12核32GB
100
115529
902
37
100%
12核32GB
200
56751
3658
31
100%
24核64GB
100
160227
668
29
100%
24核64GB
200
112755
1876
32
100%
24核128GB
100
159130
659
26
100%
24核128GB
200
112993
1936
32
100%
32核240GB
100
167518
634
28
74%
32核240GB
200
172424
1244
35
100%
48核512GB
100
173768
608
31
50%
48核512GB
200
211986
1012
33
85%