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

mqttNet performance on larger messages #1160

Closed
jesseemus opened this issue May 6, 2021 · 10 comments
Closed

mqttNet performance on larger messages #1160

jesseemus opened this issue May 6, 2021 · 10 comments
Labels
bug Something isn't working

Comments

@jesseemus
Copy link

Receiving larger messages on mqttNet client is slow

When subscribing to a topic with a wildcard (+/topic) on broker (in our case moquitto),
that has around 900 persistent messages with an average size of 180KB,
the performance of mqttNet client on receiving messages is horribly slow.

I started the project that has only the managed client in it subscribing to +/topic, and incrementing a counter on received messages.
After starting the project I also connected separate mqtt client software (mqtt.fx) to same broker and subscribed to same topic.
For mqtt.fx it took approximately 12 seconds to receive all 900 messages from the broker.

meantime mqttNet client that was running at the same time had only received 40 messages.

it looks like the ApplicationMessageReceivedHandler was firing approximately 3-4 times a second in this case.

I also tested with topics that have higher volume of messages but message size was smaller, there the performance of mqttNet and mqtt.fx was comparable.

Which project is your bug related to?

  • Client
    OR
  • ManagedClient
@jesseemus jesseemus added the bug Something isn't working label May 6, 2021
@ramonsmits
Copy link
Contributor

ramonsmits commented May 11, 2021

Do you know how mqtt.fx does its processing? Does it use a single connection? Without knowing that tool you don't know if you are comparing apples to apples so do provide more details.

@jesseemus
Copy link
Author

I have no in depth knowledge on the mqtt.fx tool, but what comes to connections both mqtt.fx and mqttNet are creating only single connection. other tools in addition to mqtt.fx are also providing great speeds, including NodeRed mqtt input node that I believe is using MQTT.js.

I was not aware that you could use multiple connections for single topic subscribe to improve performance, could you clarify what do you mean with it?

@jesseemus
Copy link
Author

I did some further testing and added additional 200 retained messages to our broker that have average size of 4MB, now when subscribing with MQTTnet client I receive approximately 10 messages in same time where mqtt.fx receives 1000 messages.

@jesseemus jesseemus reopened this May 31, 2021
@jesseemus
Copy link
Author

I'm also getting comparable speeds to mqtt.fx with M2Mqtt library.

@jesseemus
Copy link
Author

Running MQTTnet and M2MQTT side by side demonstrates this issue quite well, with large messages:

image

with smaller messages:

image

numbers presented are the amount of received messages for each client.

@JanEggers
Copy link
Contributor

can you provide a repro?

@chkr1011
Copy link
Collaborator

Please try again with the latest 4.0 preview from the nuget feed. Version 4 has lots of performance and memory improvements. You can also increase the internal buffer sizes in the options now. So if you usually send messages with 4 MB in size you can set the buffer size to 5 MB etc. If the problem still exists please reopen the ticket.

@kingsley91-cpu
Copy link

The problem is still there @chkr1011 even in the library MQTT net 4.3.1.873, it has some performance issue while fetching payloads compared to M2M
QTT, how we could handle the scenario?

@kingsley91-cpu
Copy link

Screenshot 2023-12-11 at 09 54 02 @chkr1011 it worked as per your suggestion of increasing the internal buffer size

@chkr1011
Copy link
Collaborator

@kingsley91-cpu Do you have some measurements to share? I am interested in how much the performance has increased.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants