啓動時:(redis爲空) redis
插入數據量都爲100W(100W個key或者list中100W個值,或者1000個key,每一個key中1000個值) lua
String spa
Key value 3d
# Memory blog
used_memory:121763808 ip
used_memory_human:116.12M 內存
used_memory_rss:124956672 hash
used_memory_peak:121762584 io
used_memory_peak_human:116.12M table
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.