How MySQL Router 8.2 Enables Seamless Read/Write Splitting with InnoDB ReplicaSet
MySQL Router 8.2 now supports automatic read/write splitting for InnoDB ReplicaSet clusters, allowing reads to be routed to replicas and writes to the primary without any changes to application code, as demonstrated through configuration steps, connection examples, and practical observations.
MySQL InnoDB ReplicaSet
This section introduces the simplest InnoDB ReplicaSet architecture, consisting of a single source instance and one or more asynchronous replicas.
The ReplicaSet object status can be viewed in MySQL Shell.
Starting MySQL Router 8.2
Configure and launch MySQL Router to enable read/write splitting.
The Router appears in the ReplicaSet object within MySQL Shell.
Connecting to MySQL via the read/write port (6450) demonstrates that read operations are automatically directed to a replica, while write operations go to the primary source without changing the connection parameters.
When a transaction is started, the connection switches to the source instance, while plain reads continue to use the replica.
The generated read/write split configuration appears in the Router's 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=autoSession-level control is possible with the ROUTER SET access_mode= command to specify which instance type to use.
Conclusion
MySQL Router 8.2 fully supports read/write splitting for InnoDB ReplicaSet clusters, allowing all read traffic to be routed to read‑only replicas and all write traffic to the primary instance without any application changes. This feature improves database performance, scalability, and simplifies deployment and management.
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.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
