MySQL Router 2.1  /  General Information  /  Connection Routing

1.3 Connection Routing

Connection routing enables redirection of MySQL connections to an available MySQL server. MySQL packets are routed in their entirety without inspection. For an example deployment using basic connection routing, see Section 3.3, “Basic Connection Routing”.

This means you can set up your application to connect to MySQL Router, and retry the connection if the current MySQL server fails as Router then selects a new MySQL server to redirect the connection to. This is also called simple redirect connection routing because it requires the application to retry the connection. That is, if a connection from MySQL Router to the MySQL server is interrupted, the application encounters a connection failure. However, a new connection attempt triggers Router to find and connect to another MySQL server.

Routed servers and routing strategies are defined in a configuration file. For example, the following section tells the router to listen for connections on port 7002 of the localhost, and then redirect those connections to any of the servers in the list named by the destinations option, including servers running on the localhost listening on ports 3306, 3307, and 3308. Finally, we use the mode option to tell the router to allow both readers and writers. For more information about the available modes, see the section entitled, Configuration File Setup below.

bind_port = 7002
mode = read-write
destinations = localhost:3306,localhost:3307,localhost:3308

Notice that the section is entitled, routing:simple_redirect. The first part, routing is called the section name and is used internally to determine which plugin to load. The last part is an option's section key (name) you can optionally provide should you want to set up more than one routing strategy.

When a server is no longer reachable, MySQL Router moves to the next server destination in the list, and halts redirection if the list is exhausted because this is the default mode schedule when the mode option is set to read-write.

User Comments
User comments in this section are, as the name implies, provided by MySQL users. The MySQL documentation team is not responsible for, nor do they endorse, any of the information provided here.
Sign Up Login You must be logged in to post a comment.