Selecting Replica Servers with MaxScale's Read/Write Split Router
This page is part of MariaDB's Documentation.
The parent of this page is: Read/Write Split Router
Topics on this page:
Overview
The Read/Write Split Router (readwritesplit) load balances read-only queries between one or more replica servers. It selects a replica server to execute a query using criteria configured by the slave_selection_criteria
parameter.
Criterion | Description |
| Selects using average response times |
| Selects based on replication lag |
| Selects based on number of active operations (the default) |
| Selects based on number of connections from MariaDB MaxScale |
| Selects based on number of connections from the service |
Using Adaptive Routing
The Read/Write Split Router (readwritesplit) uses adaptive routing when the slave_selection_criteria
parameter is set to ADAPTIVE_ROUTING
.
In this mode, the router measures average server response times. When the router routes queries, it compares the response times of the different replica servers. It favors the faster servers for most queries, while still guaranteeing some traffic on the slowest servers.
Using Least Behind Primary
The Read/Write Split Router (readwritesplit) uses the replica server that is least behind the primary server when the slave_selection_criteria
parameter is set to LEAST_BEHIND_MASTER
. This mode is only compatible with .
In this mode, the router measures replica lag using the Seconds_Behind_Master
column from . The replica server that has the lowest value is considered to be the least behind the primary server.
Setting the Replica Selection Criteria
Set the replica selection criteria by configuring the
slave_selection_criteria
parameter for the Read/Write Split Router inmaxscale.cnf
:[split-router] type = service router = readwritesplit ... slave_selection_criteria = LEAST_GLOBAL_CONNECTIONS
Restart the MaxScale instance.
$ sudo systemctl restart maxscale