标签:values work nts int 数据库 workload 文件 rop pen
主要总结Yahoo的数据库测试项目YCSB的使用(针对redis)。
github网址:https://github.com/brianfrankcooper/YCSB
需要安装
直接下载编译好的版本(不推荐)
1 | curl -O --location https://github.com/brianfrankcooper/YCSB/releases/download/0.15.0/ycsb-0.15.0.tar.gz |
使用java或者maven编译
1 | git clone http://github.com/brianfrankcooper/YCSB.git |
详细说明:https://github.com/brianfrankcooper/YCSB/wiki/Running-a-Workload
运行workload一共有六个部分
简要的说,就是创建名为usertable
的表,因为ycsb默认的是对usertable
进行相关操作。
而对于redis,则不需要相关的操作。
YCSB的操作是通过DB interface来实现的。最基本的DB interface是com.yahoo.ycsb.BasicDB
,会将输出输出到System.out
里。可以通过继承DB interface来自定义DB interface,也可以使用原有的DB interface。
当前版本提供了六种workload
This workload has a mix of 50/50 reads and writes. An application example is a session store recording recent actions.
This workload has a 95/5 reads/write mix. Application example: photo tagging; add a tag is an update, but most operations are to read tags.
This workload is 100% read. Application example: user profile cache, where profiles are constructed elsewhere (e.g., Hadoop).
In this workload, new records are inserted, and the most recently inserted records are the most popular. Application example: user status updates; people want to read the latest.
In this workload, short ranges of records are queried, instead of individual records. Application example: threaded conversations, where each scan is for the posts in a given thread (assumed to be clustered by thread id).
In this workload, the client will read a record, modify it, and write back the changes. Application example: user database, where user records are read and modified by the user or to record user activity.
当然也可以自定义workload:https://github.com/brianfrankcooper/YCSB/wiki/Implementing-New-Workloads
一般常用的workload property如fieldcount
,fieldlength
,requestdistribution
等。
全部properties如下:
The property files used with the core workload generator can specify values for the following properties:
主要是
-threads
: the number of client threads. -target
: the target number of operations per second. -s
: status.十秒打印一次状态需要指定redis.host
,redis.port
。(可以指定redis.password
和redis.cluster
)
以上参数也可以在命令中指定,比如
1 | ./bin/ycsb load redis -s -P workloads/workloada -p "redis.host=127.0.0.1" -p "redis.port=6379" |
同理
1 | ./bin/ycsb run redis -s -P workloads/workloada -p "redis.host=127.0.0.1" -p "redis.port=6379" |
issue网址:https://github.com/brianfrankcooper/YCSB/issues/587
ycsb对key命名规则是两种,hashed
模式会生成user
加固定长度的一串hash值,而ordered
模式会按照user
加顺序的方式来命名。
1 | insertorder=hashed # user6284781860667377211, user8517097267634966620, user1820151046732198393 |
错误类似于
1 | redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: Read timed out |
当数据量变大之后,延时可能会变成几秒,而Jedis默认的是2
秒的超时限制。
修改redis的src文件夹的RedisClient.java
将
jedis = new Jedis(host, port);
修改为
jedis = new Jedis(host, port, 10000);
即从默认的2秒上升为10秒。
标签:values work nts int 数据库 workload 文件 rop pen
原文地址:https://www.cnblogs.com/lijianming180/p/12251327.html