Communication Reliability
Note
This feature is only available in NCache Enterprise Edition.
NCache provides communication reliability through features of Command Retry and Request Inquiry to ensure the communication and execution of any commands that may have not been performed because of buggy networks or firewalls that block the connection with the server.
These features rely on the distinctive 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, 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 works for safe commands whereas the request inquiry works for unsafe commands.
Command Retries
Command retries, as the name indicates, retries execution of a command once the connection between the client and the cache server is broken which can result in 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 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 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 at 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
Request Inquiry logs all the client requests containing the unsafe commands on the server side on the receiving node. This is used to ensure fault tolerant and reliable communication between client and the cluster. In case of connection breakup, a client can inquire the cluster for the status of an unsafe command in a request that apparently might have failed. 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 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: Alachsioft.NCache.Service.exe.config located in %NCHOME%/bin/service
- .NET Core Windows: Alachsioft.NCache.Service.dll.config located in %NCHOME%/bin/service
- .NET Core Linux: Alachsioft.NCache.Daemon.dll.config located in /opt/ncache/bin/service
<add key="NCacheServer.EnableRequestInquiry" value="False"/>
The requests containing the unsafe commands remain logged at 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 acknowledgement, the server clears the request logs preceding the acknowledged one. Although there can occur a case when request log is never cleared. For that case, each log has a natural expiration time which can be modified through the following property in:
- .NET: Alachsioft.NCache.Service.exe.config located in %NCHOME%/bin/service
- .NET Core Windows: Alachsioft.NCache.Service.dll.config located in %NCHOME%/bin/service
- .NET Core Linux: Alachsioft.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