Configure Throughput for Azure Event Hubs
Optimizing throughput is crucial for the efficient operation of your Azure Event Hubs. This guide explains how to configure and manage throughput units (TUs) and processing units (PUs) to meet your application's demands.
Understanding Throughput Units (TUs)
Throughput Units (TUs) are the primary metric for measuring the ingress and egress capacity of an Event Hubs namespace. Each TU provides a specific amount of ingress and egress bandwidth per second. You can provision TUs at the namespace level or at the individual Event Hub level.
Provisioning TUs
You can provision TUs using the Azure portal, Azure CLI, or Azure Resource Manager (ARM) templates.
Azure Portal
- Navigate to your Event Hubs namespace in the Azure portal.
- Under "Settings," select "Event Hubs."
- Click on the specific Event Hub you want to configure or create a new one.
- In the configuration pane, adjust the "Throughput units" slider or input field.
- Click "Save."
Azure CLI
az eventhubs event-hub update \
--resource-group myResourceGroup \
--namespace-name myNamespace \
--name myEventHub \
--throughput-units 4
Scaling TUs
It's often necessary to scale TUs up or down based on your application's workload. Event Hubs supports auto-scaling for Standard and Premium tiers, which can automatically adjust TUs based on predefined metrics.
Processing Units (PUs) for Kafka
If you are using Event Hubs for Kafka (EH Kafka), throughput is managed differently using Processing Units (PUs). EH Kafka provides a Kafka-compatible endpoint, and PUs are allocated per partition.
Configuring PUs
PUs are configured when you create or update an Event Hubs namespace in the Premium or Dedicated tier.
Azure Portal (for EH Kafka)
- Navigate to your Event Hubs namespace in the Azure portal.
- Under "Settings," select "Overview."
- You will see options to configure "Processing Units" for Kafka.
- Adjust the slider or input the desired number of PUs.
- Click "Save."
Azure CLI (for EH Kafka)
az eventhubs namespace update \
--resource-group myResourceGroup \
--name myNamespace \
--capacity 4 \
--sku Premium \
--zone-redundancy Disabled
Note: The exact CLI command and parameters might vary depending on the tier and specific EH Kafka configuration.
Monitoring Throughput
Regularly monitoring your Event Hubs throughput is essential to identify bottlenecks and optimize resource usage. Key metrics include:
- Incoming Requests
- Outgoing Requests
- Incoming Bytes
- Outgoing Bytes
- Throttled Requests (for TUs)
Use Azure Monitor to visualize these metrics and set up alerts for when thresholds are approached or exceeded.
Best Practices for Throughput Management
- Start with a conservative TU/PU allocation and gradually increase it based on observed load.
- Monitor metrics closely and adjust allocations proactively.
- Utilize partitioning effectively to distribute load across Event Hubs.
- Understand the difference between TUs (for Event Hubs protocol) and PUs (for EH Kafka).
- Leverage auto-scaling where available to handle fluctuating workloads.