Databases 7 min read

MySQL Router 8.2 Read/Write Splitting with InnoDB ReplicaSet

This article demonstrates how MySQL Router 8.2 can perform automatic read/write splitting using an InnoDB ReplicaSet, shows the required configuration, explains the behavior of read and write connections, and concludes with the benefits of the feature while also containing promotional material for unrelated services.

Top Architect
Top Architect
Top Architect
MySQL Router 8.2 Read/Write Splitting with InnoDB ReplicaSet

We have been waiting for MySQL's read/write splitting feature, and it is finally available in MySQL Router 8.2.

MySQL InnoDB ReplicaSet

A ReplicaSet consists of a primary source instance and one or more asynchronous replicas.

The following image shows the ReplicaSet object status in MySQL Shell:

Starting MySQL Router 8.2

Let's configure and start MySQL Router:

The Router appears in the ReplicaSet object in MySQL Shell:

Connecting to MySQL using the read/write port (6450):

By default, read operations are routed to replicas, while write operations (or transactions) are routed to the primary source without changing the port.

The configuration generated by MySQL Router for read/write splitting can be seen in its configuration file:

[routing:bootstrap_rw_split]
 bind_address=0.0.0.0
 bind_port=6450
 destinations=metadata-cache://myreplica/?role=PRIMARY_AND_SECONDARY
 routing_strategy=round-robin
 protocol=classic
 connection_sharing=1
 client_ssl_mode=PREFERRED
 server_ssl_mode=PREFERRED
 access_mode=auto

You can also set the access mode for a session with the command ROUTER SET access_mode= to explicitly choose the instance type.

Conclusion

MySQL Router 8.2 supports read/write splitting, allowing you to direct all read traffic to read‑only instances and all write traffic to the primary instance, improving performance and scalability without any application changes.

This feature enhances user experience, simplifies database management, and clarifies that read‑only instances are replicas while write instances are the primary source.

Note: The article also contains promotional material for ChatGPT services, a paid community, and other unrelated offers.

DatabaseInnoDBMySQLRead-Write SplittingRouterReplicaSet
Top Architect
Written by

Top Architect

Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.