環(huán)境
Yahoo! Cloud System Benchmark (YCSB)性能測試工具
1.下載和安裝
1.下載并解壓
wget https://github.com/brianfrankcooper/YCSB/releases/download/0.15.0/ycsb-0.15.0.tar.gz
tar xfvz ycsb-0.15.0.tar.gz
cd ycsb-0.15.0
2.測試是否可以運行
bin/ycsb.sh load basic -P workloads/workloada
bin/ycsb.sh run basic -P workloads/workloada
3.執(zhí)行測試
## 500線程測試 MongoDB
/home/ycsb-0.15.0/bin/ycsb.sh run mongodb -P /home/ycsb-0.15.0/workloads/workloadc -threads 500
## 500線程測試 Redis
## https://github.com/brianfrankcooper/YCSB/tree/master/redis
## /home/ycsb-0.15.0/bin/ycsb.sh run redis -P /home/ycsb-0.15.0/workloads/workloadc -p redis.host=localhost -p redis.port=6379 -threads 500
## 500線程測試 Redis Cluster
## /home/ycsb-0.15.0/bin/ycsb.sh run redis -P /home/ycsb-0.15.0/workloads/workloadc -p redis.host=192.168.30.35 -p redis.port=6379 -threads 5 -p redis.cluster=true
/home/ycsb-0.15.0/bin/ycsb.sh load redis -P /home/ycsb-0.15.0/workloads/workloadc \
-p redis.host=192.168.30.35 \
-p redis.host=192.168.30.36 \
-p redis.host=192.168.30.37 \
-p redis.host=192.168.30.38 \
-p redis.host=192.168.30.39 \
-p redis.host=192.168.30.40 \
-p redis.port=6379 -threads 5 -p redis.cluster=true
/home/ycsb-0.15.0/bin/ycsb.sh run redis -P /home/ycsb-0.15.0/workloads/workloadc \
-p redis.host=192.168.30.35 \
-p redis.host=192.168.30.36 \
-p redis.host=192.168.30.37 \
-p redis.host=192.168.30.38 \
-p redis.host=192.168.30.39 \
-p redis.host=192.168.30.40 \
-p redis.port=6379 -threads 5 -p redis.cluster=true
4.配置文件示例(本示例為寫入測試)
cat <<\EOF >/home/ycsb-0.15.0/workloads/workloadc
## 測試數(shù)據(jù)集的記錄條數(shù)
recordcount=500000
## 測試過程中執(zhí)行的操作總數(shù)
operationcount=500000
## 實現(xiàn)類
workload=com.yahoo.ycsb.workloads.CoreWorkload
# workload=com.yahoo.ycsb.db.MongoDbClient
# mongodb.url=mongodb://192.168.30.161:27017
mongodb.url=mongodb://192.168.30.44:27200
## 查詢時是否讀取記錄的所有字段(默認為 true)
readallfields=true
## 讀取操作比例(例如:0.5)
readproportion=0
## 插入操作比例
insertproportion=1
## 更新操作比例
updateproportion=0
## 掃描操作比例
scanproportion=0
## 請求分布模式
requestdistribution=zipfian
EOF
2.命令參數(shù)
## 指定需要讀取的配置文件(可以同時指定多個)
-P workloads/workloada
-P workloads/workloada -P large.dat
## 指定每2000毫秒輸出一次統(tǒng)計結果
## 報告的時間點數(shù)據(jù)僅為前一個2000毫秒的平均值
-p measurementtype=timeseries -p timeseries.granularity=2000
## 指定 10 個線程
-threads 10
## 每秒總共 100 次操作
-target 100
3.寫入配置文件
## 指定 10 個線程
threadcount=10
## 每秒總共 100 次操作
target=100
## 指定每2000毫秒輸出一次統(tǒng)計結果
## 報告的時間點數(shù)據(jù)僅為前一個2000毫秒的平均值
measurementtype=timeseries
timeseries.granularity=2000
4.輸出結果說明
[OVERALL],RunTime(ms), 10110 ## 總共運行時間10.11秒
[OVERALL],Throughput(ops/sec), 98.91196834817013 ## 平均吞吐量98.9次/秒
[UPDATE], Operations, 491 ## 有491個更新操作
[UPDATE], AverageLatency(ms), 0.054989816700611 ## 平均響應時間(毫秒)
[UPDATE], MinLatency(ms), 0 ## 最小響應時間(毫秒)(1秒=1000毫秒)
[UPDATE], MaxLatency(ms), 1 ## 最大響應時間(毫秒)
[UPDATE], 95thPercentileLatency(ms), 1
[UPDATE], 99thPercentileLatency(ms), 1
[UPDATE], Return=0, 491 ## 有491個更新操作返回0(0=成功)
[UPDATE], 0, 464 ## 有464個更新操作在1ms內(nèi)完成
[UPDATE], 1, 27 ## 有27個更新操作在1-2ms內(nèi)完成
[UPDATE], 2, 0
[UPDATE], 3, 0
[UPDATE], 4, 0
5.實測結果
CPU:8核
內(nèi)存:24G
硬盤:SSD存儲
[20:04:10 root@mongodb-test-oneonde ~ $]mongostat
insert query update delete getmore command dirty used flushes vsize res qrw arw net_in net_out conn time
28763 *0 *0 *0 0 2|0 2.2% 2.9% 0 2.02G 971M 0|0 1|0 37.1m 1.36m 104 Aug 1 20:04:13.302
26714 *0 *0 *0 0 2|0 2.6% 3.3% 0 2.02G 971M 0|1 1|0 34.5m 1.27m 104 Aug 1 20:04:14.302
28496 *0 *0 *0 0 3|0 2.9% 3.6% 0 2.02G 971M 0|0 1|0 36.8m 1.35m 104 Aug 1 20:04:15.301
27726 *0 *0 *0 0 2|0 3.3% 3.9% 0 2.02G 971M 0|0 1|2 35.8m 1.31m 104 Aug 1 20:04:16.301
26610 *0 *0 *0 0 1|0 3.6% 4.3% 0 2.02G 971M 0|3 1|0 34.4m 1.26m 104 Aug 1 20:04:17.302
26036 *0 *0 *0 0 2|0 3.9% 4.6% 0 2.02G 971M 0|0 1|0 33.6m 1.24m 104 Aug 1 20:04:18.300
28221 *0 *0 *0 0 2|0 4.2% 4.9% 0 2.02G 971M 0|1 1|0 36.4m 1.33m 104 Aug 1 20:04:19.300
28502 *0 *0 *0 0 1|0 4.6% 5.3% 0 2.02G 971M 0|0 1|1 36.8m 1.35m 104 Aug 1 20:04:20.303
28430 *0 *0 *0 0 2|0 4.9% 5.6% 0 2.02G 971M 0|0 1|1 36.7m 1.34m 104 Aug 1 20:04:21.301
26332 *0 *0 *0 0 2|0 3.5% 5.9% 0 2.02G 971M 0|0 1|1 34.0m 1.25m 104 Aug 1 20:04:22.300
[OVERALL], RunTime(ms), 19632
[OVERALL], Throughput(ops/sec), 25468.622656886717
[TOTAL_GCS_PS_Scavenge], Count, 10
[TOTAL_GC_TIME_PS_Scavenge], Time(ms), 80
[TOTAL_GC_TIME_%_PS_Scavenge], Time(%), 0.40749796251018744
[TOTAL_GCS_PS_MarkSweep], Count, 0
[TOTAL_GC_TIME_PS_MarkSweep], Time(ms), 0
[TOTAL_GC_TIME_%_PS_MarkSweep], Time(%), 0.0
[TOTAL_GCs], Count, 10
[TOTAL_GC_TIME], Time(ms), 80
[TOTAL_GC_TIME_%], Time(%), 0.40749796251018744
[CLEANUP], Operations, 500
[CLEANUP], AverageLatency(us), 15.93
[CLEANUP], MinLatency(us), 0
[CLEANUP], MaxLatency(us), 7803
[CLEANUP], 95thPercentileLatency(us), 1
[CLEANUP], 99thPercentileLatency(us), 3
[INSERT], Operations, 500000
[INSERT], AverageLatency(us), 19045.604576
[INSERT], MinLatency(us), 11296
[INSERT], MaxLatency(us), 169215
[INSERT], 95thPercentileLatency(us), 23743
[INSERT], 99thPercentileLatency(us), 42079
[INSERT], Return=OK, 500000
附錄:
GitHub主頁:https://github.com/brianfrankcooper/YCSB
最新發(fā)行版:https://github.com/brianfrankcooper/YCSB/releases/latest