Skip to content

Instantly share code, notes, and snippets.

@amgorb
Last active October 29, 2025 13:56
Show Gist options
  • Select an option

  • Save amgorb/c38a77599c1f30e853cc9babf596d634 to your computer and use it in GitHub Desktop.

Select an option

Save amgorb/c38a77599c1f30e853cc9babf596d634 to your computer and use it in GitHub Desktop.
redis replication scheduled to be closed ASAP for overcoming of output buffer limits.
If your redis initial replication fails with error like
"5101:M 20 Feb 18:14:29.130 # Client id=4500196 addr=71.459.815.760:43872 fd=533 name= age=127 idle=127 flags=S db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=13997 oll=1227 omem=192281275 events=rw cmd=psync scheduled to be closed ASAP for overcoming of output buffer limits.
this means that slave buffer is not enough and you should increase it (at master!) with command like
redis-cli config set client-output-buffer-limit "slave 836870912 836870912 0"
more info: https://redis.io/topics/clients
@alibo

alibo commented Aug 18, 2018

Copy link
Copy Markdown

You saved my life :)

@drneo-mehdi

Copy link
Copy Markdown

our life too :)

@talalashraf

Copy link
Copy Markdown

Set to 0 0 0 if you are about to die.

@asrarak

asrarak commented Jan 30, 2019

Copy link
Copy Markdown

Also my life πŸ‘

@hacrot3000

Copy link
Copy Markdown

Me too, thanks

@mehdone

mehdone commented Mar 19, 2019

Copy link
Copy Markdown

Thanks; mine too

@mtdavidson

Copy link
Copy Markdown

Saved us too, thanks! πŸš€

@quintindk

Copy link
Copy Markdown

give that man a bells...

@Gianlu

Gianlu commented May 28, 2019

Copy link
Copy Markdown

Thank you!!

@heaje

heaje commented Jun 2, 2019

Copy link
Copy Markdown

You're my new hero. I was wondering what the heck was happening.

@15astro

15astro commented Sep 25, 2019

Copy link
Copy Markdown

@amgorb, I am not getting the slave buffer error in redis logs but the same error redis.exceptions.ConnectionError: Error 104 while writing to socket. Connection reset by peer in application logs.

Is increasing the slave buffer going to help?

@techoutlooks

Copy link
Copy Markdown

@amgorb, I am not getting the slave buffer error in redis logs but the same error redis.exceptions.ConnectionError: Error 104 while writing to socket. Connection reset by peer in application logs.

Is increasing the slave buffer going to help?

Yes, buffer issue might be the root cause:
Right now getting from app logs "Error 104 while writing to socket. Connection reset by peer.",
then at the same time stamps, but in the redis logs, got the "to be closed ASAP for overcoming of output buffer limits." error.

above trick just ran and keeping an eye on the logs -

@jberends

jberends commented Jun 26, 2020

Copy link
Copy Markdown

These errors can also happen for the pubsub buffer overruns, not only the slave buffers.

The errors we see in the log that are related to pubsub buffer overruns are something like:

<timestamp> # Client id=494028 addr=127.0.0.1:43534 fd=36 name= age=75 idle=0 flags=N db=0 sub=148630 
    psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=742 omem=12154393 events=rw 
    cmd=subscribe scheduled to be closed ASAP for overcoming of output buffer limits.

By increasing the client-output-buffer-limit pubsub <hard> <soft> <seconds> this may be resolved as well.

you can set this in a running production server by

redis-cli config set client-output-buffer-limit "pubsub <hard> <soft> <seconds>"

# eg to set it to 64 MB hard, 32 MB soft for 120s:
redis-cli config set client-output-buffer-limit "pubsub 64mb 32mb 120"

or put it in the redis.conf and find and replace the client-output-buffer-limit pubsub line

Thanks for this post for guiding our thoughts and eventually saving our lives as well.

@weijiayun

Copy link
Copy Markdown

also my life, thank you!

@FirstShanti

Copy link
Copy Markdown

@jberends

Thanks for the help!
These manipulations require AUTH password to submit changes.

redis-cli config -a "$REDIS_PASSWORD" set client-output-buffer-limit "pubsub 64mb 32mb 120"

It must return OK if a request is successful.

@thstarshine

Copy link
Copy Markdown

I can't use "mb" in redis-cli command for server version 4.0.9.
I must specify pure numbers in the command:

redis-cli config set client-output-buffer-limit "pubsub 268435456 67108864 120"

@toddlindner

Copy link
Copy Markdown

TO THE MOON

@mhalbsguth

Copy link
Copy Markdown

Thank you. Helpful hint.
I knew there is some buffer but official documentation was missing that info.

@samof76

samof76 commented Sep 29, 2023

Copy link
Copy Markdown

Thanks this is helpful!

@ehassan1312

Copy link
Copy Markdown

Me too :) Thanks a lot

@bironran

bironran commented Dec 4, 2023

Copy link
Copy Markdown

too bad I got here after the crash loop. Still, very helpful, thanks!

@ciupam

ciupam commented May 23, 2024

Copy link
Copy Markdown

you saved my life as well πŸ™

@d0zingcat

Copy link
Copy Markdown

In my case, I found that I need to set repl-backlog-size 512mb as well(RDB file size is around 65 GB) in addition to set client-output-buffer-limit "slave 836870912 836870912 0"

@vanso-hubsi

vanso-hubsi commented Oct 10, 2024

Copy link
Copy Markdown

and in 2024 still more lifes saved πŸ‘πŸ˜‰

@pratik4599

Copy link
Copy Markdown

some times rdb file size is around 3000mb, most of the time below 1000 mb

current soft and hard limits are 64 and 256 mb

how much should i set client-output-buffer-limit ?

TIA.

@dbdbdeep90

Copy link
Copy Markdown

and in 2024 still more lifes saved too

@BestAwperEver

Copy link
Copy Markdown

it's 2025 already, and lives are still being saved

@meatballhat

Copy link
Copy Markdown

So humbled to be among the saved. Thank you, @amgorb πŸ™‡ πŸ’–

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment