# Readwritesplit This document provides a short overview of the **readwritesplit** router module and its intended use case scenarios. It also displays all router configuration parameters with their descriptions. A list of current limitations of the module is included and examples of the router's use are provided. ## Overview The **readwritesplit** router is designed to increase the read-only processing capability of a cluster while maintaining consistency. This is achieved by splitting the query load into read and write queries. Read queries, which do not modify data, are spread across multiple nodes while all write queries will be sent to a single node. The router is designed to be used with a traditional Master-Slave replication cluster. It automatically detects changes in the master server and will use the current master server of the cluster. With a Galera cluster, one can achieve a resilient setup and easy master failover by using one of the Galera nodes as a Write-Master node, where all write queries are routed, and spreading the read load over all the nodes. ## Configuration Readwritesplit router-specific settings are specified in the configuration file of MariaDB MaxScale in its specific section. The section can be freely named but the name is used later as a reference from listener section. For more details about the standard service parameters, refer to the [Configuration Guide](../Getting-Started/Configuration-Guide.md). ## Optional parameters ### `max_slave_connections` **`max_slave_connections`** sets the maximum number of slaves a router session uses at any moment. The default is to use all available slaves. max_slave_connections= ### `max_slave_replication_lag` **`max_slave_replication_lag`** specifies how many seconds a slave is allowed to be behind the master. If the lag is bigger than configured value a slave can't be used for routing. This feature is disabled by default. max_slave_replication_lag= This applies to Master/Slave replication with MySQL monitor and `detect_replication_lag=1` options set. Please note max_slave_replication_lag must be greater than monitor interval. This option only affects Master-Slave clusters. Galera clusters do not have a concept of slave lag even if the application of write sets might have lag. ### `use_sql_variables_in` **`use_sql_variables_in`** specifies where should queries, which read session variable, be routed. The syntax for `use_sql_variable_in` is: use_sql_variables_in=[master|all] The default is to use SQL variables in all servers. When value all is used, queries reading session variables can be routed to any available slave (depending on selection criteria). Note, that queries modifying session variables are routed to all backend servers by default, excluding write queries with embedded session variable modifications, such as: INSERT INTO test.t1 VALUES (@myid:=@myid+1) In above-mentioned case the user-defined variable would only be updated in the master where query would be routed due to `INSERT` statement. **Note:** As of version 2.1 of MaxScale, all of the router options can also be defined as parameters. The values defined in _router_options_ will have priority over the parameters. ``` [Splitter Service] type=service router=readwritesplit servers=dbserv1, dbserv2, dbserv3 user=maxscale passwd=96F99AA1315BDC3604B006F427DD9484 disable_sescmd_history=true master_failure_mode=fail_on_write ``` ## Router options **`router_options`** may include multiple **readwritesplit**-specific options. All the options are parameter-value pairs. All parameters listed in this section must be configured as a value in `router_options`. Multiple options can be defined as a comma-separated list of parameter-value pairs. ``` router_options=