Throughput Units (TUs) in Azure Event Hubs

Azure Event Hubs is a highly scalable data streaming platform and event ingestion service. A core concept that dictates its capacity and performance is the Throughput Unit (TU).

What are Throughput Units?

A Throughput Unit (TU) is a unit of pre-provisioned throughput for Azure Event Hubs. Each TU provides a specific amount of ingress and egress capacity for your Event Hubs namespace. The number of TUs you configure directly impacts how much data your Event Hub can ingest and how quickly consumers can process it.

When you create an Event Hubs namespace, you specify the number of TUs it should have. This pre-provisioning ensures that your application has the necessary resources available even during peak load, avoiding throttling and maintaining consistent performance.

Capacity per Throughput Unit

The exact capacity provided by a single TU can vary slightly depending on the pricing tier and configuration, but generally, a TU offers:

  • Ingress: Up to 1 MB per second or 1000 events per second (whichever comes first).
  • Egress: Up to 2 MB per second or 4096 events per second (whichever comes first).

It's important to note that these are the maximums for a single TU. Your actual throughput may be lower depending on factors like event size, message partitioning, and consumer processing speed.

Key Takeaway: Each TU provides a fixed block of ingress and egress capacity, allowing for predictable performance and cost management.

Scaling Throughput Units

You can scale the throughput of your Event Hubs namespace by increasing or decreasing the number of TUs. This can be done:

  • Manually: Through the Azure portal, Azure CLI, or PowerShell.
  • Automatically: Using the Auto-Inflate feature (available in the Standard and Premium tiers). Auto-Inflate allows the namespace to automatically increase its TUs up to a configured maximum, helping to handle sudden traffic spikes without manual intervention.

Manual Scaling

To scale manually, navigate to your Event Hubs namespace in the Azure portal, go to the 'Scale' or 'Throughput settings' section, and adjust the number of TUs. This change typically takes effect within a few minutes.

Auto-Inflate

The Auto-Inflate feature is a cost-effective way to manage throughput. You set a maximum number of TUs, and Event Hubs will gradually increase the TUs as needed, up to that limit. This prevents over-provisioning during low-traffic periods while ensuring capacity is available when needed.

Enabling Auto-Inflate:

  1. In the Azure portal, go to your Event Hubs namespace.
  2. Navigate to Settings > Throughput.
  3. Enable Auto-inflate.
  4. Set the Maximum number of Throughput Units.

TUs and Pricing Tiers

Throughput Units are a fundamental pricing factor for Azure Event Hubs. The number of TUs directly influences the cost of your Event Hubs namespace. Different pricing tiers (Basic, Standard, Premium) offer varying capabilities and associated costs for TUs:

  • Basic Tier: Offers a limited number of TUs and is suitable for development or low-throughput scenarios.
  • Standard Tier: Offers more TUs, Auto-Inflate, and better performance, making it suitable for most production workloads.
  • Premium Tier: Offers dedicated resources, significantly higher TUs, and guaranteed performance, ideal for mission-critical, high-throughput applications.

When to Adjust Throughput Units

Consider adjusting your TUs based on the following indicators:

  • High Ingress/Egress Throttling: If you observe throttling errors (e.g., 401 errors with specific error codes), your current TUs might be insufficient.
  • Consistent Peak Loads: If your application consistently experiences high traffic, pre-provisioning more TUs or enabling Auto-Inflate is recommended.
  • New Feature Rollouts or Increased User Activity: Anticipate higher loads when launching new features or during periods of increased user engagement.
  • Cost Optimization: During periods of low activity, you might consider reducing TUs (manually or by adjusting Auto-Inflate max) to manage costs.

Monitoring Throughput

Effective monitoring is crucial for managing TUs. Key metrics to watch in Azure Monitor include:

  • Ingress Throughput: Monitor the amount of data being sent to Event Hubs.
  • Egress Throughput: Monitor the amount of data being read by consumers.
  • Throttled Requests: Track the number of requests that were throttled.
  • Active Connections: Observe the number of active client connections.

Setting up alerts on these metrics can help you proactively manage your Event Hubs throughput.

Conclusion

Throughput Units are the primary mechanism for controlling and scaling the capacity of your Azure Event Hubs namespace. Understanding their role, capacity, and how to manage them through manual scaling or Auto-Inflate is essential for building reliable, performant, and cost-effective event-driven solutions on Azure.