Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the maximum number of topics that a MQTT broker can handle?

Tags:

node.js

mqtt

iot

I am using the node.js mosca MQTT broker for some internet of things (iot) application.

https://github.com/mcollina/mosca

What is the maximum number of topics that a MQTT broker, specifically mosca, can handle?

If I want to increase the number of allowed topics, is there a configuration parameter I can modify or which part of the code can I change?

like image 209
guagay_wk Avatar asked Oct 15 '25 17:10

guagay_wk


2 Answers

Without looking at the source for mosca I'm going to make a general statement about a generic broker.

The number of topics is going to be set by the number of topics that clients subscribe to as this list is what is searched when a new message is published, so assuming this list is kept I some kind of tree structure (which is very likely due to the hierarchical nature of topics) then the limit is likely to be the amount of memory on the server (assuming 64bit host).

Also since mosca runs on nodejs and as such single threaded, having a huge number of topics is likely to impact performance before you run out of memory.

like image 85
hardillb Avatar answered Oct 17 '25 06:10

hardillb


While hardlib's answer is correct, i would like to add that the number of possible topics is of course limited by the broker's / clients maximum topic length.

If that strictly follows the MQTT spec we are talking about 7^65536 possible topics (as explained here ), but for smaller brokers / clients (for example embedded stuff) the maximum topic length can be a lot smaller than 65536 bytes. PubSubClient for example has a default maximum length of 128 bytes for the entire packet.

like image 23
hammockdude Avatar answered Oct 17 '25 06:10

hammockdude



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!