Repository navigation
Backlog
Labels
enhancementNew feature or request
Milestone
Description
Problem
Currently, KiviDB disconnects a Pub/Sub subscriber when its pending output buffer exceeds the configured client-output-buffer-limit pubsub limits.
A subscriber is disconnected in two scenarios:
- Hard limit: When its pending output buffer reaches the configured hard limit.
- Soft limit: When its pending output buffer remains above the soft limit for longer than the configured
soft_seconds.
This behavior is currently fixed, with no configuration option to choose an alternative backpressure strategy.
For high-throughput, fire-and-forget Pub/Sub use cases, disconnecting slow subscribers may be undesirable, especially when occasional message loss is acceptable.
Proposed Solution
Introduce a new configuration option:
pubsub-backpressure
It should support two strategies:
disconnect(default): Preserve the existing behavior. Disconnect subscribers when they exceed the configured hard or sustained soft output buffer limits.drop: Instead of disconnecting slow subscribers, discard incoming messages that would exceed the configured output buffer limits while keeping the subscriber connected.
The configuration should be accessible through CONFIG GET and dynamically adjustable through CONFIG SET.
Expected Behavior
- Existing deployments should retain the current behavior by default (
disconnect). - In
dropmode, messages that exceed the subscriber's configured output buffer limits should be discarded. - The subscriber should remain connected when messages are dropped.
- Pending buffer accounting should remain accurate after dropped messages.
- Once the subscriber's pending buffer drains below the configured limits, normal message delivery should resume.
- The soft-limit background monitoring mechanism should not disconnect subscribers in
dropmode.
Configuration Example
CONFIG SET pubsub-backpressure drop
CONFIG GET pubsub-backpressure
To restore the existing behavior
CONFIG SET pubsub-backpressure disconnect
Testing
- Verify that
dropmode discards messages when the hard limit is exceeded without disconnecting the subscriber. - Verify that sustained soft-limit violations do not disconnect subscribers in
dropmode. - Verify that pending buffer accounting remains correct after dropped messages.
- Verify that message delivery resumes after the subscriber's buffer drains.
- Verify runtime switching between
dropanddisconnect. - Verify
CONFIG GET,CONFIG SET, and invalid configuration values. - Ensure the default
disconnectmode preserves existing behavior.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
JituRewar commentedon Dec 1, 2026
Hi @murtazayusuf Before raising pr please take a look to this.
murtazayusuf commentedon Dec 1, 2026
Thanks @JituRewar, the write-up is clear and the shape is right: an opt-in
pubsub-backpressure dropwithdisconnectstaying the default. Go ahead with a PR. 1.3.0's scope is closed, so I've put this on the "after 1.3.0" milestone and it merges once that release is out.A few things I'd want the PR to settle:
message,pmessage,smessage). Replies toSUBSCRIBE/UNSUBSCRIBE/PINGand RESP3 client-tracking invalidations always go through, since a client cannot recover from a missing one.INFO stats(saypubsub_dropped_messages) and a per-client count inCLIENT LIST/CLIENT INFO. Please document thatPUBLISH's return value counts subscribers the message was dropped for or not, whichever you choose, and test it.dropmode I'd drop at the hard limit and also once the soft limit has been exceeded forsoft_seconds, so memory per subscriber stays bounded the same way as today. A subscriber with no pubsub limit configured (0 0 0) behaves as now.If this is your first engine PR the CLA bot will ask you to sign; it takes a minute.
Pub/Sub: add configurable pubsub-backpressure disconnect|drop (kividb…
Pub/Sub: add configurable pubsub-backpressure disconnect|drop (kividb…
Pub/Sub: add server-level drop tests, wire main.rs, and update docs (k…