Mqtt performance

0

How many messages per second can I expect to be able to send through a single Mqtt client connection? My messages are small, under 100 bytes. I am using the Java SDK, so software.amazon.awssdk.crt.mqtt.MqttClientConnection is the class.

At the moment I am sending messages this way:

int result = connection.publish(message).get(TIMEOUT_SECONDS, TimeUnit.SECONDS);

However I do not really need the result. Is it OK if I send the next message without waiting for the result of the previous?

My client is running on an EC2 instance in the same region so the connection ought to be pretty fast.

Thanks

  • I read somewhere else that there is a fixed quota of 100/second when sending shadow updates. I'm not sure if this is true. I looked at the quotas page and there are hundreds of quotas listed, I don't know which ones apply to my situation. I am using the Mqtt connection to send shadow updates. For example $aws/things/<thing-name>/shadow/update. When I have a large number of updates to send it's always one update per thing to a large number of things, not many updates to one thing.

1 Answer
2
Accepted Answer

Hi Frank.

How many messages per second can I expect to be able to send through a single Mqtt client connection?

Each MQTT client connection to IoT Core has a hard limit of 100 messages per second and throughput of 512KB/s. These are covered in the message broker limits. Specifically Publish requests per second per connection and Throughput per second per connection. With your messages being under 100 bytes, the 100 messages per second limit is what you'll hit first. This limit is the sum of inbound and outbound. This video gives a nice introduction to this limit, and to message throttling: https://www.youtube.com/watch?v=vQRBQ5yhEP0. As you'll see, it's possible to exceed 100 for short bursts, without being throttled. The video also covers how to monitor for thottling, so you know when it happens.

Is it OK if I send the next message without waiting for the result of the previous?

Yes. Per the video though, you will quickly hit the limits.

Because of these limits, a cloud (or mobile) application will often not use an MQTT client connection to interact with a device fleet. You can instead use the AWS SDK (not the IoT device SDK) to interact with the IoT data plane using HTTP: https://docs.aws.amazon.com/iot/latest/apireference/API_Operations_AWS_IoT_Data_Plane.html. With these methods in the Java SDK: https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/iotdataplane/IotDataPlaneAsyncClient.html. HTTP is not constrained to 100 messages per second, so you can call the publish method at a higher rate. And there's a separate API/method for updating shadows. Please be aware though that you can't subscribe using HTTP.

it's always one update per thing to a large number of things

In that case, I wonder if shadows is the best way. It's generally suited for 1:1 interaction with devices. If you routinely need to make an update to a large group of devices, or to your whole fleet, then jobs may better suited. They are a 1:many pattern.

profile pictureAWS
EXPERT
Greg_B
answered 3 months ago
profile picture
EXPERT
reviewed a month ago
profile picture
EXPERT
reviewed 3 months ago
  • Thanks for all the information. In my case it would be easiest to create multiple client connections and make sure they don't exceed the rate limit.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions