Aerospike C客户端函数库附带了一个benchmark工具,是使用C客户端函数库构建。 利用这个benchmark工具,能够:
以特定的读取比率向数据库写入数据与读取数据。改变客户端线程数,模拟客户端并发情况。从客户端的角度观察延迟的分布。在可以使用benchmark工具之前,需要安装“开发包”及其先决条件要求的包。
构建benchmark工具:
$ cd benchmarks
$ make
启动工具
$ make run
此命令将用默认的负载、以localhost为集群服务器地址启动benchmark,简要输出内容如下:
$ make run
./target/benchmarks -h 127.0.0.1 -p 3000
hosts: 127.0.0.1
port: 3000
namespace: test
set: testset
keys/records: 1000000
object spec: int
random values: false
minimum number of transactions: -1
workload: read 50% write 50%
threads: 16
max throughput: unlimited
read timeout: 0 ms
write timeout: 0 ms
max retries: 1
debug: false
latency: false
shared memory: false
read replica: master
read consistency level: one
write commit level: all
2014-11-06 11:43:29 INFO Read/write using 1000000 records
2014-11-06 11:43:29 INFO Start 16 generator threads
2014-11-06 11:43:30 INFO write(tps=10847 timeouts=0 errors=0) read(tps=10772 timeouts=0 errors=0) total(tps=21619 timeouts=0 errors=0)
2014-11-06 11:43:31 INFO write(tps=11477 timeouts=0 errors=0) read(tps=11271 timeouts=0 errors=0) total(tps=22748 timeouts=0 errors=0)
2014-11-06 11:43:32 INFO write(tps=11051 timeouts=0 errors=0) read(tps=10698 timeouts=0 errors=0) total(tps=21749 timeouts=0 errors=0)
随机读取/更新的键是1000000个。50%的读取请求,50%的写入请求。
更详细的工具属性,请使用如下命令查看:
$ ./target/benchmarks -u
Benchmark示例
示例1
连接127.0.0.1:3000,使用名称为test的namespace。使用1亿个键(键使用整型值,范围1~100000000)、名称为testbin的bin、bin值为50个字符的字符串。90%的读与10%的写入,20个并发线程。
$ ./target/benchmarks -h 127.0.0.1 -p 3000 -n test -k 100000000 -o S:50 -w RU,90 -z 20
示例2
连接127.0.0.1:3000,使用名称为test的namespace与名称为demoset的set。
使用1百万个键,1400个字符的字符串做为值。80%的读取与20%的写入,8个并发线程。限制每秒事务数为2500读写的超时时间50毫秒显示客户端延迟百分比为四栏:<=1ms, >1ms, >8ms, >64ms。
$ ./target/benchmarks -h 127.0.0.1 -p 3000 -n test -s demoset -k 1000000 -o S:1400 -g 2500 -w RU,80 -z 8 -L 4,3