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

feat: Upper bound on outgoing inflight publishes #615

Merged
merged 1 commit into from
May 12, 2023

Conversation

einarmo
Copy link
Contributor

@einarmo einarmo commented May 5, 2023

Adds a configuration option for setting an optional upper bound on the number of maximum outgoing publishes. The smaller of this and the value received from the broker on connect is used.

This allows the user to limit the memory usage of the client, especially if they have a good idea of the number of inflight messages they expect.

The background for this is that we run a number of clients that never actually publish anything, just subscribe, and noticed a major bump in memory usage even for idle clients with 0.21.0. The outgoing_pub vector can be as much as ~1.5MB of memory, which quickly adds up.

The solution is fairly simple. Respect the receive_max value received from the broker, but let users specify an upper bound. This upper bound can safely be used to limit the length of the outgoing_pub and outgoing_rel vectors, much like it used to work, and how it is done for MQTT3.

There is also a comment mentioning resizing the outgoing_pub and outgoing_rel vectors depending on the receive_max value from the broker. That could be a separate but related improvement along similar lines.

Type of change

New feature (non-breaking change which adds functionality)

Checklist:

  • Formatted with cargo fmt
  • Make an entry to CHANGELOG.md if its relevant of user of the library. If its not relevant mention why.

Adds a configuration option for setting an optional upper bound on the
number of maximum outgoing publishes. The smaller of this and the value
received from the broker on connect is used.

This allows the user to limit the memory usage of the client, especially
if they have a good idea of the number of inflight messages they expect.

The `outgoing_pub` vector accounts for some ~1.5MB of memory, which can
be considerable depending on use.
@yatinmaan yatinmaan merged commit db64f0b into bytebeamio:main May 12, 2023
3 checks passed
@yatinmaan
Copy link
Contributor

Thanks for your contribution 🚀

@einarmo einarmo deleted the inflight-upper-limit branch May 22, 2023 06:03
carlocorradini pushed a commit to carlocorradini/rumqtt that referenced this pull request Aug 3, 2023
Adds a configuration option for setting an optional upper bound on the
number of maximum outgoing publishes. The smaller of this and the value
received from the broker on connect is used.

This allows the user to limit the memory usage of the client, especially
if they have a good idea of the number of inflight messages they expect.

The `outgoing_pub` vector accounts for some ~1.5MB of memory, which can
be considerable depending on use.
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.

None yet

2 participants