ReadEventOptions.CacheEventCount Property


The maximum number of events that will be read from the Event Hubs service and held in a local memory cache when reading is active and events are being emitted to an enumerator for processing.

public int CacheEventCount { get; set; }
member this.CacheEventCount : int with get, set
Public Property CacheEventCount As Integer

Property Value


The CacheEventCount is a control that developers can use to help tune performance for the specific needs of an application, given its expected size of events, throughput needs, and expected scenarios for using Event Hubs.


Occurs when the requested count is less than 1.


The size of this cache has an influence on the efficiency of reading events from the Event Hubs service. The larger the size of the cache, the more efficiently service operations can be buffered in the background to improve throughput. This comes at the cost of additional memory use and potentially increases network I/O.

For scenarios where the size of events is small and many events are flowing through the system, using a larger CacheEventCount and PrefetchCount may help improve throughput. For scenarios where the size of events is larger or when processing of events is expected to be a heavier and slower operation, using a smaller size CacheEventCount and PrefetchCount may help manage resource use without incurring a non-trivial cost to throughput.

Regardless of the values, it is generally recommended that the PrefetchCount be at least 2-3 times as large as the CacheEventCount to allow for efficient buffering of service operations.

Applies to