YCSB压力测试工具

环境

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.执行测试

## 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
## 测试数据集的记录条数
recordcount=500000

## 测试过程中执行的操作总数
operationcount=500000

## 实现类
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.命令参数

## 指定需要读取的配置文件(可以同时指定多个)
-P workloads/workloada
-P workloads/workloada -P large.dat
## 指定每2000毫秒输出一次统计结果
## 报告的时间点数据仅为前一个2000毫秒的平均值
-p measurementtype=timeseries -p timeseries.granularity=2000
## 指定 10 个线程
-threads 10
## 每秒总共 100 次操作
-target 100

3.写入配置文件

## 指定 10 个线程
threadcount=10
## 每秒总共 100 次操作
target=100
## 指定每2000毫秒输出一次统计结果
## 报告的时间点数据仅为前一个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内完成
[UPDATE], 1, 27                                     ## 有27个更新操作在1-2ms内完成
[UPDATE], 2, 0
[UPDATE], 3, 0
[UPDATE], 4, 0

5.实测结果

CPU:8核
内存: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

最新发行版:https://github.com/brianfrankcooper/YCSB/releases/latest

你可能感兴趣的:(YCSB压力测试工具)