Keep Alive
In the context of distributed caching, having a stable network state is an important aspect. The Keep Alive property in NCache is a connectivity tool that prevents the automatic closure of idle client-server sockets. By sending periodic heartbeats over open connections, NCache prevents stateful firewalls and load balancers from closing idle paths, thus providing a constant communication channel for low-latency data access.
Note
This feature can be enabled via manually editing the client.ncconf file and is disabled by default. Alternatively, you can also employ the CacheConnectionOptions API, by setting EnableKeepAlive to true and establishing a KeepAliveInterval.
Enable Keep Alive
The enable-keep-alive property specifies whether the connection between the client and server should be kept "alive", i.e., if the client is not communicating with its connected servers, the enable-keep-alive property sends heartbeats or pings from the client to server nodes at fixed intervals. This feature is particularly useful if there is a firewall which breaks idle network connections or if it detects connection breakages proactively.
<configuration>
<ncache-server connection-retries="3" ... enable-keep-alive="true" keep-alive-interval="30" />
<cache ...>
</cache>
</configuration>
Note
The default value of connection-retries is 3, though you can change it as you feel appropriate. You can read more about connection retries, here.
Keep Alive Interval
The keep-alive-interval is the interval, in seconds, after which a heartbeat is sent from the idle client to server to sustain the connection. The interval ranges between 1 and 7200 seconds with default set at 30 seconds. If any value is specified out of the range, NCache resorts to using the default value.
See Also
Client Config (client.ncconf)
Communication Reliability
Cache Settings