SlideShare a Scribd company logo
Scale Your Database Traffic with
Read/Write Splitting using MySQL Router
Presented by
Vignesh Prabhu S
Database Reliability Engineer II
Mydbops
Mydbops MyWebinar - 31
Apr 13th, 2024
Consulting
Services
Consulting
Services
Managed
Services
● Database Management and
consultancy provider
● Founded in 2016
● Assisted 800+ happy customers
● AWS partners
● PCI & ISO certified
About Us
● Introduction to MySQL Router
● Why MySQL Router? & It’s Features
● MySQL Router: Destination & Routing Strategy
● Use Cases of MySQL Router
● Case 1: Static RW Routing for Standalone Servers
● Case 2: Dynamic RW Split for InnoDB Cluster
● Case 3: Dynamic RW Split for Innodb Replica Set
● Load Balancer Comparison
Agenda
Introduction to
MySQL Router
● Part of InnoDB Cluster
● Transparent routing between application and back-end MySQL Servers
● High Availability Solution
● Easily Scalable
Introduction to MySQL Router
● Auto Failover
● Highly Available
● Zero Config Changes during addition / deletion of nodes
Why MySQL Router?
● Transparent Routing - Default
● High Availability - InnoDB Cluster
● Load Balancing
● Routing Strategy - 8.0.4
● Read/Write Splitting - 8.3
● Automatic Failover
● Bootstrap Configuration - Cluster and Replica Set
● Cross-Version Compatibility
Features
Destination:-
destinations = 172.31.0.196:3306, 172.31.0.200:3306, 172.31.0.205:3306
Routing Strategy:-
● first-available
● next-available
● round-robin
● round-robin-with-fallback
MySQL Router: Destination & Routing Strategy
MySQL Router: first-available
MySQL Router: next-available
MySQL Router: round-robin
MySQL Router: round-robin-with-fallback
Use Cases of
MySQL Router
Case 1: Static Read and Write
Routing for Master Repl Servers
Environment:-
Case 1: Static Read and Write Routing
Nodes IP
Master 1 172.31.7.51
Master 2 172.31.7.55
Replica 1 172.31.0.196
Replica 2 172.31.0.200
Replica 3 172.31.0.205
Case 1: Static Read and Write Routing
Router Config File:-
[routing:read_only]
bind_address = localhost
bind_port = 6000
destinations = 172.31.0.196:3306, 172.31.0.200:3306, 172.31.0.205:3306
routing_strategy=round-robin
[routing:read_write]
bind_address = localhost
bind_port = 7000
destinations = 172.31.7.51:3306, 172.31.7.55:3306
routing_strategy = next-available
Case 1: Static Read and Write Routing
Case 1: Static Read and Write Routing
Advantages:-
● Routing can be done based on the Routing_strategy
● Read and Write Split is available for the static destinations
Limitations:-
● Configuration is Manual
● Automatic Failover is not available
● Dynamic Destinations can’t be added. It requires the restart of the
router.
● Separate Ports needs to be used for Read and Write.
Case 2: Dynamic Read and
Write Split for InnoDB Cluster
Case 2: Router R/W Split for InnoDB Cluster
Cluster Node IPs -
Steps to Configure -
● mkdir -p /home/mydbops/mysql_router
● mysqlrouter -B cluster@ip-172-31-14-181 -d /home/mydbops/mysql_router -u root
Case 2: Router R/W Split for InnoDB Cluster - Configuration
Cluster Nodes IP Hostname
Node 1 172.31.14.181 ip-172-31-14-181
Node 2 172.31.15.227 ip-172-31-15-227
Node 3 172.31.10.174 ip-172-31-10-174
Directories & Files Created:-
Case 2: Router R/W Split for InnoDB Cluster - Configuration
File / Directory Purpose
start.sh To start the MySQL Router for the Innodb Cluster
stop.sh To stop the MySQL Router for the Innodb Cluster
mysqlrouter.conf MySQL Router Configuration file for Innodb Cluster
data/state.json Contains Innodb Cluster Primary Information
log/ Log Directory that holds the MySQL router log
Router Config File:-
[routing:bootstrap_rw]
bind_address=0.0.0.0
bind_port=6446
destinations=metadata-cache://innodb_cluster/?role=PRIMARY
routing_strategy=first-available
protocol=classic
[routing:bootstrap_ro]
bind_address=0.0.0.0
bind_port=6447
destinations=metadata-cache://innodb_cluster/?role=SECONDARY
routing_strategy=round-robin-with-fallback
protocol=classic
Case 2: Router R/W Split for InnoDB Cluster - Configuration
Router Config File:-
[routing:bootstrap_rw_split]
bind_address=0.0.0.0
bind_port=6450
destinations=metadata-cache://innodb_cluster/?role=PRIMARY_AND_SECONDARY
routing_strategy=round-robin
protocol=classic
connection_sharing=1
client_ssl_mode=PREFERRED
server_ssl_mode=PREFERRED
access_mode=auto
Case 2: Router R/W Split for InnoDB Cluster - Configuration
Conditions for RW Split:-
● Connection Sharing must be enabled
● Destinations Should be targeted to metadata-cache
● access mode should be in AUTO
● Protocol should be in CLASSIC
● Server & Client ssl modes should be in PREFERRED
Case 2: Router R/W Split for InnoDB Cluster - Configuration
Advantages:-
● Bootstrapping is available.
● Automatic Failover for HA system
● Destinations will be changed with respect to the Cluster Node Availability
● Native Support for R/W Split
Case 2: Router R/W Split for InnoDB Cluster
Case 3: Dynamic Read and Write
Split for InnoDB Replica Set
Case 3: Router R/W Split for InnoDB Replica Set
Replica Set Node IPs -
Case 3: Router R/W Split for InnoDB Replica Set
Cluster Nodes IP Hostname
Source 172.31.0.196 ip-172-31-0-196
Replica 172.31.7.51 ip-172-31-7-51
Case 3: Router R/W Split for InnoDB Replica Set
Router Config File:-
mysqlrouter -B mydbops@ip-172-31-7-51 -d /home/mydbops/router_replicaset -u root
[[routing:bootstrap_rw]
bind_address=0.0.0.0
bind_port=6446
destinations=metadata-cache://innodb_replica_set/?role=PRIMARY
routing_strategy=first-available
protocol=classic
[routing:bootstrap_ro]
bind_address=0.0.0.0
bind_port=6447
destinations=metadata-cache://innodb_replica_set/?role=SECONDARY
routing_strategy=round-robin-with-fallback
protocol=classic
Case 3: Router R/W Split for InnoDB Replica Set
Router Config File:-
[routing:bootstrap_rw_split]
bind_address=0.0.0.0
bind_port=6450
destinations=metadata-cache://innodb_replica_set/?role=PRIMARY_AND_SECONDARY
routing_strategy=round-robin
protocol=classic
connection_sharing=1
client_ssl_mode=PREFERRED
server_ssl_mode=PREFERRED
access_mode=auto
Case 3: Router R/W Split for InnoDB Replica Set
Advantages:-
● Bootstrapping is available.
● Destinations will be changed with respect to the Cluster Node Availability
● Native Support for R/W Split
Limitation:-
● Manual Failover is required via MySQL admin api
Case 3: Router R/W Split for InnoDB Replica Set
Demo:
Router with Innodb Cluster
Load Balancer Comparison
Load Balancer Comparison
Features MySQL Router ProxySQL Maxscale
Easy Setup with bootstrap function YES Yes NO
Auto Addition of Cluster Nodes YES Yes NO
InnoDB Replica Set support YES NO NO
Auto Addition of Replica Set Nodes YES NO NO
Load Balancing based on Connection YES YES YES
Load Balancing Based on weight NO YES YES
Regex Based routing NO YES YES
Query Caching NO YES YES
Consulting
Services
Consulting
Services
Connect with us !
Reach us at : info@mydbops.com
Thank you!

More Related Content

PDF
Read/Write Splitting using MySQL Router - Mydbops Meetup16
PDF
Routing Guidelines: Unlocking Smarter Query Routing in MySQL Architectures
PDF
MySQL User Camp : MySQL-Router
PDF
My sql router
PDF
MySQL Router - Explore The Secrets (MySQL Belgian Days 2024)
PDF
MySQL InnoDB Cluster and MySQL Group Replication @HKOSC 2017
PDF
MySQL HA
PDF
MySQL InnoDB Cluster / ReplicaSet - Tutorial
Read/Write Splitting using MySQL Router - Mydbops Meetup16
Routing Guidelines: Unlocking Smarter Query Routing in MySQL Architectures
MySQL User Camp : MySQL-Router
My sql router
MySQL Router - Explore The Secrets (MySQL Belgian Days 2024)
MySQL InnoDB Cluster and MySQL Group Replication @HKOSC 2017
MySQL HA
MySQL InnoDB Cluster / ReplicaSet - Tutorial

Similar to Scale your database traffic with Read & Write split using MySQL Router (20)

PDF
MySQL InnoDB Cluster / ReplicaSet - Tutorial
PDF
NY Meetup: Scaling MariaDB with Maxscale
PDF
Deep Dive into MySQL InnoDB Cluster Read Scale-out Capabilities.pdf
PDF
MySQL Day Paris 2016 - MySQL HA: InnoDB Cluster and NDB Cluster
PDF
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
PDF
20190817 coscup-oracle my sql innodb cluster sharing
PDF
Disaster Recovery with MySQL InnoDB ClusterSet - What is it and how do I use it?
PDF
MySQL 8.0 InnoDB Cluster demo
PDF
MySQL InnoDB Cluster and NDB Cluster
PDF
InnoDb Vs NDB Cluster
PDF
Training Slides: 204 - Tungsten Proxy Deep Dive
PDF
High Availability in MySQL 8 using InnoDB Cluster
PDF
MySQL Database Architectures - InnoDB ReplicaSet & Cluster
PDF
20200613 my sql-ha-deployment
PPTX
A Year in Google - Percona Live Europe 2018
PDF
MySQL Database Architectures - MySQL InnoDB ClusterSet 2021-11
PDF
MySQL 8.0 Operational Changes
PDF
Sunshine php my sql 8.0 v2
PDF
Scaling MySQL -- Swanseacon.co.uk
PDF
devops Days Belgium Ghent 2016
MySQL InnoDB Cluster / ReplicaSet - Tutorial
NY Meetup: Scaling MariaDB with Maxscale
Deep Dive into MySQL InnoDB Cluster Read Scale-out Capabilities.pdf
MySQL Day Paris 2016 - MySQL HA: InnoDB Cluster and NDB Cluster
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
20190817 coscup-oracle my sql innodb cluster sharing
Disaster Recovery with MySQL InnoDB ClusterSet - What is it and how do I use it?
MySQL 8.0 InnoDB Cluster demo
MySQL InnoDB Cluster and NDB Cluster
InnoDb Vs NDB Cluster
Training Slides: 204 - Tungsten Proxy Deep Dive
High Availability in MySQL 8 using InnoDB Cluster
MySQL Database Architectures - InnoDB ReplicaSet & Cluster
20200613 my sql-ha-deployment
A Year in Google - Percona Live Europe 2018
MySQL Database Architectures - MySQL InnoDB ClusterSet 2021-11
MySQL 8.0 Operational Changes
Sunshine php my sql 8.0 v2
Scaling MySQL -- Swanseacon.co.uk
devops Days Belgium Ghent 2016
Ad

More from Mydbops (20)

PDF
Scaling TiDB for Large-Scale Application
PDF
AWS MySQL Showdown - RDS vs RDS Multi AZ vs Aurora vs Serverless - Mydbops...
PDF
Mastering Vector Search with MongoDB Atlas - Manosh Malai - Mydbops MyWebinar 39
PDF
Migration Journey To TiDB - Kabilesh PR - Mydbops MyWebinar 38
PDF
AWS Blue Green Deployment for Databases - Mydbops
PDF
What's New In MySQL 8.4 LTS Mydbops MyWebinar Edition 36
PDF
What's New in PostgreSQL 17? - Mydbops MyWebinar Edition 35
PDF
What's New in MongoDB 8.0 - Mydbops MyWebinar Edition 34
PDF
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
PDF
TiDB - From Data to Discovery: Exploring the Intersection of Distributed Dat...
PDF
MySQL InnoDB Storage Engine: Deep Dive - Mydbops
PDF
Demystifying Real time Analytics with TiDB
PDF
Must Know Postgres Extension for DBA and Developer during Migration
PDF
Efficient MySQL Indexing and what's new in MySQL Explain
PDF
PostgreSQL Schema Changes with pg-osc - Mydbops @ PGConf India 2024
PDF
Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...
PDF
Mastering Aurora PostgreSQL Clusters for Disaster Recovery
PDF
Navigating Transactions: ACID Complexity in Modern Databases- Mydbops Open So...
PDF
AWS RDS in MySQL 2023 Vinoth Kanna @ Mydbops OpenSource Database Meetup 15
PDF
Data-at-scale-with-TIDB Mydbops Co-Founder Kabilesh PR at LSPE Event
Scaling TiDB for Large-Scale Application
AWS MySQL Showdown - RDS vs RDS Multi AZ vs Aurora vs Serverless - Mydbops...
Mastering Vector Search with MongoDB Atlas - Manosh Malai - Mydbops MyWebinar 39
Migration Journey To TiDB - Kabilesh PR - Mydbops MyWebinar 38
AWS Blue Green Deployment for Databases - Mydbops
What's New In MySQL 8.4 LTS Mydbops MyWebinar Edition 36
What's New in PostgreSQL 17? - Mydbops MyWebinar Edition 35
What's New in MongoDB 8.0 - Mydbops MyWebinar Edition 34
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
TiDB - From Data to Discovery: Exploring the Intersection of Distributed Dat...
MySQL InnoDB Storage Engine: Deep Dive - Mydbops
Demystifying Real time Analytics with TiDB
Must Know Postgres Extension for DBA and Developer during Migration
Efficient MySQL Indexing and what's new in MySQL Explain
PostgreSQL Schema Changes with pg-osc - Mydbops @ PGConf India 2024
Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...
Mastering Aurora PostgreSQL Clusters for Disaster Recovery
Navigating Transactions: ACID Complexity in Modern Databases- Mydbops Open So...
AWS RDS in MySQL 2023 Vinoth Kanna @ Mydbops OpenSource Database Meetup 15
Data-at-scale-with-TIDB Mydbops Co-Founder Kabilesh PR at LSPE Event
Ad

Recently uploaded (20)

PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
madgavkar20181017ppt McKinsey Presentation.pdf
PDF
Advanced IT Governance
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PDF
Transforming Manufacturing operations through Intelligent Integrations
PPTX
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
Chapter 3 Spatial Domain Image Processing.pdf
MYSQL Presentation for SQL database connectivity
madgavkar20181017ppt McKinsey Presentation.pdf
Advanced IT Governance
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
Transforming Manufacturing operations through Intelligent Integrations
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
GamePlan Trading System Review: Professional Trader's Honest Take
Review of recent advances in non-invasive hemoglobin estimation
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
The Rise and Fall of 3GPP – Time for a Sabbatical?
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Empathic Computing: Creating Shared Understanding
Per capita expenditure prediction using model stacking based on satellite ima...
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift

Scale your database traffic with Read & Write split using MySQL Router