How do I know if I hit MQTT Resource Limits?

Hello,

I know in the back of my head that there are MQTT Limits:
Losant’s MQTT broker usage is subject to a few limits:

30 messages in a 15-second window per topic (or, on average, two per second)
300 messages in a 15-second window per client connection (or, on average, 20 per second)
300 device connections in a 15-second window per application (or, on average, 20 per second)
256KB per message

Its more that second and third one that I am slightly worried about.
I’ve taken some consideration to place each customer onto its own ‘client connection’ by virtue of its own access_key. That would help the second limitation, but not necessarily the third.

However should that even not be enough, is there anyway, in Losant itself, I can monitor how close I am to these limits?

From searching the forums, it looks like these will appear in the Application Overview debug tab pane.
Is there wanyway to trigger an email or something else if I happen to not be watching that pane at a given time?

Should I instead handle throttling prior to Losant, knowing that these are my limits?

First, this -

I’ve taken some consideration to place each customer onto its own ‘client connection’ by virtue of its own access_key.

Individual access keys do not define client connections; rather, it’s devices connecting to the MQTT broker that define client connections. If 100 devices connect using the same access key or individual access keys per device, that counts as 100 connections either way. Also bear in mind that peripheral and floating devices do not count as connecting to the broker when their respective gateways connect.

For the first two limits, these result from the device being connected to the broker and taking some action that then gets them kicked off. This means that, using an Application Workflow with a Device: Disconnect Trigger, you could catch those events based on the disconnectReason provided in the initial payload.

That last one dealing with the throttle limit of device connections per second is harder to catch - but for most users it is also a much rarer occurrence. One thing you could do is, in your client connection code, set a random time to wait before reconnecting - say anywhere from 1 to 15 seconds - to help spread out the load of devices connecting all at once. We actually have this option baked into our Gateway Edge Agent for this same purpose. (See the MQTT_RECONNECT_INTERVAL and MQTT_RECONNECT_VARIABILITY options in the advanced settings.)

Let me know if you have any other questions about this approach.