Conventions: Load Balance & Failover

ReadBalanceBehavior

  • This convention gets or sets the default load-balancing behavior of Read requests from the client to RavenDB cluster.

  • The method selected in the convention determines which node the client's RequestExecutor will send the Read requests to,
    and which node to failover to in case of issues with the Read request.

  • Note: Write requests will always access the Preferred Node calculated by the client.

Conventions = new DocumentConventions
{
    ReadBalanceBehavior = ReadBalanceBehavior.FastestNode
}

ReadBalanceBehavior Options

  • None

    • Load-balance: No load balancing will occur. The client will always select the preferred node.
    • Failover: The client will failover nodes in the order they appear in the topology nodes list.
      Note: The list can be reordered, see Database Group Actions.
  • RoundRobin

    • Load-balance: For each Read request, the client will address the next node from the topology nodes list.
    • Failover: In case of a failure, the client will try the next node in the round robin order.
  • FastestNode

    • Load-balance: Read request will go to the fastest node.
      The fastest node is determined by a Speed Test.
    • Failover: In case of a failure, a speed test will be triggered again and in the meantime the client will use the preferred node.

Preferred Node

  • The preferred node is selected by simply going over the topology nodes list and returning the first node that has not had any errors.

  • If all nodes are in a failure state then the first node in the list is returned. The user would get an error or recover if the error was transient.

Session Usage

  • When using RoundRobin or FastestNode it might happen that the next session you open will access a different node.

  • A short delay in replicating changes to all nodes in the cluster is acceptable in most cases.
    If you need to ensure that the next request will be able to immediately read what you just wrote, you need to use write assurance.