Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] Add backpressure to publish #1286

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Conversation

Jarema
Copy link
Member

@Jarema Jarema commented Jul 24, 2024

Overview

Clients that are missing backpressure for async publishing of JetStream messages can negatively impac the NATS servers and clusters.

Rust client separates publish with ack, as two separate futures, which is fine and very flexible, but does not enforce any backpressure, or enable easier handling of it. That is especially relevant for users dropping PublishAckFuture and ignoring the Ack entirely.

This PR addresses this in two ways:

  1. Error on Context::publish if the threshold for in-flight acks is reached
  2. Spin a task that awaits for acks for PubAckFuture that were dropped.

Challenges

  1. A new background task was needed. This should be fine, as it idles if user does not drop acks.
  2. Increased memory footprint of Context.

Signed-off-by: Tomasz Pietrek <[email protected]>
Signed-off-by: Tomasz Pietrek <[email protected]>
Signed-off-by: Tomasz Pietrek <[email protected]>
@Jarema Jarema requested a review from caspervonb July 24, 2024 19:02
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.

1 participant