Configuring Cache Client Timeouts (Windows Server AppFabric Caching)

Windows Server AppFabric caching features enable you to configure the length of cache client timeouts. You can control how long to wait for a response from the cache cluster. This topic covers two types of timeouts: channel open timeouts and request timeouts.

Some applications achieve performance benefits by setting short timeout durations and then appropriately handling timeout errors. Other applications may prefer to have relatively long timeout durations to reduce the frequency of these errors.

The timeouts discussed here do not apply to the initial connection to the cache cluster. This initial connection occurs when a new DataCacheFactory object is created. During this connection, an attempt is made to communicate with the cluster through one or more of the servers specified in the Servers property or hosts element of the application configuration file. Any network or cluster issues communicating with those servers could result in a delay in establishing the initial connection. To mitigate this delay, create the DataCacheFactory object in a secondary thread. Based on the programming model, the application should be able to function without the cache by using the source data until the connection with the cache cluster succeeds.

ChannelOpenTimeout

When a channel open timeout duration is exceeded, a DataCacheException is thrown with the ErrorCode set to RetryLater. The ChannelOpenTimeout configuration setting controls how long the cache client waits to establish a network connection with the server. You can choose to set this timeout to 0 if you want any errors to immediately return to the client.

To change this setting programmatically, configure the ChannelOpenTimeout property of the DataCacheFactoryConfiguration object.

To control this setting with an application configuration file, specify the timeout duration in milliseconds with the channelOpenTimeout attribute to the dataCacheClient element.

RequestTimeout

When a request timeout duration is exceeded, a DataCacheException is thrown with the ErrorCode set to Timeout. The RequestTimeout configuration setting controls how long the cache client waits to receive a response from the server from a specific API call. For example, if you called the Get method to retrieve an object from the cache, the request timeout would determine how long the cache client waits for a response before throwing an exception. Unlike the ChannelOpenTimeout, you should not set the RequstTimeout to 0, because this has the effect of causing a timeout error on every call to the server.

To change this setting programmatically, configure the RequestTimeout property of the DataCacheFactoryConfiguration object.

To control this setting with an application configuration file, specify the timeout duration in milliseconds with the requestTimeout attribute of the dataCacheClient element.

See Also

Concepts

Exception Handling Overview (Windows Server AppFabric Caching)
Common Exceptions (Windows Server AppFabric Caching)