Toofle
Toofle

Reputation: 214

IoT Edge SendEventBatchAsync

I've currently been experimenting with the Azure IoT Edge and trying to make it cheaper to send lots of telemetry to IoT Hub.

At first I was using the DeviceClient and the method SendEventAsync() to send messages. Now I'm saving them and sending them as a single batch.

From my understanding this was implemented to reduce throughput to IoTHub and make it cheaper to send telemetry to IoT Hub. But when I look into IoT Hub I still have the same amount of messages used whether I send them immediately or whenever I save them up and send them as a batch every 5 minutes.

I've been searching the net for a while now and I don't know what I'm missing.

I hope anyone can help me with this issue.

Some more information and things I tried: I'm using C# to write the software. I'm sending messages using a DeviceClient through a transparent gateway using AMQP. I've tried batching with MQTT or HTTP1 but both don't work. HTTP1 isn't even supported by the DeviceClient.

Upvotes: 2

Views: 890

Answers (1)

silent
silent

Reputation: 16138

From the Azure Pricing page FAQs:

The maximum message size for messages sent from a device to the cloud is 256 KB. These messages are metered in 4 KB blocks for the paid tiers so for instance if the device sends a 16 KB message via the paid tiers it will be billed as 4 messages.

So it does not really seem to matter if you use SendEventAsync() or SendEventBatchAsync() in terms of pricing.

Also, when it comes to IoT Edge: Over which protocol your leaf device connects to the Edge Hub does not influence how the Edge Hub connects to IoT Hub. By default it will use AMQP but you can change that via the UpstreamProtocol env variable if you need to.

As discussed below in the comments:

My understanding is that the 4KB per message is the maximum. Also smaller messages will be counted as 1 message each. What you could do is to batch messages internally and put multiple of your actual telemetry messages into one Microsoft.Azure.Devices.Client.Message. Those should be the ones that IoT Hub quota counts against. What you do in terms of batching inside the payload of those does not matter to the quota

Upvotes: 3

Related Questions