Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis MGET Limitations

Tags:

redis

We're planning to use MGET for one of our Systems. During benchmarking, we were able to retrieve values for 1 Million Keys in one MGET call in lettuce and were quite surprised.

What I've been trying to find are the limitations of MGET. Specifically,

  1. Is there any limit to number of Keys that can be retrieved in one MGET call?
  2. Is there any limit to size of data that gets returned by a single MGET call?
like image 463
D159 Avatar asked Mar 09 '17 22:03

D159


People also ask

How many hashes can Redis handle?

Redis can handle up to 2^32 keys, and was tested in practice to handle at least 250 million keys per instance. Every hash, list, set, and sorted set, can hold 2^32 elements. In other words your limit is likely the available memory in your system.

What is Redis Mget?

Redis MGET command is used to get the values of all specified keys. For every key that does not hold a string value or does not exist, the special value nil is returned.

How big can a Redis key be?

The maximum allowed key size is 512 MB.


1 Answers

Is there any limit to number of Keys that can be retrieved in one MGET call?

Theoretically, the limit is the max value for int: 0x7FFFFFFF. However, in practice, you CANNOT have so many keys in a single Redis instance (it costs too much memory).

Is there any limit to size of data that gets returned by a single MGET call?

Theoretically, NO limit. However, in practice, Redis saves the returned values in memory before sending to client, so if you try to MGET too many keys, you'll get OOM problem.

In a word, it's a bad idea to MGET too many keys from Redis: it costs too much memory, and blocks Redis for a long time.

like image 176
for_stack Avatar answered Sep 30 '22 17:09

for_stack