B4J Question Slow performance of jMQTTBroker v2

jmon

Well-Known Member
Licensed User
Longtime User
Hello,

I was using jMQTTBroker v1 for almost 2 years I guess. Recently I updated to v2 and instantly saw the difference. The new version is much slower. I kept all the settings as it was, I just changed the library. I use QOS 0.

I have about 75 raspberry pi connected together and exchanging messages using MQTT Broker. The Broker is running on Ubuntu, and raspberry pi are running the MQTT Client. The MQTT Broker is also a client.

I have a "ping" function in my app, which counts the round trip time a message took. The "ping" message is published on the "ping" topic. So any raspberry pi that gets the message have to reply as quickly as possible.
With V1 I get ping that range between 10ms to 25ms. With v2 my ping from raspberry pi ranges between 600ms to 2500ms and sometimes more.

At the moment I stick to v1. Anyone could confirm the same problem? Just swap the jMQTT broker in the IDE to the other version.

thanks
 

jmon

Well-Known Member
Licensed User
Longtime User
Hi, yes I can reproduce it.

Here I tested with a windows 7 broker and a windows 10 client, on a different network and still get a different ping. I've uploaded an example of the problem.

With v1 I get: 1 to 5 ms
and with v2 I get: 100ms to 900ms

to reproduce the problem:
- In the client B4J file, change the "MQTT_HOST" IP address to the one of your broker.
- Run the Client on a separate machine.
- Open the B4J Broker file and run the broker.
- On the broker GUI, click the button "PING" and you will see the ping of V1.
- Close the broker, change from jMqttBroker to jMqttBroker2 in the IDE's libraries manager
- Run the broker again
- press the PING button, it should show ping at least 10 times longer.

[EDIT] tested with JDK 10 and JDK 8, but not yet with JDK 11.
 

Attachments

  • Broker.zip
    3.8 KB · Views: 294
  • Client.zip
    3.2 KB · Views: 289
Last edited:
Upvote 0

jmon

Well-Known Member
Licensed User
Longtime User
Thank you. :)
It's still slower than v1, but the results are quite reasonable. I now get results that are about 2-3 times slower than v1, but not 100 times slower like before.
Now with v2 I get ping results in the range of 11 ms - 45 ms.
I wonder if that can be improved more?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I wonder if that can be improved more?
The issue is related to an internal auto-flush module. The change was done inside moqueutte code. I changed the timeout from 1 second to 50 ms. I prefer to keep it like this for now in order to avoid causing other unexpected issues.

Once the broker will be under more load it will be flushed before the timeout.
 
Upvote 0

jmon

Well-Known Member
Licensed User
Longtime User
ok thank you.

Another thing I noticed is that .debugLog = true logs much less messages than before. That doesn't bother me, it's just a note.

Thank you for your help.
 
Upvote 0
Top