By default the client will detect and respond appropriately whenever a server has the replication bundle enabled. This includes:
- Detecting that an instance is replicating to another set of instances.
- When that instance is down, the client will be automatically shifted to other instances.
This is caused by a failover mechanism which is turned in a document stored by default. The clinet can load a replication document from
/replication/topology to learn what replication instances to use if the failover occurred.
The client by default creates requests for the replication document even if the server does not have the replication bundle enabled. In this case, the request for
/replication/topology results in
404 in server logs.
You can turn off the failover behavior by using the document store conventions. In order to do so, use
FailImmediately option is used then client will raise exception when primary server is down.
The remaining values of
FailoverBehavior enumeration are:
- AllowReadsFromSecondaries (default) - allow to read from secondary server(s), but immediately fail writes to the secondary server(s)
- AllowReadsFromSecondariesAndWritesToSecondaries - allow reads from and writes to secondary server(s)
- ReadFromAllServers - spread read requests across all servers, instead of doing all the work against master. Write requests will always go to master
They determine the strategy of the failovers if the primary server is down and the environment is configured to replicate between sibling instances.
FailoverBehavior enumeration values are actually flags and can be combined, e.g. to spread all reads across all servers and allow writes to secondaries one can do as follows: