Simulate 10,000 Azure IoT Hub Device connections from Azure Service Fabric cluster

◇◆丶佛笑我妖孽 提交于 2019-11-29 13:03:13

Take a look at this.

The second answer provides a sample that allows you to multiplex multiple devices onto one Amqp connection.

The approach you choose to monitor your devices won't scale well and will be hard to maintain.

Currently, service fabric has a limitation of how many instances you can place in a single node. For example: if you create an application with your ServiceBus service and span 10000 instances, you will hit this limitation, that is the number of nodes. i.e: if you have a 5 node cluster, you will be able to run only 5 instances of your service by using the default scaling approach.

To bypass this issue you have some options:

Partitioning:

To have a single stateless service running more partitions than the node count, you have to partition your service. Assuming you have a 5 node cluster and need 10000 instances, you will need 2000 partitions running on each node. If you use shared process and have enough ram to this, this approach might help you, please take a look at this thread and this thread before following this approach

Multiple Named Services:

Named service is the running service definition for one service type, in this case you would create one per device. like:

  • ServiceBusType
    • ServiceBus-Device1
    • ServiceBus-Device2
    • ServiceBus-Device3

This approach will consume too much resources in your machine, as you will be running one instance for each device, but easy to manage, as you can span new instances for each new device without affecting other running services.

Parallel Processing per instance:

Where each instance, would be responsible for processing multiple messages concurrently, in this case you would create 2000 connections for each instance(if running in a 5 instance/node per cluster). This will be lighter than the other approaches on resources consumption, but is a bit harder to maintain, as you will have to handle the balance yourself and might need an extra service to monitor and delegate tasks to all the services and ensure the messages are being processing evenly.

Summary:

One instance handling one connection at one message a time will required 10000 instances of your service, the partitioning will be similar but you can use a shared process to reduce memory consumption, but the memory consumption will still be high in both cases.

Multiple named services could be an option if the number of services were not too high, You also wouldn't be able to share the connection. So I won't recommend this approach for your scenario.

The third option, is the more resource friendly but you will have to find a way to partition the connections evenly throughout the cluster nodes.

You can also use a mixed approach, for example, you can have service handling multiple messages in parallel and a partitioned service to define the key range of devices.

Please take a look in the links I've mentioned.

I found that there is a DeviceClient constructor that allows the AmqpConnectionPoolSettings to be set.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!