Paho client limit?
<p>I'm running some performance test of a service/client service using mosquitto broker and clients, and paho clients. I got some strange results:</p>

<p>Deployment notes: </p>

<ul>
<li>3 machines; producer, broker, consumer  </li>
<li>Producers: 6 python scripts using mosquitto_pub as fast they can. See below.   </li>
<li>Consumer: simple java client show below. Subscribing to all topics.</li>
<li>The hardware specifics has not shown significant difference.</li>
</ul>

<p>1) Mosquitto gets around 1459.5055 messages/s but it sends only 973.9596666666667. The subscribers just get 485.5458333333333 . </p>

<p>2) Not matter how many instances of the paho clients are created the performance do not improve. E.g. if you run 6 producers in one topic and 2 consumer in two topic you will get 485.5458333333333. But if you add 6 producers to the other topic (already checked that the total amount of messages increment) the total performance stay the same  and per topic is divided by two. </p>

<p>3) If you do the precisely the test to two separated java application the performance do not drop. Each application gets the max performance. </p>

<p>In no case the CPU or memory reaches any limit.</p>

<p><strong>Producers.py</strong></p>

<pre><code>from datetime import datetime, date, time
import os,sys,time, json, random, itertools

arg = sys.argv
host="broker"

n=1
if len(arg)&gt;1:
    n = int(arg[1])

i=0
while True :

    payload = {"id":str(n),"Time":datetime.now().strftime("%Y-%m-%dT%H:%M:%S.00Z"),"ResultValue":1.0,"ResultType":"integer","Datastream":{"id":str(n)}}

    os.system( "mosquitto_pub -h "+host+" -t "+("/"+str(payload["id"])+" -m " +str(json.dumps(json.dumps(payload)))+"")
</code></pre>

<p><strong>Consumer.java</strong></p>

<pre><code>package eu.linksmart.testing;

import org.eclipse.paho.client.mqttv3.*;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;

import java.util.UUID;

public class Application implements MqttCallback {
    public Application() {
        id++;
    }

    public static void main(String[] args) {

        try {

            Application app = new Application();
            create("1",new Application());
            create("2",new Application());

            while (true)
                try {
                    Thread.sleep(30000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

        } catch (MqttException e) {
            e.printStackTrace();
        }

    }
    static void create(String id, Application app) throws MqttException {
        MqttClient mqttClient =  new MqttClient("tcp://broker:1883", UUID.randomUUID().toString(), new MemoryPersistence());
        mqttClient.connect();
        mqttClient.subscribe("/"+id+"/#", 1);

        mqttClient.setCallback(app);
    }
    long acc =0;
    int i=0;
    long start= System.nanoTime();
    static  int id=0;
    @Override
    public void connectionLost(Throwable throwable) {

    }

    @Override
    public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {

        i++;
        acc = (System.nanoTime()-start);
        if(acc/1000000&gt;1000){
            start = System.nanoTime();
            System.out.println(String.valueOf((i * 1000000000.0) / acc));
            acc =0;
            i=0;
        }
    }

    @Override
    public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {

    }

}
</code></pre>

<p>E.g. running producer for topic 1 as:</p>

<pre><code>python Producers.py 1&amp;
</code></pre>

<p>What limits the paho client inside an java application?</p>