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

Memory usage #189

Closed
thedevop opened this issue Mar 9, 2023 · 3 comments
Closed

Memory usage #189

thedevop opened this issue Mar 9, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request pending ok Released, awaiting confirmation of resolution

Comments

@thedevop
Copy link
Collaborator

thedevop commented Mar 9, 2023

I did a memory usage comparison between 2.1.6 and 2.2.3 (post dedicated write chan per client). The setup is ~140K concurrent clients, each client send ~2KB to the broker every minute.

2.1.6 2.2.3 (128) 2.2.3 (1024)
RSS GiB 8.5 10.5 13.5

2.1.6: FanPoolSize = 512, with FanPoolQueueSize = 1024
2.2.3: MaximumClientWritesPending in parenthesis above

The difference is larger than expected, so I did a heap profile on it, and found currently the majority of the memory allocation is due to NewReader and NewWriter (both defaults to 4096B)
https://github.com/mochi-co/mqtt/blob/44ce819318f67eee790d5126355f1229e57a8d1a/clients.go#L172
We make this configurable, I can submit a PR if you like.

@mochi-co
Copy link
Collaborator

Good find! This should now be configurable in v2.2.6: https://github.com/mochi-co/mqtt/releases/tag/v2.2.6 - let me know if it works as expected!

@mochi-co mochi-co added enhancement New feature or request pending ok Released, awaiting confirmation of resolution labels Mar 11, 2023
@thedevop
Copy link
Collaborator Author

Preliminary usage in staging looks promising. I'll report back the numbers when it's in production.

@thedevop
Copy link
Collaborator Author

Thanks @mochi-co. With 2.2.6, with of ClientNetWriteBufferSize=ClientNetReadBufferSize=2KB, MaximumClientWritesPending=128, the memory usage is down to similar size as 2.1.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pending ok Released, awaiting confirmation of resolution
Projects
None yet
Development

No branches or pull requests

2 participants