79

Does anyone know what the maximum value size you can store in redis? I want to use redis as a message queue with celery to store some small documents that need to be processed by a worker on another server, and I want to make sure the documents aren't going to be too big.

I found one page with a reference to 1GB, but when I followed the link on the page for where they got that answer the link wasn't valid anymore. Here is the link:

http://news.ycombinator.com/item?id=1182005

Alexis Wilke
  • 19,179
  • 10
  • 84
  • 156
Ken Cochrane
  • 75,357
  • 9
  • 52
  • 60

4 Answers4

110

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.

Values, on the other hand, can vary in size depending on their type. For aggregate data types (i.e. hash, list, set, and sorted set), the maximum value size is 512 MiB for each element, although the data structure itself can have up to 2^32 - 1 elements.

https://redis.io/topics/data-types

https://redis.io/topics/faq#what-is-the-maximum-number-of-keys-a-single-redis-instance-can-hold-and-what-is-the-max-number-of-elements-in-a-hash-list-set-sorted-set

http://groups.google.com/group/redis-db/browse_thread/thread/1c7e33fbc98734b3?fwc=2

BMiner
  • 16,669
  • 12
  • 53
  • 53
  • 12
    So, in other words, you should be OK. If you need to store strings larger than 512 MiB, you probably should be using the hard disk, not redis. – BMiner Apr 11 '11 at 16:41
  • I'm going to necro this thread, as I landed it on it today from a Google search. In the google groups discussion you reference, Salvatore Sanfilippo himself states that the maximum key size is 512MB. Keys are strings there, so this consistency makes sense. It would not make sense to allow 2 GiB key size, and place a 512MiB size limit on strings. For a key/value store, that would actually be absurd. – Pittsburgh DBA Jun 16 '20 at 21:28
  • 1
    @PittsburghDBA - More precisely speaking, the string data that makes up the key is limited to 512 MiB. A 32-bit int is used under the hood, so the limit *could* theoretically be 2 GiB without changing much (hence the confusion). – BMiner Jul 01 '20 at 13:43
  • 1
    of course that's the case. But you would have to recompile the source, which I think was already mentioned in that same thread. – Pittsburgh DBA Jul 01 '20 at 19:37
  • It looks like changes were merged 2 Feb 2022: https://github.com/redis/redis/pull/4568 There is some discussion about it: https://github.com/redis/redis/issues/757 AFAIK recent versions of Redis should therefore support 2GB keys and values. – NeilG Sep 09 '22 at 01:16
  • @NeilG - I could easily foresee Redis relaxing the 512 MB limit, but the Redis official docs still state 512 MB. https://redis.io/docs/data-types/tutorial/ – BMiner Nov 07 '22 at 17:49
5

Article about Redis Memory Usage can help you to roughly determine how much memory your database would take.

yojimbo87
  • 65,684
  • 25
  • 123
  • 131
2

It's in the order of the amount of RAM you have, at least, so unless you plan on puting multi-gigabyte objects in there I wouldn't worry. I've had sets that were hundreds of megabytes big without a problem, but I don't know the exact limits.

Theo
  • 131,503
  • 21
  • 160
  • 205
  • I'm guessing my files will be under 10k in size, but there could be thousands of them. Which sounds like it should handle it, if I have enough RAM. – Ken Cochrane Apr 09 '11 at 22:09
  • 3
    I may have misunderstood your question, I thought you were asking about the max size for a single value. If you're worried about the size of the whole database the limit is 4 Gb on a 32 bit system, but for 64 bit systems you can't install RAM enough into a server to reach it. http://redis.io/topics/memory-optimization – Theo Apr 10 '11 at 08:04
  • No you were right I wanted to make sure it could handle my files. Most will be 10k range but every now and then they might jump up to the MB range, so it looks like it will work fine. Thanks for the other answer, that is good to know as well. – Ken Cochrane Apr 10 '11 at 10:43
0

A String value can accommodate the size of max 512MB. But according to this link, the size can be increased.

Gunasekar
  • 611
  • 1
  • 8
  • 21