I am currently implementing redis PUB/SUB in one of my project, and it raises a concern to me, what’s the size limitation of a message when PUB/SUB in Redis channel. Was the limit equal to the available memory of the computer? or there will be a threshold in somewhere of config file. Thanks!
2
Answers
Just for your information, I experimented myself, the approximate ceiling size is around 21MB to 22MB on my machine (Debian 5.4.8-1) (it may vary depends on the OS and redis version), it will cause a redis ConnectionError: Connection closed by server.
Updated Answer
Subsequent to my original answer below, I came across the actual answer. There is a configuration parameter in
redis.conf
called:You can check it with:
The 33554432 after
pub/sub
is the maximum buffer size for pub/sub clients, and the 8388608 is a soft limit that may not be exceeded for more than 60 seconds.So, my answer below changes if you raise the limit using a command like the following:
I have not done any tests as to whether this is advisable, or safe or even sensible but think it is materially relevant to the answer.
Original Answer
I don’t know where the limit arises, but just FYI, I did some simple tests with the
redis-cli
client, subscribing like this:And I sent data, in multiples of 1MB like this:
So, the command above worked, at 20MB but the following command for 21MB failed:
and the subscriber was disconnected with the message:
I’m calling this an "empirical" answer.