Skip to content

perf(pubsub): buffer subscriber output per connection - #197

Merged
MohitGoyal09 merged 12 commits into
mainfrom
fix/153-pubsub-buffering
Nov 24, 2026
Merged

MohitGoyal09 merged 12 commits into
mainfrom
fix/153-pubsub-buffering

Conversation

@MohitGoyal09

Copy link
Copy Markdown
Collaborator

Fixes #153

Reference: Redis client output buffer limits (client-output-buffer-limit pubsub 32mb 8mb 60).

A subscriber that paused for ~2 s lost a truncating connection, PUBLISH returned 0 for it, and a large message could be skipped for a live subscriber.

  • Each subscriber gets an output queue plus a writer thread; acknowledgements, messages, and command replies are all queued whole, so no reply is ever cut mid-frame.
  • A publish appends to the queue and returns; it never waits for a reader and never skips a live listener.
  • A subscriber is evicted only above 32 MiB buffered, or after staying above 8 MiB for 60 seconds; the queue and socket close on eviction.
  • EXEC replies are queued ahead of held self-deliveries, preserving fix(pubsub): queue subscription commands inside MULTI #162 ordering.
  • Removed the 100 ms publish / 750 ms ack budgets and the partial-frame caveat from docs/COMPATIBILITY.md.
  • New tests: a 4 MiB message to a subscriber paused 2 s arrives whole, and a 40 x 300 KiB SUBSCRIBE batch paused 1.5 s delivers every ack.

Verification

cargo fmt --all -- --check
cargo clippy --all-targets -- -D warnings
cargo test

All 40 test binaries pass.

@MohitGoyal09
MohitGoyal09 merged commit 7b005d0 into main Nov 24, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Buffer per-client Pub/Sub output instead of dropping on short stalls

1 participant