Azure Event Hubs is designed to handle high-throughput, real-time data streaming. Effective scaling is crucial to ensure your application can ingest and process events reliably under varying load conditions. This section covers the primary mechanisms for scaling Event Hubs and best practices to follow.
The fundamental unit of throughput in Azure Event Hubs is the Throughput Unit (TU). Each TU provides a guaranteed level of ingress and egress throughput. There are two main types of TUs:
The number of TUs allocated to an Event Hub namespace directly impacts its capacity. You can scale the number of TUs up or down based on your application's needs.
You can manually adjust the number of TUs for your Event Hub namespace through the Azure portal, Azure CLI, PowerShell, or SDKs.
# Example using Azure CLI
az eventhubs namespace update \
--resource-group <your-resource-group> \
--name <your-event-hub-namespace> \
--capacity <new-number-of-TUs>
For Event Hubs in the Standard tier, you can enable auto-inflation. With auto-inflation, Event Hubs automatically increases the number of TUs when incoming traffic approaches the provisioned capacity. This is a valuable feature to prevent throttling during unexpected traffic spikes.
Event Hubs distributes data across partitions. The number of partitions impacts parallelism. A higher number of partitions allows for greater consumer parallelism, which is essential for processing high volumes of data.
Choosing the right number of partitions is critical. Aim for a number that allows your consumers to operate in parallel without causing contention. A common practice is to set the number of partitions to a multiple of your expected peak consumer instances.
| Scenario | Recommendation |
|---|---|
| Variable, unpredictable load (Standard tier) | Enable Auto-Inflation. Monitor and manually adjust max TUs if needed. |
| Consistent, high-volume load (Standard/Premium) | Manually provision sufficient TUs. Monitor and adjust proactively. |
| Need for dedicated resources and guaranteed performance | Consider Premium tier and carefully provision TUs and partitions. |
| High processing parallelism required | Increase the number of partitions. Ensure consumers are designed for parallel reads. |
By understanding and applying these scaling principles, you can ensure that your Azure Event Hubs deployment remains performant and reliable, even as your data streaming needs grow.