Skip to content
New issue

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

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

Already on GitHub? # to your account

feat(outputs.nats): Add option to use async Jetstream publish #16582

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kfollesdal
Copy link
Contributor

@kfollesdal kfollesdal commented Mar 4, 2025

Summary

Solves #16581 by adding option to use async jetstream publish. "Make" up for loose of performance when changing to sync jetstream publisher vs core.

Checklist

  • No AI generated code was used in this PR

Related issues

resolves #16581
based on #16570

@telegraf-tiger telegraf-tiger bot added feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/output 1. Request for new output plugins 2. Issues/PRs that are related to out plugins labels Mar 4, 2025
@kfollesdal kfollesdal force-pushed the nats-publish-async-jetstream branch 2 times, most recently from 90a09ef to 4cd7f12 Compare March 4, 2025 15:56
@kfollesdal kfollesdal marked this pull request as ready for review March 4, 2025 15:57
@srebhan srebhan self-assigned this Mar 4, 2025
@srebhan
Copy link
Member

srebhan commented Mar 4, 2025

Let's merge #16570 first and then rebase this PR. In any case this looks good to me already.

@kfollesdal kfollesdal force-pushed the nats-publish-async-jetstream branch from 4cd7f12 to 3f0c6e9 Compare March 5, 2025 15:49
@kfollesdal
Copy link
Contributor Author

kfollesdal commented Mar 5, 2025

@srebhan, #16570 is now merged :-) I have now rebased this PR.

To achieve higher throughput, add an option to use asynchronous publishing.
In benchmarks, asynchronous publishing is significantly faster—up to 16 times
in one test. This improvement comes from not having to wait for individual
publish acknowledgments, allowing all acknowledgments to be checked at once.
@kfollesdal kfollesdal force-pushed the nats-publish-async-jetstream branch from 84df24c to fa4eb1d Compare March 5, 2025 20:39
return fmt.Errorf("publish acknowledgement is an error: %w (retrying)", err)
}
}
case <-time.After(5 * time.Second):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kfollesdal @srebhan Can we also make this configurable?
this can come under async table in TOML config or as a standalone field.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neelayu and @srebhan added a new commit with option async_ack_timeout to control timeout for waiting on ack from async publish. Default to 5s.

Add option async_ack_timeout to controll timeout for waiting on ack from
async publish.
@telegraf-tiger
Copy link
Contributor

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/output 1. Request for new output plugins 2. Issues/PRs that are related to out plugins
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Outout NATS]: Add option for async jetstream publish
3 participants