Difference between Active and Inactive Client

Asked by Paul Diston

What is the main difference between an Active and Inactive Client? For example, is a client active only due to it being connected in the last X minutes? Does a client become inactive after a certain amount of time or because that client's topic hasn't had any messages published to it in a certain time frame?

The reason for my question is that I am trying to test the maximum number of clients that the mosquitto broker can handle and I seem to be reaching a 550 client limit of active clients before the clients then start to become inactive. I am using a single Windows Client to create the clients therefore have I reached a workable limit by using a single application to create these clients, or have I reached a limit based on the Mosquitto broker?

We are looking to have around 3000 clients connected at any one time, is this going to be possible with a single Mosquitto instance? All 3000 clients will be connected via their own application (Windows Mobile).

The max_connections setting in the config file is set to default (-1). I notice that the comment in the config file states that a typical maximum is 1024.

Thank you for your time.

Question information

Language:
English Edit question
Status:
Answered
For:
mosquitto Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Roger Light (roger.light) said :
#1

Active clients are ones that are currently connected. Inactive clients are clients that have "clean session" set to false (i.e. they are persistent/durable) but that are not currently connected to the broker. I'll take your implied point that it's not exactly obvious what they are (although it is documented here: http://mosquitto.org/man/mosquitto-8.html )

There have been reports of 100,000 and 200,000 clients on a single broker, so 3000 should be no problem.

https://lists.launchpad.net/mosquitto-users/msg00106.html
https://lists.launchpad.net/mosquitto-users/msg00107.html

One thing to note is that the above is all on Linux. On Windows there is a hard limit of around 2000 clients due to the network functions used. This will change in the future but is a very large change.

I'm not sure about why you are hitting a limit at 550. Does the same thing happen if you use multiple instances of your program? Some things to check would be the keepalive value and the client ids. If you have keepalive set low (in the few seconds) then it is possible they are timing out. You must have unique client ids - if you connect with a duplicate id the already connected client will be disconnected.

The comment on typical maximum in the config file is meant to refer to the limit set by the OS that can be changed if you have the appropriate permissions. I'll see about making that a bit clearer.

Revision history for this message
Paul Diston (paul-diston) said :
#2

After running my application multiple times I have managed to get the number of inactive clients up to over 1000, I will keep running the application, creating clients with unique client ids until I reach 3000. If I do get to an inactive client count of over 3000, is it safe to say that we can support a solution with that many clients? I am not entirely sure how I can reproduce 3000 connected clients as I ran 8 instances of my application creating 100 clients each and this crashed my development machine.

Do you have any suggestions how I might reproduce 3000 connected clients?

The keep alive value that is set for each client that is connected is 10 seconds. By upping this value, am I more likely to be able to achieve the number of connected clients I require?

Thank you for your time.

Revision history for this message
Paul Diston (paul-diston) said :
#3

I have now run the client on 4 different machines trying to reach 800 active clients however the maximum I was able to reach was 592, this was before connection exceptions started happening and then the clients closed therefore disconnecting their associated active clients.

Would you expect the limit to be as low compared to both the number of inactive clients I can reach as well as the 2000 clients due to the network functions used?

Thank you for your time.

Revision history for this message
Paul Diston (paul-diston) said :
#4

After further investigation I am still running into a limited number of connected clients, between 380 and 600. I am not sure why this is.

Would bridging help in this scenario, if so, is there a step by step guide as to how to setup a bridge, running on a single server?

I would be keen to understand by a limit is being imposed.

Revision history for this message
Roger Light (roger.light) said :
#5

The way I have approached this in the past is to use a script to
launch many instances of the mosquitto_sub client. On Linux I would do
something like:

for a in $(seq 1 1000); do
    mosquitto_sub -t my/topic &
done

to launch 1000 instances for example, but I don't know how to achieve
the same result in Windows.

Increasing keepalive may improve the number of clients you can get
connected, but I wouldn't expect it to be a problem.

Could you try connecting your clients to test.mosquitto.org:1883? That
is configured to allow 16384 open sockets at once and I know that
there have been >4000 clients at once before. This will at least help
narrow down the problem if it is something peculiar about your
installation.

Revision history for this message
Paul Diston (paul-diston) said :
#6

I have just ran my test client 4 times to try and create 800 active clients and the number of active clients has maxed out at 643, currently sitting at 634.

I am performing this test from a single machine (my development machine).

I have now just tested on two machines and the number of active clients again maxed out at around 932, I was expecting 1200 active clients.

I am not sure where the limitation is. I don't seem to be able to reproduce the number of active clients I require without the majority of the active clients getting disconnected before the limit is reached.

Do you have any ideas what I can try next?

Revision history for this message
Roger Light (roger.light) said :
#7

I've tried to recreate this using the mosquitto Python module and the
code at https://gist.github.com/oojah/5188913 , and it works ok for
me. I do get some timeouts when connecting to test.mosquitto.org from
my slow home computer but I'm not too surprised because it uses 8GB of
ram which is lots more than it has... Could you give that code a go on
your local machine?

Revision history for this message
Paul Diston (paul-diston) said :
#8

I have tried the module you provided and was able to connect to the broker running on our server however I am seeeing similar results where clients are disconnecting prematurely.

I have included a section of the output from the module running (I send you the complete output if that would help) :-

http://pastebin.com/hkpmrXtT

I had to stop the testing as this was effecting our other testing environments.

I have also run the module, connecting to the test.mosquitto.org, however there was a high number of disconnections although the number of active clients did reach a maximum of 692, although I was expecting nearer 1000.

Revision history for this message
Paul Diston (paul-diston) said :
#9

Would it be possible for me to email you the test client I am using so that you could experience the same behaviour that I am seeing?

Revision history for this message
Roger Light (roger.light) said :
#10

Hi Paul,

Yes, that would be very useful, thanks.

Roger

Can you help with this problem?

Provide an answer of your own, or ask Paul Diston for more information if necessary.

To post a message you must log in.