How exactly does Event Hubs Throttling Work?

This is a good question and it comes up fairly often. Event Hubs provides capacity through a concept called a Throughput Unit (TU). A TU entitles you to a maximum of 1000 events per second or 1 MB per second of ingress (traffic to Event Hubs) and double that amount in egress - traffic out of Event Hubs. This number is global for the namespace and shared across all Event Hubs in that namespace. You can change your TU setting in the Azure portal and select a value between 1 and 20. TUs are charged per hour, but the increase is effective almost immediately. If you need more than 20 TUs you can issue a support ticket in the Azure portal.


So what happens when you hit this limit, which by default is 1 TU? We throttle you. Throttling means we will deny request. We do this with a fairness based approach so that all of your senders or readers should get an even amount of throttling based on the traffic they send. How we do this is we keep a short window running total of your traffic. When it exceeds your purchased TU limit we will throttle. For .NET clients this means a ServerBusyException. This will happen both on senders (producers) and readers (consumers).


When you receive the ServerBusyException take a look at the Detail property to see more information. It will have a more detailed message and an error code. An error code of 50002 means you are being throttled.


You should log these so you can know when you need to increase your TUs.


For a complete list of messaging exceptions that Service Bus may throw see: Appendix: Messaging Exceptions on MSDN.