Redis各种数据结构内存占用测试
2015-07-14 10:03
507 查看
启动时:(redis为空)
插入数据量都为100W(100W个key或者list中100W个值,或者1000个key,每个key中1000个值)
String
Key value
# Memory
used_memory:121763808
used_memory_human:116.12M
used_memory_rss:124956672
used_memory_peak:121762584
used_memory_peak_human:116.12M
used_memory_lua:31744
mem_fragmentation_ratio:1.03
mem_allocator:jemalloc-3.2.0
List
Key value如下
# Memory
used_memory:81375240
used_memory_human:77.61M
used_memory_rss:84156416
used_memory_peak:121762496
used_memory_peak_human:116.12M
used_memory_lua:31744
mem_fragmentation_ratio:1.03
mem_allocator:jemalloc-3.2.0
Set
Key value
# Memory
used_memory:89764296
used_memory_human:85.61M
used_memory_rss:94650368
used_memory_peak:153269416
used_memory_peak_human:146.17M
used_memory_lua:31744
mem_fragmentation_ratio:1.05
mem_allocator:jemalloc-3.2.0
ZSET
# Memory
used_memory:143119144
used_memory_human:136.49M
used_memory_rss:146919424
used_memory_peak:165802136
used_memory_peak_human:158.12M
used_memory_lua:31744
mem_fragmentation_ratio:1.03
mem_allocator:jemalloc-3.2.0
Hash
# Memory
used_memory:137763776
used_memory_human:131.38M
used_memory_rss:157798400
used_memory_peak:183714248
used_memory_peak_human:175.20M
used_memory_lua:31744
mem_fragmentation_ratio:1.15
mem_allocator:jemalloc-3.2.0
设置:
##ziplist中允许的条目个数
hash-max-ziplist-entries 512
##ziplist中每个条目(K-V)的V允许的最大字节数
hash-max-ziplist-value 64
##如果达到阀值,则重构为hashtable
# Memory
used_memory:21946472
used_memory_human:20.93M
used_memory_rss:25464832
used_memory_peak:183714248
used_memory_peak_human:175.20M
used_memory_lua:31744
mem_fragmentation_ratio:1.16
mem_allocator:jemalloc-3.2.0
结论:100W数据在key和value都在10Byte左右时,占用空间100M左右,若使用Hash的压缩列表特性,内存占用减少到1/5.
100W的key和value都在10Byte时 100w*2*0.00001m=20M
插入数据量都为100W(100W个key或者list中100W个值,或者1000个key,每个key中1000个值)
String
Key value
# Memory
used_memory:121763808
used_memory_human:116.12M
used_memory_rss:124956672
used_memory_peak:121762584
used_memory_peak_human:116.12M
used_memory_lua:31744
mem_fragmentation_ratio:1.03
mem_allocator:jemalloc-3.2.0
List
Key value如下
# Memory
used_memory:81375240
used_memory_human:77.61M
used_memory_rss:84156416
used_memory_peak:121762496
used_memory_peak_human:116.12M
used_memory_lua:31744
mem_fragmentation_ratio:1.03
mem_allocator:jemalloc-3.2.0
Set
Key value
# Memory
used_memory:89764296
used_memory_human:85.61M
used_memory_rss:94650368
used_memory_peak:153269416
used_memory_peak_human:146.17M
used_memory_lua:31744
mem_fragmentation_ratio:1.05
mem_allocator:jemalloc-3.2.0
ZSET
# Memory
used_memory:143119144
used_memory_human:136.49M
used_memory_rss:146919424
used_memory_peak:165802136
used_memory_peak_human:158.12M
used_memory_lua:31744
mem_fragmentation_ratio:1.03
mem_allocator:jemalloc-3.2.0
Hash
# Memory
used_memory:137763776
used_memory_human:131.38M
used_memory_rss:157798400
used_memory_peak:183714248
used_memory_peak_human:175.20M
used_memory_lua:31744
mem_fragmentation_ratio:1.15
mem_allocator:jemalloc-3.2.0
设置:
##ziplist中允许的条目个数
hash-max-ziplist-entries 512
##ziplist中每个条目(K-V)的V允许的最大字节数
hash-max-ziplist-value 64
##如果达到阀值,则重构为hashtable
# Memory
used_memory:21946472
used_memory_human:20.93M
used_memory_rss:25464832
used_memory_peak:183714248
used_memory_peak_human:175.20M
used_memory_lua:31744
mem_fragmentation_ratio:1.16
mem_allocator:jemalloc-3.2.0
结论:100W数据在key和value都在10Byte左右时,占用空间100M左右,若使用Hash的压缩列表特性,内存占用减少到1/5.
100W的key和value都在10Byte时 100w*2*0.00001m=20M
相关文章推荐
- caffe study (1) - 数据结构(1)
- 【数据结构】 Queue 的简单实现
- 课程笔记 02:数据结构(清华) 向量
- 数据结构基础温故-4.树与二叉树(中)
- LeetCode刷题记 2
- 软件开发步骤
- PAT 数据结构 08-排序4. The World's Richest (25)
- 基本数据结构之堆
- 基本数据结构之二叉树
- PAT 数据结构 08-排序3. Talent and Virtue (25)
- PAT 数据结构 07-排序2. Insert or Merge (25)
- 【数据结构】深度优先搜索BFS和广度优先搜索DFS
- 数据结构与算法设计--顺时针打印矩阵
- PAT 数据结构 07-排序1. 排序(25) 8种排序的比较
- java数据结构和算法------二叉树基本操作
- [数据结构]RMQ算法
- session 原理 数据结构
- 数据结构:树结构笔试题目
- 数据结构之栈
- 数据结构与算法——插入类排序(直接插入排序,希尔排序)