SlideShare a Scribd company logo
1 of 13
Download to read offline
合理配置和使用redis
异步请求提高并发能力
利用hashes结构优化存储
同步与异步客户端性能对比
Redis异步请求方式
 Nio:lettuce
 socket pipeline:jedis
tips:
redis的异步请求全都是基于客户端的实现,redis服务端是
完全串行的,通讯协议设计也不支持异步,这里所说的异
步都是基于保证单个连接上的串行请求顺序来保证可靠异
步。
Lettuce vs jedis
可以将更多的运算资源分配给具体
的handler,减少io等待延时
对于可简单批处理的任务更
加友好
 Lettuce nio异步
 基于java nio 单线程多连
接并发
 Handler线程池与worker
线程池独立
 Jedis socket pipeline
 基于连接池 pipeline封装
实现并发
 以jedis对象为单元处理批
量请求,每一个连接占用
单独线程
Lettuce vs jedis
Lettuce:
Read : 15k ~ 17k kvs/s
Write : 23k ~ 25k kvs/s
Jedis:
Read : 20k ~ 25k kvs/s
Write : 30k ~ 32k kvs/s
 同步客户端
 10M kvs,
key int 0 ~ 10M ,value string “65533”
 Read :10k keys,10 times
 Write :10k keys, 10 times
Lettuce vs jedis
Lettuce:
read : 20w kvs/s
write : 25w kvs/s
Jedis:
Read : 28w kvs/s
Write : 28w kvs/s
 异步客户端
 10M kvs
key int 0 ~ 9999999 ,value string “65533”
 Read :10k keys,10 times
 Write :10k keys, 10 times
Redis hashes结构分片cache & zipmap
Redis zipmap
 Zipmap
zipmap是在redis存储较小的hashes结构时使用的
压缩结构,由hash-max-zipmap-entries 和hash-max-
zipmap-value 两个参数的值来控制,其实质是用一个
字符串数组来依次保存key和value,查询时是依次遍历
每个 key-value 对,直到查到为止.
Key-value vs hashes
Used memory:740m
Read: 20w kvs/s
Write: 25w kvs/s
Used memory:536.50m
Read:28w kvs/s
Write: 32w kvs/s
 10M kvs
key int 0 ~ 9999999 ,
value string “65533”
 Read :10k keys,10
times
 Write :10k keys, 10
times
 1000k kvs
key int 0 ~ (1000k/1024) ,
field 0 ~ 1024,
value string “65533”
 hash-max-zipmap-entries=512
 hash-max-zipmap-value=64
 Read :10k keys,10 times
 Write :10k keys, 10 times
zipmap
Used memory:154.86m
Read: 11w kvs/s
Write: 14w kvs/s
Used memory:115.99m
Read: 90k kvs/s
Write: 95k kvs/s
 10M kvs
key int 0 ~ (10M/512) ,
field 0 ~ 512,
value string “65533”
 hash-max-zipmap-entries=512
 hash-max-zipmap-value=64
 Read :10k keys,10 times
 Write :10k keys, 10 times
 10M kvs
key int 0 ~ (10M/1024) ,
field 0 ~ 1024,
value string “65533”
 hash-max-zipmap-entries=1024
 hash-max-zipmap-value=64
 Read :10k keys,10 times
 Write :10k keys, 10 times
FAQ
The End

More Related Content

Similar to Redis应用优化技巧

新浪 杨海朝 Redis运维之道
新浪 杨海朝 Redis运维之道新浪 杨海朝 Redis运维之道
新浪 杨海朝 Redis运维之道colderboy17
 
Redis运维之道 新浪:杨海朝
Redis运维之道 新浪:杨海朝Redis运维之道 新浪:杨海朝
Redis运维之道 新浪:杨海朝billowqiu
 
新浪 杨海朝 Redis运维之道
新浪 杨海朝 Redis运维之道新浪 杨海朝 Redis运维之道
新浪 杨海朝 Redis运维之道guiyingshenxia
 
Redis 常见使用模式分析
Redis 常见使用模式分析Redis 常见使用模式分析
Redis 常见使用模式分析vincent253
 
Thinking in React by Deot
Thinking in React by Deot Thinking in React by Deot
Thinking in React by Deot 荣德 周
 
Redis分享
Redis分享Redis分享
Redis分享yiihsia
 
Nodejs api server_implement
Nodejs api server_implementNodejs api server_implement
Nodejs api server_implementChi-wen Sun
 

Similar to Redis应用优化技巧 (7)

新浪 杨海朝 Redis运维之道
新浪 杨海朝 Redis运维之道新浪 杨海朝 Redis运维之道
新浪 杨海朝 Redis运维之道
 
Redis运维之道 新浪:杨海朝
Redis运维之道 新浪:杨海朝Redis运维之道 新浪:杨海朝
Redis运维之道 新浪:杨海朝
 
新浪 杨海朝 Redis运维之道
新浪 杨海朝 Redis运维之道新浪 杨海朝 Redis运维之道
新浪 杨海朝 Redis运维之道
 
Redis 常见使用模式分析
Redis 常见使用模式分析Redis 常见使用模式分析
Redis 常见使用模式分析
 
Thinking in React by Deot
Thinking in React by Deot Thinking in React by Deot
Thinking in React by Deot
 
Redis分享
Redis分享Redis分享
Redis分享
 
Nodejs api server_implement
Nodejs api server_implementNodejs api server_implement
Nodejs api server_implement
 

Redis应用优化技巧