Share via


ReadEventOptions.PrefetchCount Property

Definition

The number of events that will be eagerly requested from the Event Hubs service and queued locally without regard to whether a read operation is currently active, intended to help maximize throughput by allowing events to be read from from a local cache rather than waiting on a service request.

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

Property Value

The PrefetchCount 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.

Exceptions

Occurs when the requested count is negative.

Remarks

The size of the prefetch count 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