I have a testing configuration which consists of a raspberry pi 3 b+ has a mqtt server, an esp32 with some led´s and a webpage to toogle them (webpage and esp32 are clients). For the esp32 i am using the PubSubClient has the library for the communication. Basically what it happens when i toogle a led, i publish "in1" topic which the esp32 is subscribed, reads its payload ("on" or "off") and then it publishs a message to the broswer according the output state for confirmation. Keep in mind that this is all happening in a local network. After some tests, i saw that it takes max. 10 ms for the browser to publish a message. However, the complete cycle takes from 20 to 100 ms since the first publish message till the confirmation message (message esp32 sends reporting output state). Ive found out that it has nothing to do with the code since it takes 1ms from when the subscribed topic gets a new message, till the esp32 publishs the output state of the designed led.
The raspberry pi is running mosquitto v 1.5.5 with websockets enabled. Don´t think it has something to do with the configuration since the same happens when i test it with the mosquitto server i have in my laptop.
All the messages and subscriptions are 0 qos.
I just think it is a ridiculous amount of time for a communication in a local network, not to talk it´s very inconsistent (20 to 100 ms).
Very gratefull for all the help.