Communication Reliability for Cluster Connectivity
NCache provides communication reliability through the Command Retry and Request Inquiry features for cluster connectivity and to ensure the communication and execution of any commands that may not have been performed due to a network or firewall issue.
These features rely on the rule that certain commands change the state of the cache, like write operations (Add/Insert/Remove). These commands are referred to as unsafe commands, and once performed, they cannot be performed again - unless specified. On the other hand, we have commands that can be safely performed on the cache repeatedly, without changing the state of the cache, like read operations (Get commands). These are referred to as safe commands. The command retries work for safe commands, whereas the request inquiry works for unsafe commands.
Command Retries for Cluster Connectivity
Command retries, as the name indicates, retry the execution of a command once the connection between the client and the cache server is broken, which can result from one of the following scenarios:
The request containing the command was being sent when the connection broke, and the request never reached the server.
The request containing the command was successfully sent to the server but there is uncertainty about whether the request was entertained or not when the connection broke.
Hence, if it is certain that the connection was broken before the request was sent to the server, the command is retried as the request is resent to the server.
In case of uncertainty, the command’s status is checked to whether it is safe or unsafe.
If the command is safe, the command is simply retried.
If it is unsafe, an inquiry is made to another server node in the cache cluster to check the status of the request. Action is then taken according to the response from the request inquiry which returns the state of the request to the server. Request Inquiry is explained further in the chapter.
The user can configure how many retries should be made for each command and the time interval between them in seconds.
Command retries and their interval can be enabled through the <ncache-server>
tag in client.ncconf in %NCHOME%\config
(Windows) or \opt\ncache\config
(Linux). By default, the command retries are set to 3, and the interval to 0.1 seconds.
<ncache-server ... command-retries="3" command-retry-interval="0.1" ... />
Request Inquiry for Cluster Connectivity
Request Inquiry logs all the client requests containing unsafe commands on the server side on the receiving node. This is used to ensure fault tolerant and reliable communication between the client and cluster. In case of a connection break, a client can inquire about the status of an unsafe command from the cluster. The status of the failed requests can be either of the following:
Response from Request Inquiry | Action Taken |
---|---|
Request not received by server node. | Command Retry. |
Request received but not yet processed. | Wait for the request to be processed and inquire again. |
Request processed. | Send the response of the completed request in response to the inquiry. |
If request inquiry is disabled and an unsafe command fails, an exception is thrown asking the user to enable the feature, if any future unsafe commands are to be made reliable. By default, the request inquiry is disabled.
Request inquiry is a node specific setting and can be enabled through the following property in the cache server configuration file located at the following location:
- .NET: Alachisoft.NCache.Service.exe.config located in
%NCHOME%\bin\service
. - .NET Core Windows: Alachisoft.NCache.Service.dll.config located in
%NCHOME%\bin\service
. - .NET Core Linux: Alachisoft.NCache.Daemon.dll.config located in
/opt/ncache/bin/service
. - Java Windows: Alachisoft.NCache.Service.dll.config located in
%NCHOME%\bin\service
. - Java Linux: Alachisoft.NCache.Daemon.dll.config located in
/opt/ncache/bin/service
.
<add key="NCacheServer.EnableRequestInquiry" value="False"/>
The requests containing the unsafe commands remain logged on the server side until they are acknowledged by the client. The client piggybacks the identifier of the acknowledged request on the next request. Upon reception of the acknowledgment, the server clears the request logs preceding the acknowledgment. However, there can occur situations where the request log isn't cleared. Here, each log has a natural expiration time which can be modified through the following property:
- .NET: Alachisoft.NCache.Service.exe.config located in
%NCHOME%\bin\service
. - .NET Core Windows: Alachisoft.NCache.Service.dll.config located in
%NCHOME%\bin\service
. - .NET Core Linux: Alachisoft.NCache.Daemon.dll.config located in
/opt/ncache/bin/service
. - Java Windows: Alachisoft.NCache.Service.dll.config located in
%NCHOME%\bin\service
. - Java Linux: Alachisoft.NCache.Daemon.dll.config located in
/opt/ncache/bin/service
.
<add key="NCacheServer.RequestInquiryCleanInterval" value="15"/>
See Also
Heartbeat
Bind Cluster and Client/Server IP with Multiple NICs
Auto Start Cache on Boot
Nagle's Algorithm