eclipse-mosquitto / mosquitto

Eclipse Mosquitto - An open source MQTT broker
https://mosquitto.org
Other
9.12k stars 2.41k forks source link

Tuning for real time continuous message delivery #1616

Open kryptonn opened 4 years ago

kryptonn commented 4 years ago

Hi,

I publish one message every 20ms, but has a suscriber, i receive 10 messages at a time every 200ms. I want to receive messages in real time every 20ms, one by one.

I'm in mqtt mode.

My concern is that i succeeded with a MacOS catalina 10.15.2 as a mosquitto broker with docker. It didn't work on a linux debian, with exactlty the same mosquitto.conf (i either try with docker or not, with no luck). Do you know which layer is involved in grouping messages every 200 ms ?

ptjm commented 4 years ago

This sounds like the Nagle algorithm. Try setting this option:

set_tcp_nodelay true

As for why the mac and linux behave differently, I'm just guessing, but it may be the mac uses some other congestion control algorithm by default or perhaps it doesn't implement deferred acks, which as I understand it are the true source of the 200ms delay.

You may need to set the socket option TCP_NODELAY on the client application as well.

kryptonn commented 4 years ago

Thanks for the reply and sorry for the delay i didn't see your answer. So... it works ! you're my dude :)

For now i get exactly the same speeds between macos and linux, and i prevent me from doing a hackintosh on my NUC ;)

Thanks again