ycsb是yahoo开源的一个多功能压测软件,支持mysql mongodb redis hbase等多种软件。
官方地址:https://github.com/brianfrankcooper/YCSB
本次这里我们以ycsb压测redis为例。
tar xf ycsb-0.15.0.tar.gz -C /usr/local/
cd /usr/local/ycsb-0.15.0
其中,workloads 目录下是各个压测模板文件
# cat workloads/workload_read 这是我写的一个纯读取的场景的压测模板
recordcount=1000000 # 总共的操作条数
operationcount=1000000 # 总共操作的次数
workload=com.yahoo.ycsb.workloads.CoreWorkload
readallfields=true # 在读取的时候,是否需要读取所有字段
readproportion=1 # 读取比例
updateproportion=0 # update比例
scanproportion=0
insertproportion=0
requestdistribution=zipfian
开始压测远程的一个codis-proxy
./bin/ycsb load redis -s -P workloads/workload_read -p redis.host=192.168.2.4 -p redis.port=19000 -threads 10 造数据(这步涉及到写操作)
./bin/ycsb run redis -s -P workloads/workload_read -p redis.host=192.168.2.4 -p redis.port=19000 -threads 10 测试纯读取测试
单次测试的结果:
2019-07-26 00:36:12:194 80 sec: 1000000 operations; 9884.21 current ops/sec; [READ: Count=7503, Max=9047, Min=411, Avg=826.87, 90=1048, 99=2931, 99.9=7791, 99.99=8975] [CLEANUP: Count=10, Max=1771, Min=52, Avg=235.2, 90=92, 99=1771, 99.9=1771, 99.99=1771]
[OVERALL], RunTime(ms), 80760
[OVERALL], Throughput(ops/sec), 12382.367508667658
[TOTAL_GCS_PS_Scavenge], Count, 278
[TOTAL_GC_TIME_PS_Scavenge], Time(ms), 309
[TOTAL_GC_TIME_%_PS_Scavenge], Time(%), 0.3826151560178306
[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, 278
[TOTAL_GC_TIME], Time(ms), 309
[TOTAL_GC_TIME_%], Time(%), 0.3826151560178306
[READ], Operations, 1000000
[READ], AverageLatency(us), 800.371762
[READ], MinLatency(us), 381
[READ], MaxLatency(us), 65087
[READ], 95thPercentileLatency(us), 1163
[READ], 99thPercentileLatency(us), 2089
[READ], Return=OK, 1000000
[CLEANUP], Operations, 10
[CLEANUP], AverageLatency(us), 235.2
[CLEANUP], MinLatency(us), 52
[CLEANUP], MaxLatency(us), 1771
[CLEANUP], 95thPercentileLatency(us), 1771
[CLEANUP], 99thPercentileLatency(us), 1771
此外,国内的pingcap的唐刘大佬也写了一个go-ycsb的软件,功能上与ycsb类似。
编译方式可以看这个:https://github.com/pingcap/go-ycsb
yum install golang
mkdir /home/gocode/
echo 'export GOPATH=/home/gocode/' >> /root/.bashrc
source /root/.bashrc
git clone https://github.com/pingcap/go-ycsb.git $GOPATH/src/github.com/pingcap/go-ycsb
cd $GOPATH/src/github.com/pingcap/go-ycsb
make
稍等片刻即可完成编译。
编译完成后,用法和 ycsb基本上一样的,压测redis如下写法:
load:
./bin/go-ycsb load redis -P workloads/workload_dba -p redis.mode=single -p redis.addr=192.168.2.4:19000
run:
./bin/go-ycsb run redis -P workloads/workload_dba -p redis.mode=single -p redis.addr=192.168.2.4:19000