ycsb是yahoo開源的一個多功能壓測軟件,支持mysql mongodb redis hbase等多種軟件。mysql
官方地址:https://github.com/brianfrankcooper/YCSBgit
本次這裏咱們以ycsb壓測redis爲例。
github
tar xf ycsb-0.15.0.tar.gz -C /usr/local/golang
cd /usr/local/ycsb-0.15.0redis
其中,workloads 目錄下是各個壓測模板文件
sql
# cat workloads/workload_read 這是我寫的一個純讀取的場景的壓測模板mongodb
recordcount=1000000 # 總共的操做條數 operationcount=1000000 # 總共操做的次數 workload=com.yahoo.ycsb.workloads.CoreWorkload readallfields=true # 在讀取的時候,是否須要讀取全部字段 readproportion=1 # 讀取比例 updateproportion=0 # update比例 scanproportion=0 insertproportion=0 requestdistribution=zipfian
開始壓測遠程的一個codis-proxybash
./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
############ide
此外,國內的pingcap的唐劉大佬也寫了一個go-ycsb的軟件,功能上與ycsb相似。oop
編譯方式能夠看這個: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