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
Proposal: Add support for TCP_NODELAY option in libmosquitto #1526
Milestone
Comments
ralight
added a commit
that referenced
this issue
Dec 18, 2019
Closes #1526. Thanks to Felix Moessbauer.
Will that do the job? |
2 tasks
@ralight: Thanks for taking care of this. I tested your patch and the results match perfectly with what I measured in the PoC. Note for future readers: To enable the mosquitto_int_option(mosq, MOSQ_OPT_TCP_NODELAY, 1); In a ping-pong test between two Raspberry Pis, I measure the following latencies:
What an improvement. Again: Thanks for your great work. |
I'm closing this, it will be part of 1.7. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
libmosquitto with QoS > 0 shows a very high latency when publishing. This is due to a high latency of messages send from publisher to the broker (~ 40ms).
The reason for the high latency is the TCP stack, because it waits for more incoming packets to group them together. This could be avoided by setting TCP_NODELAY for all sockets. For the mosquitto broker this can be done in the config file. The mosquitto client library has no API functionality to pass flags to the socket. However, the behavior of the Nagel algorithm has to be specified on sender side.
The following diff contains a proof-of-concept showing how to set the TCP_NODELAY flag in libmosquitto (using a compile time option). With this PoC, we were able to reduce the RTT from ~40ms to less than 1ms. For a production ready solution, this option should be selectable at runtime by using e.g. a further API call, or an additional parameter in
mosquitto_connect
ormosquitto_connect_bind
libmosquitto_nodelay.patch.txt
Xref: #433
The text was updated successfully, but these errors were encountered: