参考 - IoT 中心配额和限制Reference - IoT Hub quotas and throttling

本文介绍 IoT 中心的配额,所提供的信息有助于你理解限制的工作原理。This article explains the quotas for an IoT Hub, and provides information to help you understand how throttling works.

配额和限制Quotas and throttling

每个 Azure 订阅最多可以有 50 个 IoT 中心和 1 个免费中心。Each Azure subscription can have at most 50 IoT hubs, and at most 1 Free hub.

每个 IoT 中心都在特定层中预配了特定单位数。Each IoT hub is provisioned with a certain number of units in a specific tier. 层和单位数决定了可以发送的消息的每日配额上限。The tier and number of units determine the maximum daily quota of messages that you can send. 用于计算每日配额的消息大小为 0.5 KB(适用于中心的免费层)和 4 KB(适用于所有其他层)。The message size used to calculate the daily quota is 0.5 KB for a free tier hub and 4KB for all other tiers. 有关详细信息,请参阅 Azure IoT 中心定价For more information, see Azure IoT Hub Pricing.

层还决定了 IoT 中心对所有操作强制实施的限制。The tier also determines the throttling limits that IoT Hub enforces on all operations.

IoT 即插即用IoT Plug and Play

在公开预览期间,IoT 即插即用设备将为每个接口发送单独的消息,这可能会增加计入消息配额的消息数量。During public preview, IoT Plug and Play devices will send separate messages per interface, which may increase the number of messages counted towards your message quota.

操作限制Operation throttles

操作限制是在分钟范围内应用的速率限制,主要是为了防止不当使用。Operation throttles are rate limitations that are applied in minute ranges and are intended to prevent abuse. 它们还受流量整形的约束。They're also subject to traffic shaping.

下表显示了强制限制。The following table shows the enforced throttles. 值与单个中心相关。Values refer to an individual hub.

限制Throttle 免费、B1 和 S1Free, B1, and S1 B2 和 S2B2 and S2 B3 和 S3B3 and S3
标识注册表操作(创建、检索、列出、更新、删除)Identity registry operations (create, retrieve, list, update, delete) 1.67/秒/单位(100/分钟/单位)1.67/sec/unit (100/min/unit) 1.67/秒/单位(100/分钟/单位)1.67/sec/unit (100/min/unit) 83.33/秒/单位(5,000/分钟/单位)83.33/sec/unit (5,000/min/unit)
新设备连接(此限制适用于建立_新连接_的速率,而不是连接总数)New device connections (this limit applies to the rate of new connections, not the total number of connections) 高于 100/秒或 12/秒/单位Higher of 100/sec or 12/sec/unit
例如,两个 S1 单位是 2*12 = 24 个新连接/秒,但你的单位至少有 100 个新连接/秒。For example, two S1 units are 2*12 = 24 new connections/sec, but you have at least 100 new connections/sec across your units. 如果有 9 个 S1 单位,则你的单位就有 108 个新连接/秒 (9*12)。With nine S1 units, you have 108 new connections/sec (9*12) across your units.
120 个新连接/秒/单位120 new connections/sec/unit 6,000 个新连接/秒/单位6,000 new connections/sec/unit
设备到云的发送Device-to-cloud sends 100 个发送操作/秒或 12 个发送操作/秒/单位,具体取决于哪一个更高Higher of 100 send operations/sec or 12 send operations/sec/unit
例如,两个 S1 单位是 2*12 = 24/秒,但是在所有单位中至少有 100 个发送操作/秒。For example, two S1 units are 2*12 = 24/sec, but you have at least 100 send operations/sec across your units. 如果有 9 个 S1 单位,则你的单位就有 108 个发送操作/秒 (9*12)。With nine S1 units, you have 108 send operations/sec (9*12) across your units.
120 个发送操作/秒/单位120 send operations/sec/unit 6,000 个发送操作/秒/单位6,000 send operations/sec/unit
云到设备的发送1Cloud-to-device sends1 1.67 个发送操作/秒/单位(100 条消息/分钟/单位)1.67 send operations/sec/unit (100 messages/min/unit) 1.67 个发送操作/秒/单位(100 个发送操作/分钟/单位)1.67 send operations/sec/unit (100 send operations/min/unit) 83.33 个发送操作/秒/单位(5,000 个发送操作/分钟/单位)83.33 send operations/sec/unit (5,000 send operations/min/unit)
云到设备的接收1Cloud-to-device receives1
(仅当设备使用 HTTPS 时)(only when device uses HTTPS)
16.67 个接收操作/秒/单位(1,000 个接收操作/分钟/单位)16.67 receive operations/sec/unit (1,000 receive operations/min/unit) 16.67 个接收操作/秒/单位(1,000 个接收操作/分钟/单位)16.67 receive operations/sec/unit (1,000 receive operations/min/unit) 833.33 个接收操作/秒/单位(50,000 个接收操作/分钟/单位)833.33 receive operations/sec/unit (50,000 receive operations/min/unit)
文件上传File upload 1.67 次文件上传启动/秒/单位(100/分钟/单位)1.67 file upload initiations/sec/unit (100/min/unit) 1.67 次文件上传启动/秒/单位(100/分钟/单位)1.67 file upload initiations/sec/unit (100/min/unit) 83.33 次文件上传启动/秒/单位(5,000/分钟/单位)83.33 file upload initiations/sec/unit (5,000/min/unit)
直接方法1Direct methods1 160KB/秒/单位2160KB/sec/unit2 480KB/秒/单位2480KB/sec/unit2 24MB/秒/单位224MB/sec/unit2
查询Queries 20/分钟/单位20/min/unit 20/分钟/单位20/min/unit 1,000/分钟/单位1,000/min/unit
孪生(设备和模块)读取1Twin (device and module) reads1 100/秒100/sec 高于 100/秒或 10/秒/单位Higher of 100/sec or 10/sec/unit 500/秒/单位500/sec/unit
孪生更新(设备和模块)1Twin updates (device and module)1 50/秒50/sec 高于 50/秒或 5/秒/单位Higher of 50/sec or 5/sec/unit 250/秒/单位250/sec/unit
作业操作1Jobs operations1
(创建、更新、列表、删除)(create, update, list, delete)
1.67/秒/单位(100/分钟/单位)1.67/sec/unit (100/min/unit) 1.67/秒/单位(100/分钟/单位)1.67/sec/unit (100/min/unit) 83.33/秒/单位(5,000/分钟/单位)83.33/sec/unit (5,000/min/unit)
作业设备操作1Jobs device operations1
(更新孪生、调用直接方法)(update twin, invoke direct method)
10/秒10/sec 高于 10/秒或 1/秒/单位Higher of 10/sec or 1/sec/unit 50/秒/单位50/sec/unit
配置和 Edge 部署1Configurations and edge deployments1
(创建、更新、列表、删除)(create, update, list, delete)
0.33/秒/单位(20/分钟/单位)0.33/sec/unit (20/min/unit) 0.33/秒/单位(20/分钟/单位)0.33/sec/unit (20/min/unit) 0.33/秒/单位(20/分钟/单位)0.33/sec/unit (20/min/unit)
设备流启动率1Device stream initiation rate1 5 个新流/秒5 new streams/sec 5 个新流/秒5 new streams/sec 5 个新流/秒5 new streams/sec
最大并发连接设备流数1Maximum number of concurrently connected device streams1 5050 5050 5050
最大设备流数据传输1(每日聚合量)Maximum device stream data transfer1 (aggregate volume per day) 300 MB300 MB 300 MB300 MB 300 MB300 MB

1此功能在 IoT 中心的基本层内不可用。1This feature is not available in the basic tier of IoT Hub. 有关详细信息,请参阅如何选择正确的 IoT 中心For more information, see How to choose the right IoT Hub.
2限制计量大小为 4 KB。2Throttling meter size is 4 KB.

限制详细信息Throttling Details

  • 计量大小决定了以什么样的增量来使用限制。The meter size determines at what increments your throttling limit is consumed. 如果直接调用的有效负载为 0 到 4 KB,则将其计为 4 KB。If your direct call's payload is between 0 and 4 KB, it is counted as 4 KB. 可以每个单位每秒进行高达 40 次的调用,然后才会达到 160 KB/秒/单位的限制。You can make up to 40 calls per second per unit before hitting the limit of 160 KB/sec/unit.

    同样,如果有效负载为 4 KB 到 8 KB,则每个调用计为 8 KB,可以每个单位每秒进行高达 20 次的调用,然后才会达到最大限制。Similarly, if your payload is between 4 KB and 8 KB, each call accounts for 8 KB and you can make up to 20 calls per second per unit before hitting the max limit.

    最后,如果有效负载为 156 KB 到 160 KB,则在中心只能每个单位每秒进行 1 次调用,然后就会达到 160 KB/秒/单位的限制。Finally, if your payload size is between 156KB and 160 KB, you'll be able to make only 1 call per second per unit in your hub before hitting the limit of 160 KB/sec/unit.

  • 就 S2 层级的作业设备操作(更新孪生、调用直接方法)来说, 50/秒/单位仅适用于使用作业来调用方法的情况。For Jobs device operations (update twin, invoke direct method) for tier S2, 50/sec/unit only applies to when you invoke methods using jobs. 如果直接调用直接方法,则适用原始的 24 MB/秒/单位(针对 S2)限制。If you invoke direct methods directly, the original throttling limit of 24 MB/sec/unit (for S2) applies.

  • 配额是每天可以在中心发送的聚合消息数。 Quota is the aggregate number of messages you can send in your hub per day. 可以在 IoT 中心定价页上的“消息总数/天”列下找到中心的配额限制。 You can find your hub's quota limit under the column Total number of messages /day on the IoT Hub pricing page.

  • 云到设备和设备到云限制决定了发送消息的最大速率(在不考虑 4 KB 区块情况下的消息数)。 Your cloud-to-device and device-to-cloud throttles determine the maximum rate at which you can send messages -- number of messages irrespective of 4 KB chunks. 每条消息最大可以为 256 KB(最大消息大小)。Each message can be up to 256 KB which is the maximum message size.

  • 最好是限制调用数,这样就不会达到/超过限制。It's a good practice to throttle your calls so that you don't hit/exceed the throttling limits. 如果你达到限制,IoT 中心会以错误代码 429 进行响应,客户端应回退并重试。If you do hit the limit, IoT Hub responds with error code 429 and the client should back-off and retry. 这些限制是按中心(在某些情况下,按中心/单位)应用的。These limits are per hub (or in some cases per hub/unit). 有关详细信息,请参阅管理连接和可靠的消息传送/重试模式For more information, refer to Manage connectivity and reliable messaging/Retry patterns.

流量整形Traffic shaping

为了应对突发流量,IoT 中心可在有限的一段时间内接受超出限制的请求。To accommodate burst traffic, IoT Hub accepts requests above the throttle for a limited time. 其中的前几个请求会立即得到处理。The first few of these requests are processed immediately. 但是,如果请求数持续违反限制,IoT 中心会开始将请求放入队列,并以限制速率对其进行处理。However, if the number of requests continues violate the throttle, IoT Hub starts placing the requests in a queue and processed at the limit rate. 此效应称为“流量整形”。 This effect is called traffic shaping. 此外,此队列的大小受到限制。Furthermore, the size of this queue is limited. 如果违反限制的情况持续出现,队列最终将会填满,而 IoT 中心会开始拒绝请求并引发 429 ThrottlingExceptionIf the throttle violation continues, eventually the queue fills up, and IoT Hub starts rejecting requests with 429 ThrottlingException.

例如,如果你使用模拟设备每秒将 200 条设备到云的消息发送到 S1 IoT 中心(它限制为每秒发送 100 条 D2C 消息)。For example, you use a simulated device to send 200 device-to-cloud messages per second to your S1 IoT Hub (which has a limit of 100/sec D2C sends). 在前一两分钟,消息会立即得到处理。For the first minute or two, the messages are processed immediately. 但是,由于设备发送的消息数持续超过限制,IoT 中心随后将每秒处理 100 条消息,并将剩余的消息放入队列。However, since the device continues to send more messages than the throttle limit, IoT Hub begins to only process 100 messages per second and puts the rest in a queue. 此时你会注意到延迟增大。You start noticing increased latency. 最终,在队列填满后,你会开始收到 429 ThrottlingException,并且 IoT 中心指标中的“限制错误数”会开始增加。Eventually, you start getting 429 ThrottlingException as the queue fills up, and the "number of throttle errors" in IoT Hub's metrics starts increasing.

标识注册表操作限制Identity registry operations throttle

设备标识注册表操作用于设备管理与预配方案中的运行时使用。Device identity registry operations are intended for run-time use in device management and provisioning scenarios. 通过导入和导出作业可以支持读取或更新大量的设备标识。Reading or updating a large number of device identities is supported through import and export jobs.

设备连接限制Device connections throttle

“设备连接” 限制控制与 IoT 中心建立新设备连接的速率。The device connections throttle governs the rate at which new device connections can be established with an IoT hub. “设备连接” 限制不控制同时连接的最大设备数。The device connections throttle does not govern the maximum number of simultaneously connected devices. 设备连接 速率限制取决于为 IoT 中心预配的单位数。The device connections rate throttle depends on the number of units that are provisioned for the IoT hub.

例如,如果购买的是单一 S1 单位,则限制为每秒 100 个连接。For example, if you buy a single S1 unit, you get a throttle of 100 connections per second. 因此,若要连接 100,000 台设备,至少需要花费 1,000 秒(大约 16 分钟)。Therefore, to connect 100,000 devices, it takes at least 1,000 seconds (approximately 16 minutes). 但是,同时连接的设备数可与用户在标识注册表中注册的设备数相同。However, you can have as many simultaneously connected devices as you have devices registered in your identity registry.

其他限制Other limits

IoT 中心强制实施其他操作限制:IoT Hub enforces other operational limits:

操作Operation 限制Limit
设备Devices 可注册到单个 IoT 中心的设备和模块的总数上限为 1,000,000。The total number of devices plus modules that can be registered to a single IoT hub is capped at 1,000,000. 只能联系 Microsoft 支持部门来提高此限制。The only way to increase this limit is to contact Microsoft Support.
文件上传File uploads 每个设备 10 个并发文件上传。10 concurrent file uploads per device.
作业1Jobs1 最大并发作业数为 1(对于“免费”层和 S1)、5(对于 S2)和 10(对于 S3)。Maximum concurrent jobs is 1 (for Free and S1), 5 (for S2), and 10 (for S3). 但是,所有层的最大并发设备导入/导出作业数为 1。However, the max concurrent device import/export jobs is 1 for all tiers.
作业历史记录最多保留 30 天。Job history is retained up to 30 days.
额外终结点Additional endpoints 付费 SKU 中心可能有 10 个额外终结点。Paid SKU hubs may have 10 additional endpoints. 免费 SKU 中心可能有 1 个额外终结点。Free SKU hubs may have one additional endpoint.
消息路由查询Message routing queries 付费 SKU 中心可能有 100 个路由查询。Paid SKU hubs may have 100 routing queries. 免费 SKU 中心可包含 5 个路由查询。Free SKU hubs may have five routing queries.
消息扩充Message enrichments 付费 SKU 中心可能有最多 10 个消息扩充。Paid SKU hubs can have up to 10 message enrichments. 免费 SKU 中心可能有最多 2 个消息扩充。Free SKU hubs can have up to 2 message enrichments.
设备到云的消息传送Device-to-cloud messaging 最大消息大小 256 KBMaximum message size 256 KB
云到设备的消息传递1Cloud-to-device messaging1 最大消息大小为 64 KB。Maximum message size 64 KB. 最大传递挂起消息数为每个设备 50 个。Maximum pending messages for delivery is 50 per device.
直接方法1Direct method1 直接方法有效负载的最大大小为 128 KB。Maximum direct method payload size is 128 KB.
自动设备配置1Automatic device configurations1 每个付费 SKU 中心 100 个配置。100 configurations per paid SKU hub. 每个免费 SKU 中心 20 个配置。20 configurations per free SKU hub.
IoT Edge 自动部署1IoT Edge automatic deployments1 每个部署 20 个模块。20 modules per deployment. 每个付费 SKU 中心 100 个部署。100 deployments per paid SKU hub. 每个免费 SKU 中心 10 个部署。10 deployments per free SKU hub.
孪生1Twins1 每个孪生部分(标记、所需属性、报告的属性)的最大大小为 8 KBMaximum size per twin section (tags, desired properties, reported properties) is 8 KB

1此功能在 IoT 中心的基本层内不可用。1This feature is not available in the basic tier of IoT Hub. 有关详细信息,请参阅如何选择正确的 IoT 中心For more information, see How to choose the right IoT Hub.

提高配额或限制Increasing the quota or throttle limit

无论何时,都可通过增加 IoT 中心内的预配单位数来提高配额或限制。At any given time, you can increase quotas or throttle limits by increasing the number of provisioned units in an IoT hub.

延迟Latency

IoT 中心致力于降低所有操作的延迟。IoT Hub strives to provide low latency for all operations. 但是,由于网络条件和其他不可预测因素,它不能保证特定的延迟。However, due to network conditions and other unpredictable factors it cannot guarantee a certain latency. 在设计解决方案时,应该:When designing your solution, you should:

  • 避免对任何 IoT 中心操作的最大延迟进行假定。Avoid making any assumptions about the maximum latency of any IoT Hub operation.
  • 在离设备最近的 Azure 区域预配 IoT 中心。Provision your IoT hub in the Azure region closest to your devices.
  • 请考虑在设备上或在离设备近的网关上使用 Azure IoT Edge 执行易受延迟影响的操作。Consider using Azure IoT Edge to perform latency-sensitive operations on the device or on a gateway close to the device.

如前所述,多个 IoT 中心单位影响限制,但未提供任何附加延迟权益或保证。Multiple IoT Hub units affect throttling as described previously, but do not provide any additional latency benefits or guarantees. 如果发现操作延迟意外增加,请与 Microsoft 支持联系。If you see unexpected increases in operation latency, contact Microsoft Support.

后续步骤Next steps

此 IoT 中心开发人员指南中的其他参考主题包括:Other reference topics in this IoT Hub developer guide include: