事件中心常见问题Event Hubs frequently asked questions


什么是事件中心命名空间?What is an Event Hubs namespace?

命名空间是事件中心主题的范围容器。A namespace is a scoping container for Event Hub Topics. 它提供唯一的 FQDNIt gives you a unique FQDN. 命名空间充当容装多个事件中心主题的应用程序容器。A namespace serves as an application container that can house multiple Event Hub Topics.

何时创建新的命名空间而不是使用现有的命名空间?When do I create a new namespace vs. use an existing namespace?

容量分配(吞吐量单位 (TU))在命名空间级别进行计费。Capacity allocations (throughput units (TUs)) are billed at the namespace level. 命名空间也与区域相关联。A namespace is also associated with a region.

在以下任一情况下,你可能希望创建新的命名空间,而不是使用现有的命名空间:You may want to create a new namespace instead of using an existing one in one of the following scenarios:

  • 需要与新区域关联的事件中心。You need an Event Hub associated with a new region.
  • 需要与其他订阅关联的事件中心。You need an Event Hub associated with a different subscription.
  • 需要一个具有不同容量分配的事件中心(即,具有添加的事件中心的命名空间的容量需求将超过 40 TU 阈值,并且你不希望使用专用群集)You need an Event Hub with a distinct capacity allocation (that is, the capacity need for the namespace with the added event hub would exceed the 40 TU threshold and you don't want to go for the dedicated cluster)

事件中心基本和标准这两种服务层有什么不同?What is the difference between Event Hubs Basic and Standard tiers?

Azure 事件中心标准层提供的功能超出了基本层中提供的功能。The Standard tier of Azure Event Hubs provides features beyond what is available in the Basic tier. 以下功能是标准层附带的:The following features are included with Standard:

  • 更长的事件保留期Longer event retention
  • 其他中转连接,对于超出包含的数量的部分收取超额费用Additional brokered connections, with an overage charge for more than the number included
  • 多于单个使用者组More than a single consumer group
  • 捕获Capture

有关定价层的详细信息(包括专用事件中心),请参阅事件中心定价详细信息For more information about pricing tiers, including Event Hubs Dedicated, see the Event Hubs pricing details.

Azure 事件中心在哪些区域可用?Where is Azure Event Hubs available?

在所有支持的 Azure 区域中都可使用 Azure 事件中心。Azure Event Hubs is available in all supported Azure regions. 有关列表,请访问 Azure 区域页。For a list, visit the Azure regions page.

是否可以使用单个 AMQP 连接来与多个事件中心相互收发数据?Can I use a single AMQP connection to send and receive from multiple event hubs?

可以,但前提是所有事件中心都在同一个命名空间中。Yes, as long as all the event hubs are in the same namespace.

事件的最长保留期有多久?What is the maximum retention period for events?

事件中心标准版目前支持的最长保留期为七天。Event Hubs Standard tier currently supports a maximum retention period of seven days. 事件中心并非永久性的数据存储。Event hubs are not intended as a permanent data store. 大于 24 小时的保留期适用于将事件流重播到相同系统中的情形;例如,为了基于现有数据来培训或验证新机器学习模型。Retention periods greater than 24 hours are intended for scenarios in which it is convenient to replay an event stream into the same systems; for example, to train or verify a new machine learning model on existing data. 如果需要将消息保留 7 天以上,那么启用事件中心的事件中心捕获功能,可将数据从事件中心拉取到选定的存储帐户。If you need message retention beyond seven days, enabling Event Hubs Capture on your event hub pulls the data from your event hub into the Storage account your choosing. 启用捕获功能需要支付费用,具体因购买的吞吐量单位而异。Enabling Capture incurs a charge based on your purchased throughput units.

如何监视事件中心?How do I monitor my Event Hubs?

事件中心向 Azure Monitor 发出详尽指标用于提供资源的状态。Event Hubs emits exhaustive metrics that provide the state of your resources to Azure Monitor. 此外,参考指标不仅可以在命名空间级别,而且还能在实体级别评估事件中心服务的总体运行状况。They also let you assess the overall health of the Event Hubs service not only at the namespace level but also at the entity level. 了解 Azure 事件中心提供哪些监视功能。Learn about what monitoring is offered for Azure Event Hubs.

我需要在防火墙上打开哪些端口?What ports do I need to open on the firewall?

可以将以下协议与 Azure 服务总线配合使用,以便发送和接收消息:You can use the following protocols with Azure Service Bus to send and receive messages:

  • 高级消息队列协议 (AMQP)Advanced Message Queuing Protocol (AMQP)
  • Apache KafkaApache Kafka

请查看下表,了解需要打开哪些出站端口,以便使用这些协议与 Azure 事件中心通信。See the following table for the outbound ports you need to open to use these protocols to communicate with Azure Event Hubs.

协议Protocol 端口Ports 详细信息Details
AMQPAMQP 5671 和 56725671 and 5672 请参阅 AMQP 协议指南See AMQP protocol guide

我需要将哪些 IP 地址加入允许列表?What IP addresses do I need to whitelist?

若要找到适合加入连接的允许列表的 IP 地址,请执行以下步骤:To find the right IP addresses to white list for your connections, follow these steps:

  1. 从命令提示符处运行以下命令:Run the following command from a command prompt:

    nslookup <YourNamespaceName>.servicebus.chinacloudapi.cn
  2. 记下在 Non-authoritative answer 中返回的 IP 地址。Note down the IP address returned in Non-authoritative answer. 只有在你将命名空间还原到另一群集时,它才会更改。The only point in time it would change is if you restore the namespace on to a different cluster.

如果对命名空间使用区域冗余,则需执行一些额外的步骤:If you use the zone redundancy for your namespace, you need to do a few additional steps:

  1. 首先,在命名空间中运行 nslookup。First, you run nslookup on the namespace.

    nslookup <yournamespace>.servicebus.chinacloudapi.cn
  2. 记下“非权威回答” 部分中的名称,该名称采用下述格式之一:Note down the name in the non-authoritative answer section, which is in one of the following formats:

  3. 为每一个运行 nslookup,使用后缀 s1、s2 和 s3 获取所有三个在三个可用性区域中运行的实例的 IP 地址。Run nslookup for each one with suffixes s1, s2, and s3 to get the IP addresses of all three instances running in three availability zones,

吞吐量单位Throughput units

什么是事件中心吞吐量单元?What are Event Hubs throughput units?

事件中心内的吞吐量定义通过事件中心传入和传出的数据量,以 MB 或者 1-KB 事件的数目(以千计)为单位。Throughput in Event Hubs defines the amount of data in mega bytes or the number (in thousands) of 1-KB events that ingress and egress through Event Hubs. 此吞吐量以吞吐量单位 (TU) 来计量。This throughput is measured in throughput units (TUs). 在开始使用事件中心服务之前,需购买 TU。Purchase TUs before you can start using the Event Hubs service. 可以使用门户或事件中心资源管理器模板显式选择事件中心 TU。You can explicitly select Event Hubs TUs either by using portal or Event Hubs Resource Manager templates.

吞吐量单位是否适用于命名空间中的所有事件中心?Do throughput units apply to all event hubs in a namespace?

是的,吞吐量单位 (TU) 适用于事件中心命名空间中的所有事件中心。Yes, throughput units (TUs) apply to all event hubs in an Event Hubs namespace. 这意味着,TU 是在命名空间级别购买的,并在该命名空间下的事件中心之间共享。It means that you purchase TUs at the namespace level and are shared among the event hubs under that namespace. 每个 TU 为命名空间赋予以下功能:Each TU entitles the namespace to the following capabilities:

  • 入口事件(发送到事件中心的事件)最多为每秒 1 MB,但每秒不超过 1000 个入口事件、管理操作或控制 API 调用。Up to 1 MB per second of ingress events (events sent into an event hub), but no more than 1000 ingress events, management operations, or control API calls per second.
  • 出口事件(从事件中心使用的事件)最多达每秒 2 MB,但不超过 4096 个。Up to 2 MB per second of egress events (events consumed from an event hub), but no more than 4096 egress events.
  • 事件存储空间最多为 84 GB(对于默认的 24 小时保留期而言已足够)。Up to 84 GB of event storage (enough for the default 24-hour retention period).

吞吐量单位如何计费?How are throughput units billed?

吞吐量单位 (TU) 按小时计费。Throughput units (TUs) are billed on an hourly basis. 计费基于在给定的小时选择的最大单位数目。The billing is based on the maximum number of units that was selected during the given hour.

如何优化吞吐量单位的使用?How can I optimize the usage on my throughput units?

可以从最少的一个吞吐量单位 (TU) 着手,并启用自动扩充You can start as low as one throughput unit (TU), and turn on auto-inflate. 自动扩充功能可让你在流量/有效负载增大时扩展 TU。The auto-inflate feature lets you grow your TUs as your traffic/payload increases. 还可以针对 TU 数量设置上限。You can also set an upper limit on the number of TUs.

事件中心自动扩充功能的工作原理是什么?How does Auto-inflate feature of Event Hubs work?

使用自动扩充功能可以纵向扩展吞吐量单位 (TU)。The auto-inflate feature lets you scale up your throughput units (TUs). 这意味着,一开始可以购买较低的 TU,自动扩充会在入口流量增大时纵向扩展 TU。It means that you can start by purchasing low TUs and auto-inflate scales up your TUs as your ingress increases. 自动扩充是一种经济高效的选项,可让你完全控制 TU 数量。It gives you a cost-effective option and complete control of the number of TUs to manage. 这是一个仅限纵向扩展的功能,可以通过更新来完全控制 TU 数量的缩减。This feature is a scale-up only feature, and you can completely control the scaling down of the number of TUs by updating it.

可以从较低的吞吐量单位 (TU) 着手,例如 2 个 TU。You may want to start with low throughput units (TUs), for example, 2 TUs. 如果预测流量可能会增大到 15 TU,请对命名空间启用自动扩充功能,并将最大限制设置为 15 TU。If you predict that your traffic may grow to 15 TUs, turn-on the auto-inflate feature on your namespace, and set the max limit to 15 TUs. 现在,当流量增大时可以自动扩展 TU。You can now grow your TUs automatically as your traffic grows.

启用自动扩充功能是否会产生相关的费用?Is there a cost associated when I turn on the auto-inflate feature?

此功能不会产生相关的费用。There is no cost associated with this feature.

如何强制实施吞吐量限制?How are throughput limits enforced?

如果某个命名空间中所有事件中心间的总入口吞吐量或总入口事件率超过了聚合吞吐量单位限额,发送方会受到限制,并会收到指明已超出入口配额的错误信息。If the total ingress throughput or the total ingress event rate across all event hubs in a namespace exceeds the aggregate throughput unit allowances, senders are throttled and receive errors indicating that the ingress quota has been exceeded.

如果某个命名空间中所有事件中心间的总出口吞吐量或总出口事件率超过了聚合吞吐量单位限额,接收方会受到限制,并会收到指明已超出出口配额的错误信息。If the total egress throughput or the total event egress rate across all event hubs in a namespace exceeds the aggregate throughput unit allowances, receivers are throttled and receive errors indicating that the egress quota has been exceeded. 入口和出口配额是分开强制实施的,因此,任何发送方都不会使事件耗用速度减慢,并且接收方也无法阻止事件发送到事件中心。Ingress and egress quotas are enforced separately, so that no sender can cause event consumption to slow down, nor can a receiver prevent events from being sent into an event hub.

可预留/选择的吞吐量单位 (TU) 数量是否有限制?Is there a limit on the number of throughput units (TUs) that can be reserved/selected?

在多租户产品/服务中,吞吐量单位最多可扩展到 40 TU(可在门户中最多选择 20 TU,然后提出支持票证,在同一命名空间中将数目提高到 40 TU)。On a multi-tenant offering, throughput units can grow up to 40 TUs (you can select up to 20 TUs in the portal, and raise a support ticket to raise it to 40 TUs on the same namespace). 如果超出 40 TU,事件中心可提供名为“事件中心专用群集”的基于资源/容量的模型。 Beyond 40 TUs, Event Hubs offers the resource/capacity-based model called the Event Hubs Dedicated clusters. 专用群集按容量单位 (CU) 销售。Dedicated clusters are sold in Capacity Units (CUs).

专用群集Dedicated clusters

什么是事件中心专用群集?What are Event Hubs Dedicated clusters?

事件中心专用群集提供单租户部署来满足苛刻的客户要求。Event Hubs Dedicated clusters offer single-tenant deployments for customers with most demanding requirements. 此产品/服务会构建一个不受限于吞吐量单位的基于容量的群集。This offering builds a capacity-based cluster that is not bound by throughput units. 这意味着,可以利用该群集,根据群集的 CPU 和内存用量情况来引入和流式传输数据。It means that you could utilize the cluster to ingest and stream your data as dictated by the CPU and memory usage of the cluster. 有关详细信息,请参阅事件中心专用群集For more information, see Event Hubs Dedicated clusters.

一个容量单位可以实现多大的处理量?How much does a single capacity unit let me achieve?

对于专用群集,可以引入和流式传输的数据量取决于各种因素,例如生成者、使用者、引入和处理速率,等等。For a dedicated cluster, how much you can ingest and stream depends on various factors such as your producers, consumers, the rate at which you are ingesting and processing, and much more.

下表显示了我们在测试期间实现的基准结果:Following table shows the benchmark results that we achieved during our testing:

有效负载形状Payload shape 接收方Receivers 入口带宽Ingress bandwidth 入口消息Ingress messages 出口带宽Egress bandwidth 出口消息Egress messages TU 总数Total TUs 每个 CU 的 TU 数TUs per CU
100x1KB 批Batches of 100x1KB 22 400 MB/秒400 MB/sec 400K 消息/秒400k msgs/sec 800 MB/秒800 MB/sec 800K 消息/秒800k msgs/sec 400 TU400 TUs 100 TU100 TUs
10x10KB 批Batches of 10x10KB 22 666 MB/秒666 MB/sec 66.6K 消息/秒66.6k msgs/sec 1.33 GB/秒1.33 GB/sec 133K 消息/秒133k msgs/sec 666 TU666 TUs 166 TU166 TUs
6x32KB 批Batches of 6x32KB 11 1.05 GB/秒1.05 GB/sec 34K 消息/秒34k msgs / sec 1.05 GB/秒1.05 GB/sec 34K 消息/秒34k msgs/sec 1000 TU1000 TUs 250 TU250 TUs

测试中使用了以下条件:In the testing, the following criteria was used:

  • 一个专用的事件中心群集,其中使用了四个容量单位 (CU)。A dedicated Event Hubs cluster with four capacity units (CUs) was used.
  • 用于引入的事件中心包含 200 个分区。The event hub used for ingestion had 200 partitions.
  • 引入的数据由从所有分区接收数据的两个接收方应用程序接收。The data that was ingested was received by two receiver applications receiving from all partitions.

结果大致反映了一个专用事件中心群集可以实现的处理量。The results give you an idea of what can be achieved with a dedicated Event Hubs cluster. 此外,专用群集还为微批和长期保留方案启用了“事件中心捕获”。In addition, a dedicate cluster comes with the Event Hubs Capture enabled for your micro-batch and long-term retention scenarios.

如何创建事件中心专用群集?How do I create an Event Hubs Dedicated cluster?

可以通过提交提高配额支持请求或联系事件中心团队来创建事件中心专用群集。You create an Event Hubs dedicated cluster by submitting a quota increase support request or by contacting the Event Hubs team. 通常,我们需要花费大约两周时间来部署群集,并将其转交给你使用。It typically takes about two weeks to get the cluster deployed and handed over to be used by you. 此过程是暂时性的,到时会 Azure 门户或 Azure 资源管理器模板提供完全自助的服务,只需大约两个小时即可部署群集。This process is temporary until a complete self-serve is made available through the Azure portal or Azure Resource Manager templates, which takes about two hours to deploy the cluster.

最佳实践Best practices

需要多少分区?How many partitions do I need?

分区数在创建时指定,必须介于 2 到 32 之间。The number of partitions is specified at creation and must be between 2 and 32. 分区计数不可更改,因此在设置分区计数时应考虑长期规模。The partition count is not changeable, so you should consider long-term scale when setting partition count. 分区是一种数据组织机制,与使用方应用程序中所需的下游并行度相关。Partitions are a data organization mechanism that relates to the downstream parallelism required in consuming applications. 事件中心的分区数与预期会有的并发读取者数直接相关。The number of partitions in an event hub directly relates to the number of concurrent readers you expect to have. 有关分区的详细信息,请参阅分区For more information on partitions, see Partitions.

你可能希望在创建时将其设置为最高可能值,即 32。You may want to set it to be the highest possible value, which is 32, at the time of creation. 请记住,拥有多个分区将导致事件发送到多个分区而不保留顺序,除非你将发送方配置为仅发送到 32 个分区中的一个分区,剩下的 31 个分区是冗余分区。Remember that having more than one partition will result in events sent to multiple partitions without retaining the order, unless you configure senders to only send to a single partition out of the 32 leaving the remaining 31 partitions redundant. 在前一种情况下,必须跨所有 32 个分区读取事件。In the former case, you will have to read events across all 32 partitions. 在后一种情况下,除了必须在事件处理器主机上进行额外配置外,没有明显的额外成本。In the latter case, there is no obvious additional cost apart from the extra configuration you have to make on Event Processor Host.

事件中心设计用于允许每个用户组使用单个分区读取器。Event Hubs is designed to allow a single partition reader per consumer group. 在大多数用例中,四个分区的默认设置就足够了。In most use cases, the default setting of four partitions is sufficient. 如果希望扩展事件处理,则可以考虑添加其他分区。If you are looking to scale your event processing, you may want to consider adding additional partitions. 对分区没有特定的吞吐量限制,但是命名空间中的聚合吞吐量受吞吐量单位数限制。There is no specific throughput limit on a partition, however the aggregate throughput in your namespace is limited by the number of throughput units. 增加命名空间中吞吐量单位的数量时,可能需要添加额外分区来允许并发读取器实现其自身的最大吞吐量。As you increase the number of throughput units in your namespace, you may want additional partitions to allow concurrent readers to achieve their own maximum throughput.

但是,如果有一个模型,其中应用程序具有到特定分区的关联性,则增加分区数可能对你没有任何益处。However, if you have a model in which your application has an affinity to a particular partition, increasing the number of partitions may not be of any benefit to you. 有关详细信息,请参阅可用性和一致性For more information, see availability and consistency.


我可以在哪里找到更多定价信息?Where can I find more pricing information?

有关事件中心定价的完整信息,请参阅事件中心定价详细信息For complete information about Event Hubs pricing, see the Event Hubs pricing details.

保留事件中心事件超过 24 小时的话,要收取费用吗?Is there a charge for retaining Event Hubs events for more than 24 hours?

事件中心标准层允许消息保留期长于 24 小时,最长以 7 天为限。The Event Hubs Standard tier does allow message retention periods longer than 24 hours, for a maximum of seven days. 如果所存储事件总量的大小超过所选吞吐量单位数量的存储限制(每个吞吐量单位 84 GB),超出限制的部分会按公布的 Azure Blob 存储区费率收费。If the size of the total number of stored events exceeds the storage allowance for the number of selected throughput units (84 GB per throughput unit), the size that exceeds the allowance is charged at the published Azure Blob storage rate. 每个吞吐量单元的存储限制包括 24 小时(默认值)的保留期期间的所有存储成本,即使吞吐量单元已经用到了最大入口限制。The storage allowance in each throughput unit covers all storage costs for retention periods of 24 hours (the default) even if the throughput unit is used up to the maximum ingress allowance.

怎样对事件中心存储区大小进行计算和收费?How is the Event Hubs storage size calculated and charged?

所有存储的事件的总大小(包括所有事件中心内事件标头或磁盘存储器结构上的所有内部开销)按整天计量。The total size of all stored events, including any internal overhead for event headers or on disk storage structures in all event hubs, is measured throughout the day. 在一天结束时,计算存储区大小峰值。At the end of the day, the peak storage size is calculated. 每天的存储限制根据在当天所选择的吞吐量单元的最小数量(每个吞吐量单元提供 84 GB 的限制)来计算。The daily storage allowance is calculated based on the minimum number of throughput units that were selected during the day (each throughput unit provides an allowance of 84 GB). 如果总大小超过计算出的每日存储限额,超出的存储量会采用 Azure Blob 存储费率(按本地冗余存储费率)来计费。If the total size exceeds the calculated daily storage allowance, the excess storage is billed using Azure Blob storage rates (at the Locally Redundant Storage rate).

事件中心入口事件是怎样计算的?How are Event Hubs ingress events calculated?

发送到事件中心的每个事件均计为一条可计费消息。Each event sent to an event hub counts as a billable message. 入口事件 定义为小于等于 64 KB 的数据单位。An ingress event is defined as a unit of data that is less than or equal to 64 KB. 任何小于等于 64 KB 的事件均被视为一个计费事件。Any event that is less than or equal to 64 KB in size is considered to be one billable event. 如果该事件大于 64 KB,则根据事件大小按 64 KB 的倍数来计算计费事件的数量。If the event is greater than 64 KB, the number of billable events is calculated according to the event size, in multiples of 64 KB. 例如,发送到事件中心的 8-KB 事件按一个事件计费,而发送到事件中心的 96-KB 的消息则按两个事件计费。For example, an 8-KB event sent to the event hub is billed as one event, but a 96-KB message sent to the event hub is billed as two events.

从事件中心耗用的事件,以及管理操作和控制调用(例如检查点),不统计为计费入口事件,但会累计,上限为吞吐量单位限额。Events consumed from an event hub, as well as management operations and control calls such as checkpoints, are not counted as billable ingress events, but accrue up to the throughput unit allowance.

中转连接费用是否适用于事件中心?Do brokered connection charges apply to Event Hubs?

连接费用只在使用 AMQP 协议时适用。Connection charges apply only when the AMQP protocol is used. 使用 HTTP 发送事件没有连接费用,无论发送系统或设备的数量是多少。There are no connection charges for sending events using HTTP, regardless of the number of sending systems or devices. 如果计划使用 AMQP(例如,为了实现更高效的事件流式传输,或者为了对 IoT 命令和控制方案启用双向通信),请参阅事件中心定价信息页,了解有关每个服务层级中包括多少连接的详细信息。If you plan to use AMQP (for example, to achieve more efficient event streaming or to enable bi-directional communication in IoT command and control scenarios), see the Event Hubs pricing information page for details about how many connections are included in each service tier.

事件中心捕获如何计费?How is Event Hubs Capture billed?

命名空间中的任何事件中心启用了捕获选项时,即可启用捕获功能。Capture is enabled when any event hub in the namespace has the Capture option enabled. 事件中心捕获按所购买的吞吐量单位以小时计费。Event Hubs Capture is billed hourly per purchased throughput unit. 当吞吐量单位计数增加或减少时,事件中心捕获计费将在整个小时增量中反映这些变化。As the throughput unit count is increased or decreased, Event Hubs Capture billing reflects these changes in whole hour increments. 有关事件中心捕获计费的详细信息,请参阅事件中心定价信息For more information about Event Hubs Capture billing, see Event Hubs pricing information.

为事件中心捕获选择的存储帐户是否要付费?Do I get billed for the storage account I select for Event Hubs Capture?

捕获使用在事件中心启用捕获时提供的存储帐户。Capture uses a storage account you provide when enabled on an event hub. 因为这是你的存储帐户,任何针对此配置的费用更改都将计入你的 Azure 订阅。As it is your storage account, any changes for this configuration are billed to your Azure subscription.


是否有与事件中心关联的配额?Are there any quotas associated with Event Hubs?

如需所有事件中心配额的列表,请参阅配额For a list of all Event Hubs quotas, see quotas.


为什么在从其他订阅中删除命名空间后无法创建该命名空间?Why am I not able to create a namespace after deleting it from another subscription?

从订阅中删除命名空间时,请等待 4 个小时,然后才能在另一个订阅中使用相同的名称重新创建它。When you delete a namespace from a subscription, wait for 4 hours before recreating it with the same name in another subscription. 否则,可能会收到以下错误消息:Namespace already existsOtherwise, you may receive the following error message: Namespace already exists.

事件中心生成的异常有哪些,建议采取什么操作?What are some of the exceptions generated by Event Hubs and their suggested actions?

有关可能的事件中心异常的列表,请参阅异常概述For a list of possible Event Hubs exceptions, see Exceptions overview.

支持和 SLASupport and SLA

事件中心的技术支持可通过 社区论坛获得。Technical support for Event Hubs is available through the community forums. 计费和订阅管理支持免费提供。Billing and subscription management support is provided at no cost.

若要详细了解我们的 SLA,请参阅服务级别协议页面。To learn more about our SLA, see the Service Level Agreements page.

后续步骤Next steps

访问以下链接可以了解有关事件中心的详细信息:You can learn more about Event Hubs by visiting the following links: