MySQL Router 2.1  /  Deploying MySQL Router  /  Basic Connection Routing

3.3 Basic Connection Routing

The Connection Routing plugin performs connection-based routing, meaning it forwards packets to the server without inspecting them. This is a simplistic approach that provides high throughput. For additional general information about connection routing, see Section 1.3, “Connection Routing”.

A simple connection-based routing setup is shown below. These and additional options are documented under Section 4.3.2, “Configuration File Options”.

level = INFO

bind_address = localhost
bind_port = 7001
destinations =,,
mode = read-only

bind_address = localhost
bind_port = 7002
destinations =,
mode = read-write

Here we use connection routing to round-robin MySQL connections to three MySQL servers on port 7001, as the read-only mode causes round-robin behavior. This example also configures the read-write mode for two of the servers using port 7002. The read-write mode defaults to the first-available strategy, as described in the mode option's documentation. The number of MySQL instances assigned to each destinations is up to you, as this is only an example. Router does not inspect the packets and does not restrict connections based on assigned mode, so it is up the the application to determine where to send read and write requests, so either port 7001 or 7002 in our example.

Assuming all three MySQL instances are running, next start MySQL Router by passing in the configuration file:

shell> ./bin/mysqlrouter -config=/etc/mysqlrouter-config.conf

Now MySQL Router is listening to port's 7001 and 7002, and will send requests to the appropriate MySQL instance. For example:

shell> ./bin/mysql --user=root --port 7001 --protocol=TCP

That will first connect to, and then next, then, and the fourth call goes back to Instead, we configured port 7002 behavior differently:

shell> ./bin/mysql --user=root --port 7002 --protocol=TCP

That will first connect to, and additional requests will continue connecting to until there is a failure, at which point is used. For additional information about this behavior, see documentation for the mode option.

User Comments
Sign Up Login You must be logged in to post a comment.