主要总结Yahoo的数据库测试项目YCSB的使用(针对redis)。

github网址:https://github.com/brianfrankcooper/YCSB

  • 需要安装

    • java
    • maven
  • 直接下载编译好的版本(不推荐)

    1
    2
    3
    curl -O --location 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
  • 使用java或者maven编译

    1
    2
    3
    4
    5
    6
    git clone http://github.com/brianfrankcooper/YCSB.git
    cd YCSB
    只安装redis测试部分
    mvn -pl com.yahoo.ycsb:redis-binding -am clean package
    安装全部测试功能
    mvn clean package

概述

详细说明:https://github.com/brianfrankcooper/YCSB/wiki/Running-a-Workload

运行workload一共有六个部分

  • 设置数据库
  • 选择合适的DB interface
  • 选择合适的负载
  • 选择合适的runtime parameters
  • load选择好的workload
  • run选择好的workload

设置数据库

简要的说,就是创建名为usertable的表,因为ycsb默认的是对usertable进行相关操作。

而对于redis,则不需要相关的操作。

选择合适的DB interface

YCSB的操作是通过DB interface来实现的。最基本的DB interface是com.yahoo.ycsb.BasicDB,会将输出输出到System.out里。可以通过继承DB interface来自定义DB interface,也可以使用原有的DB interface。

选择合适的workload

当前版本提供了六种workload

Workload A: Update heavy workload

This workload has a mix of 50/50 reads and writes. An application example is a session store recording recent actions.

Workload B: Read mostly workload

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.

Workload C: Read only

This workload is 100% read. Application example: user profile cache, where profiles are constructed elsewhere (e.g., Hadoop).

Workload D: Read latest workload

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.

Workload E: Short ranges

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).

Workload F: Read-modify-write

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

当然也可以自定义workload:https://github.com/brianfrankcooper/YCSB/wiki/Implementing-New-Workloads

一般常用的workload property如fieldcountfieldlengthrequestdistribution等。

全部properties如下:

The property files used with the core workload generator can specify values for the following properties:

  • fieldcount: the number of fields in a record (default: 10)
  • fieldlength: the size of each field (default: 100)
  • readallfields: should reads read all fields (true) or just one (false) (default: true)
  • readproportion: what proportion of operations should be reads (default: 0.95)
  • updateproportion: what proportion of operations should be updates (default: 0.05)
  • insertproportion: what proportion of operations should be inserts (default: 0)
  • scanproportion: what proportion of operations should be scans (default: 0)
  • readmodifywriteproportion: what proportion of operations should be read a record, modify it, write it back (default: 0)
  • requestdistribution: what distribution should be used to select the records to operate on – un 大专栏  YCSB项目学习iform, zipfian or latest (default: uniform)
  • maxscanlength: for scans, what is the maximum number of records to scan (default: 1000)
  • scanlengthdistribution: for scans, what distribution should be used to choose the number of records to scan, for each scan, between 1 and maxscanlength (default: uniform)
  • insertorder: should records be inserted in order by key (“ordered”), or in hashed order (“hashed”) (default: hashed)
  • operationcount: number of operations to perform. If set to zero then YCSB will run until maxexecutiontime is reached (which by default is indefinitely). Note that if your workload or command line parameters do not specify an operation count it will defualt to zero.
  • maxexecutiontime: maximum execution time in seconds. The benchmark runs until either the operation count has exhausted or the maximum specified time has elapsed, whichever is earlier. If unspecified the defualt is to run indefinitely.
  • table: the name of the table (default: usertable)
  • recordcount: number of records to load into the database initially (default: 0)
  • core_workload_insertion_retry_limit: number of attempts for any failed insert operation (default: 0)
  • core_workload_insertion_retry_interval: interval between retries, in seconds (default: 3)

选择合适的runtime parameter

主要是

  • -threads : the number of client threads.
  • -target : the target number of operations per second.
  • -s : status.十秒打印一次状态

load data

需要指定redis.hostredis.port。(可以指定redis.passwordredis.cluster

以上参数也可以在命令中指定,比如

1
./bin/ycsb load redis -s -P workloads/workloada -p "redis.host=127.0.0.1" -p "redis.port=6379"

run data

同理

1
./bin/ycsb run redis -s -P workloads/workloada -p "redis.host=127.0.0.1" -p "redis.port=6379"

一些注意事项

ycsb不支持对key的长度的修改

issue网址:https://github.com/brianfrankcooper/YCSB/issues/587

ycsb对key命名规则是两种,hashed模式会生成user加固定长度的一串hash值,而ordered模式会按照user加顺序的方式来命名。

1
2
insertorder=hashed      # user6284781860667377211, user8517097267634966620, user1820151046732198393
insertorder=ordered # user1, user2, user3032

ycsb运行时错误:Read time out

错误类似于

1
2
3
4
5
6
redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: Read timed out

at redis.clients.jedis.Protocol.process(Protocol.java:79)
at redis.clients.jedis.Protocol.read(Protocol.java:131)
at redis.clients.jedis.Connection.getIntegerReply(Connection.java:188)
at redis.clients.jedis.Jedis.sismember(Jedis.java:1266)

当数据量变大之后,延时可能会变成几秒,而Jedis默认的是2秒的超时限制。

修改redis的src文件夹的RedisClient.java

jedis = new Jedis(host, port);

修改为

jedis = new Jedis(host, port, 10000);

即从默认的2秒上升为10秒。

参考资料

YCSB项目学习的更多相关文章

  1. 转:从开源项目学习 C 语言基本的编码规则

    从开源项目学习 C 语言基本的编码规则 每个项目都有自己的风格指南:一组有关怎样为那个项目编码约定.一些经理选择基本的编码规则,另一些经理则更偏好非常高级的规则,对许多项目而言则没有特定的编码规则,项 ...

  2. 中小研发团队架构实践之生产环境诊断工具WinDbg 三分钟学会.NET微服务之Polly 使用.Net Core+IView+Vue集成上传图片功能 Fiddler原理~知多少? ABP框架(asp.net core 2.X+Vue)模板项目学习之路(一) C#程序中设置全局代理(Global Proxy) WCF 4.0 使用说明 如何在IIS上发布,并能正常访问

    中小研发团队架构实践之生产环境诊断工具WinDbg 生产环境偶尔会出现一些异常问题,WinDbg或GDB是解决此类问题的利器.调试工具WinDbg如同医生的听诊器,是系统生病时做问题诊断的逆向分析工具 ...

  3. PHP项目学习——控件

    主要是在项目学习中总结的一些东西 动态效果 flashbar滚动条,增加动态效果,直接嵌入html中 <!--flash滚动条--> <object classid="cl ...

  4. PHP项目学习2

    通过<PHP项目学习1>基本上可以了解项目的大致结构.内容,现在直接从代码入手,开始coding吧. 现在部署环境中建立一个myonline的文件夹,便于放置我们的项目

  5. Spring Boot 项目学习 (四) Spring Boot整合Swagger2自动生成API文档

    0 引言 在做服务端开发的时候,难免会涉及到API 接口文档的编写,可以经历过手写API 文档的过程,就会发现,一个自动生成API文档可以提高多少的效率. 以下列举几个手写API 文档的痛点: 文档需 ...

  6. Spring Boot 项目学习 (三) Spring Boot + Redis 搭建

    0 引言 本文主要介绍 Spring Boot 中 Redis 的配置和基本使用. 1 配置 Redis 1. 修改pom.xml,添加Redis依赖 <!-- Spring Boot Redi ...

  7. Spring Boot 项目学习 (一) 项目搭建

    0 引言 本文主要记录借用Idea 开发环境下,搭建 Spring Boot 项目框架的过程. 1 系列文档目录 Spring Boot 项目学习 (一) 项目搭建 Spring Boot 项目学习 ...

  8. Spring Boot 项目学习 (二) MySql + MyBatis 注解 + 分页控件 配置

    0 引言 本文主要在Spring Boot 基础项目的基础上,添加 Mysql .MyBatis(注解方式)与 分页控件 的配置,用于协助完成数据库操作. 1 创建数据表 这个过程就暂时省略了. 2 ...

  9. 优秀的github项目学习

    优秀的github项目学习 后期会陆续添加遇到的优秀项目 https://github.com/chaijunkun

随机推荐

  1. Regex: positive lookahead 先行断言____ 后行断言(lookbehind)

    先行断言: /a(?=b)/  ,positive lookahead,a的后方必须是b才行 /a(?!b)/   ,negative lookahead,a的后方必须不是b才能匹配 如下图示:  来 ...

  2. 设置PPT版式

    1.点击视图,幻灯片母版 2.选中某个PPT母版,可进行编辑

  3. 七种常见经典排序算法总结(C++实现)

    排序算法是非常常见也非常基础的算法,以至于大部分情况下它们都被集成到了语言的辅助库中.排序算法虽然已经可以很方便的使用,但是理解排序算法可以帮助我们找到解题的方向. 1. 冒泡排序 (Bubble S ...

  4. 算法笔记 4.4 贪心 问题 A: 看电视

    问题 A: 看电视 题目描述 暑假到了,小明终于可以开心的看电视了.但是小明喜欢的节目太多了,他希望尽量多的看到完整的节目. 现在他把他喜欢的电视节目的转播时间表给你,你能帮他合理安排吗? 输入 输入 ...

  5. scala编程(六)——函数式对象

    Rational 的式样书 分数:rational number 是一种可以表达为比率 d n 的数字,这里的 n 和 d 是数字,其中 d 不能为零.n 被称作是分子:numerator,d 被称作 ...

  6. AI动作捕捉技术,会让制造业大幅度降低成本吗?

    现代动作捕捉系统应该是起源于100多年前的动画工业,通过一种叫做"动态遮罩或影像描摹"的技术,动画师们可以获得流畅的.栩栩如生的动作:后来到了20世纪80年代,动画师们设计出带有活 ...

  7. linux的nohup命令的用法(后台运行程序命令)

    linux的nohup命令的用法. 在应用Unix/Linux时,我们一般想让某个程序在后台运行,于是我们将常会用 & 在程序结尾来让程序自动运行.比如我们要运行mysql在后台: /usr/ ...

  8. Struts2加载自定义库注意事项

    新建Struts2项目,添加Struts2的jar包时,往往通过导入自定义库的方式,导入自定义库时,有个地方必须要设置,否则项目无法正常执行,如图所示: 必须要按照上述方式对自定义库进行加载!

  9. 量化预测质量之分类报告 sklearn.metrics.classification_report

    classification_report的调用为:classification_report(y_true, y_pred, labels=None, target_names=None, samp ...

  10. Linux下停止和启动redis

    1.停止redis (进入redis安装目录) [root@JDu4e00u53f7 redis]# ./bin/redis-cli shutdown 2. 启动redis [root@JDu4e00 ...