Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redis大key #21

Open
diaosichengxuyuan opened this issue Sep 20, 2020 · 0 comments
Open

redis大key #21

diaosichengxuyuan opened this issue Sep 20, 2020 · 0 comments

Comments

@diaosichengxuyuan
Copy link
Owner

1.大key是什么
redis是一个<key,value>数据库,大key即存储的value非常大。当value为哈希表、集合、有序集或链表时指存储的元素过多(上万),当value为字符串时一般指单个字符串超过1M。

2.大key导致的问题
(1)集群内存和QPS分布不均
(2)查改删或者主从复制时可能导致阻塞

3.为什么会阻塞
(1)单线程
(2)底层存储结构是LinkedList,HashTable,SkipTable等,数据量过多对数据的查找,数据的存储和处理有影响。

4.大key的排查
(1)redis-rdb-tools工具。redis实例上执行bgsave,然后对dump出来的rdb文件进行分析,找到其中的大key。
(2)redis-cli --bigkeys命令。可以找到某个实例5种数据类型(string、hash、list、set、zset)的最大key。

5.解决方案
可以尝试将对象分拆成几个key-value,使用multiGet获取值,这样分拆的意义在于分拆单次操作的压力,将操作压力平摊到多个redis实例中,降低对单个redis的IO影响。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant