Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis - Can data size be greater than memory size?

Tags:

redis

I'm rather new to Redis and before using it I'd like to learn some important (as for me) details on it. So....

Redis is using RAM and HDD for storing data. RAM is used as fast read/write storage, HDD is used to make this data persistant. When Redis is started it loads all data from HDD to RAM or it loads only often queried data to the RAM? What if I have 500Mb Redis storage on HDD, but I have only 100Mb or RAM for Redis. Where can I read about it?

like image 836
Kirzilla Avatar asked Apr 04 '10 19:04

Kirzilla


People also ask

Can Redis handle large data?

TL;DR: Redis can store very large data structures. Expect the number of results to be 232 unless you know the number. Best-practice alternatives: Run a command that sanity checks the size of data structures (HLEN for hashes, LLEN for lists, SCARD for sets, and ZCARD for sorted sets).

How big can Redis values be?

All string values are limited to 512 MiB. This is the size limit you probably care most about. EDIT: Because keys in Redis are strings, the maximum key size is 512 MiB. The maximum number of keys is 2^32 - 1 = 4,294,967,295.

Does Redis keep all data in memory?

All Redis data resides in memory, which enables low latency and high throughput data access. Unlike traditional databases, In-memory data stores don't require a trip to disk, reducing engine latency to microseconds.

Is Redis faster than memory?

Redis is a remote data structure server. It is certainly slower than just storing the data in local memory (since it involves socket roundtrips to fetch/store the data).


2 Answers

Redis loads everything into RAM. All the data is written to disk, but will only be read for things like restarting the server or making a backup.

There are a couple of ways you can use it with less RAM than data though. You can set it up in combination with MySQL or another disk based store to work much like memcached - you manage cache misses and persistence manually.

Redis has a VM mode where all keys must fit in RAM but infrequently accessed data can be on disk. However, I'm not sure if this is in the stable builds yet.

like image 57
Tom Clarkson Avatar answered Oct 07 '22 17:10

Tom Clarkson


Recent versions (>2.0) have improved significantly and memory management is more efficient. See this blog post that explains how to use hashes to optimize RAM memory footprint: http://antirez.com/post/redis-weekly-update-7.html

like image 39
Lucian2k Avatar answered Oct 07 '22 18:10

Lucian2k