skip to Main Content

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


  1. Chosen as BEST ANSWER

    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.


  2. Updated Answer

    Subsequent to my original answer below, I came across the actual answer. There is a configuration parameter in redis.conf called:

    client-output-buffer-limit
    

    You can check it with:

    config get client-output-buffer limit
    "normal 0 0 0 slave 268435456 67108864 60 pubsub 33554432 8388608 60"
    

    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:

    config set client-output-buffer-limit "normal 0 0 0 slave 268435456 67108864 60 pubsub 53554432 8388608 60"
    

    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:

    redis-cli SUBSCRIBE myStream
    

    And I sent data, in multiples of 1MB like this:

    dd if=/dev/zero bs=$((1024*1024)) count=20  | redis-cli -x PUBLISH myStream
    

    So, the command above worked, at 20MB but the following command for 21MB failed:

    dd if=/dev/zero bs=$((1024*1024)) count=21  | redis-cli -x PUBLISH myStream
    

    and the subscriber was disconnected with the message:

    Error: Server closed the connection
    

    I’m calling this an "empirical" answer.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search