MariaDB MaxScale:
An Intelligent
Database Proxy
Why we should abstract the
database cluster and how to
do it
Overview
• Part 1
– What is a database cluster?
– Why is database abstraction important for clusters?
– Few Examples of simple cluster abstraction
• Part 2
– Deep dive into MariaDB MaxScale: a Database Proxy
Part 1
What is Database Cluster Abstraction and
How it can be Done
What is a Database Cluster?
● Two or more nodes
● Logically connected
○ Shared storage
○ Logical replication
● All nodes are active
○ Hot standby
○ Multi-master cluster
Two Types of Database Clusters
Master-Slave Cluster
● Logical replication
○ MariaDB/MySQL
● Shared storage
○ Amazon Aurora
● One authoritative node
○ Write to one, read from many
● Conflict-free
Master
SlaveSlave
Synchronous Cluster
● Data synchronization
○ MariaDB Galera
○ MySQL Group Replication
○ MySQL NDB Cluster
● No authoritative nodes
○ Write to all, read from all
● Conflicts can occur
Two Types of Database Clusters
Master
MasterMaster
The Perfect Database:
● Behavior of a single database
○ Simple to use
○ Easy to manage
● Characteristics of a cluster
○ Robust and failure tolerant
○ Near-linear scalability
What is Database Abstraction for Clusters?
The Database
Why is Database Abstraction Important for Clusters?
● Isolates the complexity of the cluster
○ One logical database, multiple physical databases
○ Build simpler applications
● Highly Available Database
○ Fault tolerant
○ Easier maintenance
● Improved performance
○ Load balancing
○ Read/Write splitting
Database Abstraction Layer
● Readily available
○ Corosync/Pacemaker
○ Keepalived
● Well integrated in cloud
○ Amazon ELB
○ Azure Load Balancer
● Not really intended for databases
Example: Floating/Virtual IP
10.0.0.1
192.168.0.180 192.168.0.30
● Built into application
○ No external dependencies
● Simple setup
○ e.g. JDBC connection string
● Not in all connectors
● Increases application complexity
Example: Connectors/Drivers
2.
3.1.
● Specialized software
○ Isolates complexity
● Provides a service
○ Encapsulates resources
● One point of entry
○ Minimizes external footprint
Example: Proxy
Proxy
● Replacement of failed nodes
○ Activate standby nodes
○ Query interruptions
■ Retry failed queries
■ Replay transactions
● Changes in topology
● Read/Write splitting
○ Classification of queries
Why Simple Abstraction is Not Enough:
Problems Involved in Database Abstraction
● Session state
○ Session and user variables
○ Dependent queries
■ Last generated ID
■ Deleted/updated row count
○ Transactions
○ Temporary tables
○ Multi-statement queries
Problem: Node Failure
Failure of a single node should not be visible
to the client
Steps involved:
● Detect failed node
● Replace with standby node
● Retry interrupted query
● Replay interrupted transaction
Database Abstraction Layer
Problem: Changes in Topology
1. Initial state
2. Node type changes
3. New node is added
4. Node goes into maintenance
Master
SlaveSlave
Slave
SlaveMaster
Slave
SlaveMaster
Slave
Slave
SlaveMaster
Slave
2 3 41
Cluster abstraction must understand
and handle all cases
START TRANSACTION;
SELECT name FROM accounts WHERE id = 1;
INSERT INTO logins VALUES (‘john doe’);
COMMIT;
Problem: Transactions
Transactional behavior must be kept intact
● Executed only on one node
● Replay transaction only when it is safe
SELECT name FROM accounts WHERE id = 1;
INSERT INTO logins VALUES (‘john doe’);
SELECT LAST_INSERT_ID();
SET @@character_set_client=cp850;
Problem: Query classification
Read
Write
Dependent Query
Session State
Different queries require different behavior
● Writes to master
● Reads to slaves
● Dependent queries to previous server
● Session state modifications to all
● Non-transactional
○ Work on a single node
○ Fail when load balanced
● Depend on previous queries
○ Read inserted value
Problem: Critical Reads
INSERT INTO accounts VALUES (‘john doe’);
SELECT name FROM accounts WHERE name = ’john doe’;
● Not compatible with load balancing
○ Can return a result without the inserted value
● Not the “correct way” to do it
○ Legacy application → hard to modify
○ Framework →impossible to modify
Part 1: Summary
● Database clusters
○ Improve performance
○ Highly available
○ Not easy to handle
● Database cluster abstraction
○ Hide complexity
○ Simplifies application development
○ Easier node maintenance
Not an easy problem to solve
Part 2
MariaDB MaxScale:
Intelligent Database Proxy
MaxScale Overview
● Modular Database Proxy
○ Only use what is needed
○ Extendable
● Content-aware
○ Understands routed traffic
● Cluster-aware
○ Active cluster monitoring
○ Understands different cluster types
MaxScale Core Components
Service
● A “virtual” database
● Collection of modules
Router
● Main routing logic
● Handles load balancing
Query Classifier
● Parses SQL
● Provides information
Monitor
● Cluster-specific
● Actively monitors nodes
SELECT
WHERE
id
=
1;
● Provides both abstract and detailed information
○ Read or write
■ Does the query modify the database?
○ Query components
■ Is the table `t1` used in this query?
■ What are the values for the functions in the query?
○ Query characteristics
■ Does the query have a WHERE clause?
○ State changes
■ Was the default character set changed?
■ Is there an open transaction?
The Brains: Query Classifier
Read-only query
● Read/write splitting
○ Write to master, read from slaves
○ Major performance improvement
○ Prevents conflicts
● Session state tracking
○ Consistent session state
● Failure tolerant
○ Hides slave failures
● Multiple backend connections
○ Must-have for read/write splitting
○ Speeds up node failover
The Brawn: ReadWriteSplit
Looks at the cluster
● Tracks node status
○ Replication configuration →topology detection
○ Relevant global variables
○ Overall status →detect broken slaves
● Actively detects failures
○ Unresponsive servers
○ Out-of-sync nodes (mainly Galera)
The Eyes: Monitors
Monitors
Abstracting the Cluster Concept
● Classify servers
○ Up or Down?
○ Master or Slave?
○ In sync or not?
● Information used by routers
○ Masters used for writes
○ Slaves used for reads
● Detects events
○ Server went down
○ Slave is disconnected
Overview: Monitors
● Detects topology
○ Builds the replication tree
● Assigns correct labels
○ Root node for writes
○ Other nodes for reads
● Detects replication lag
○ Write timestamp on master
○ Read from slave
Master-Slave Monitor
Master
SlaveSlave
This is a master
This is a slave
● Galera Clusters
○ Synchronous Cluster
○ Globally conflict free
○ Conflicting transaction → Error on commit
● Abstracted in MaxScale
○ One “master” node
■ Prevents conflicts
○ Rest labeled as “slaves”
■ Good for scaleout
Galera Cluster Monitor
Master
MasterMaster
Use this for all writes...
…and these two for reads
ReadWriteSplit
The Main Router in MaxScale
1. Classify query
○ Write, read, session state modification etc.
○ Uses Query Classifier
2. Choose routing target based on query attributes
○ Modifies the database → master
○ Read-only → slave
○ Session stateme is modified → all servers
3. Pick a target server
○ Pick most valid node
■ Governed by load balancing algorithm
4. Write query and read result
ReadWriteSplit:
Read/Write Splitting
Based on server score
● Multiple algorithms
○ Active operation count → Default
■ MIN(operations)
○ Connection count
■ MIN(connections)
○ Replication delay
■ MIN(delay)
● Manually adjustable
○ Weight each server differently
■ MIN(score * weight)
ReadWriteSplit:
Load Balancing
Read retry
● Hides “trivial” failures
○ SELECT statement
○ autocommit=1
○ No open transaction
● Guaranteed reply
○ Try slaves first
○ Use master as last resort
ReadWriteSplit:
Hiding Node Failures
● Triggered on master failure
○ Master server down
○ Lost connection to master
● Read-only queries and transactions allowed
○ For read-heavy traffic
● Configurable behavior
○ Close connection on master failure
○ Close connection on first write
○ Send error on all writes
ReadWriteSplit:
Read-only Mode
● Consistent state for all connections
○ State modifications propagated
○ Truly abstracted reads
● State modification history
○ Node replacement
ReadWriteSplit:
Session State SET SQL_MODE=’ANSI’;
Filters
Extending MaxScale Functionality
● Between client and router module
○ Pre-processing
○ Analytics
○ Target hinting
● Chainable
○ Output pipes to input
● Easy to write
○ First community contribution
■ tpmfilter
Filter Overview
● Detects data modification
○ Writes “pin” the session to master
● Tags the query with a hint
○ Route to master
● Configurable
○ Number of queries
○ Time interval
CCRFilter:
Consistent Critical Reads
INSERT INTO accounts VALUES (‘john doe’);
SELECT name FROM accounts WHERE name = ’john doe’;
Route this to the master!
● Match-replace functionality
○ PCRE2 regular expressions
● Fix broken SQL
○ “Patching” after release
● Allows neat tricks
○ Append a LIMIT clause
○ Add optimizer hints
○ Change storage engine
Regexfilter:
sed for SQL
● Monitors
○ Provide abstract information
○ Assign labels to nodes
● Routers
○ Hide node failures
○ Detect dependencies
○ Load balance queries
● Filters
○ Extend functionality
○ Tailored behavior
Part 2: Summary
Solution:
Use the right tool. Work smart, not hard.
Wrapping Up
Problem:
Database clusters are essential for
performance and HA but are also hard to
use properly.
Wrapping Up
MaxScale:
A Toolbox for the Database.
● Abstracts database clusters into services
● Truly understands traffic and environment
● Makes database clusters easy to use efficiently
Thank you
Get Started with
MaxScale
SlideShare

More Related Content

PDF
How to Manage Scale-Out Environments with MariaDB MaxScale
PDF
Maxscale switchover, failover, and auto rejoin
PDF
Using all of the high availability options in MariaDB
PDF
M|18 Architectural Overview: MariaDB MaxScale
PDF
MariaDB MaxScale monitor 매뉴얼
PDF
Maxscale_메뉴얼
PDF
MariaDB MaxScale
PDF
Percona XtraDB Cluster
How to Manage Scale-Out Environments with MariaDB MaxScale
Maxscale switchover, failover, and auto rejoin
Using all of the high availability options in MariaDB
M|18 Architectural Overview: MariaDB MaxScale
MariaDB MaxScale monitor 매뉴얼
Maxscale_메뉴얼
MariaDB MaxScale
Percona XtraDB Cluster

What's hot (20)

PPTX
Running MariaDB in multiple data centers
PPTX
Maxscale 소개 1.1.1
PDF
MySQL GTID Concepts, Implementation and troubleshooting
DOCX
Keepalived+MaxScale+MariaDB_운영매뉴얼_1.0.docx
PPTX
MaxScale이해와활용-2023.11
PPTX
Postgresql Database Administration Basic - Day1
PDF
Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
PDF
ProxySQL - High Performance and HA Proxy for MySQL
PDF
MariaDB 마이그레이션 - 네오클로바
PDF
Galera cluster for high availability
PPTX
Postgres MVCC - A Developer Centric View of Multi Version Concurrency Control
PDF
ProxySQL High Availability (Clustering)
PDF
MySQL Administrator 2021 - 네오클로바
PDF
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
PDF
PostgreSQL replication
PDF
MySQL InnoDB Cluster - A complete High Availability solution for MySQL
PDF
The Full MySQL and MariaDB Parallel Replication Tutorial
PDF
Upgrade from MySQL 5.7 to MySQL 8.0
PDF
Oracle GoldenGate FAQ
PDF
Intro ProxySQL
Running MariaDB in multiple data centers
Maxscale 소개 1.1.1
MySQL GTID Concepts, Implementation and troubleshooting
Keepalived+MaxScale+MariaDB_운영매뉴얼_1.0.docx
MaxScale이해와활용-2023.11
Postgresql Database Administration Basic - Day1
Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
ProxySQL - High Performance and HA Proxy for MySQL
MariaDB 마이그레이션 - 네오클로바
Galera cluster for high availability
Postgres MVCC - A Developer Centric View of Multi Version Concurrency Control
ProxySQL High Availability (Clustering)
MySQL Administrator 2021 - 네오클로바
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
PostgreSQL replication
MySQL InnoDB Cluster - A complete High Availability solution for MySQL
The Full MySQL and MariaDB Parallel Replication Tutorial
Upgrade from MySQL 5.7 to MySQL 8.0
Oracle GoldenGate FAQ
Intro ProxySQL
Ad

Similar to MariaDB MaxScale: an Intelligent Database Proxy (20)

PDF
MariaDB MaxScale: an Intelligent Database Proxy
PDF
M|18 Why Abstract Away the Underlying Database Infrastructure
PDF
Buytaert kris my_sql-pacemaker
PPTX
Ledingkart Meetup #2: Scaling Search @Lendingkart
PDF
An Introduction to Apache Cassandra
PDF
MySQL 高可用性
PDF
MySQL High Availability Solutions
PDF
Mysqlhacodebits20091203 1260184765-phpapp02
PDF
MySQL High Availability Solutions
PDF
Towards a ZooKeeper-less Pulsar, etcd, etcd, etcd. - Pulsar Summit SF 2022
PDF
Ramp-Tutorial for MYSQL Cluster - Scaling with Continuous Availability
PDF
How to build TiDB
PDF
Large-Scale Automated Storage on Kubernetes - Matt Schallert OSCON 2019
PDF
High-level architecture of a complete MariaDB deployment
PDF
When is Myrocks good? 2020 Webinar Series
PDF
Mongo nyc nyt + mongodb
PPTX
Monitoring Cassandra With An EYE
PPTX
Modeling Data and Queries for Wide Column NoSQL
PDF
KubeCon EU 2019 - P2P Docker Image Distribution in Hybrid Cloud Environment w...
PDF
MariaDB Galera Cluster - Simple, Transparent, Highly Available
MariaDB MaxScale: an Intelligent Database Proxy
M|18 Why Abstract Away the Underlying Database Infrastructure
Buytaert kris my_sql-pacemaker
Ledingkart Meetup #2: Scaling Search @Lendingkart
An Introduction to Apache Cassandra
MySQL 高可用性
MySQL High Availability Solutions
Mysqlhacodebits20091203 1260184765-phpapp02
MySQL High Availability Solutions
Towards a ZooKeeper-less Pulsar, etcd, etcd, etcd. - Pulsar Summit SF 2022
Ramp-Tutorial for MYSQL Cluster - Scaling with Continuous Availability
How to build TiDB
Large-Scale Automated Storage on Kubernetes - Matt Schallert OSCON 2019
High-level architecture of a complete MariaDB deployment
When is Myrocks good? 2020 Webinar Series
Mongo nyc nyt + mongodb
Monitoring Cassandra With An EYE
Modeling Data and Queries for Wide Column NoSQL
KubeCon EU 2019 - P2P Docker Image Distribution in Hybrid Cloud Environment w...
MariaDB Galera Cluster - Simple, Transparent, Highly Available
Ad

Recently uploaded (20)

PDF
5-Ways-AI-is-Revolutionizing-Telecom-Quality-Engineering.pdf
PDF
The-2025-Engineering-Revolution-AI-Quality-and-DevOps-Convergence.pdf
PDF
NewMind AI Weekly Chronicles – August ’25 Week IV
PDF
A symptom-driven medical diagnosis support model based on machine learning te...
PDF
Altius execution marketplace concept.pdf
PDF
giants, standing on the shoulders of - by Daniel Stenberg
PDF
Advancing precision in air quality forecasting through machine learning integ...
PDF
Lung cancer patients survival prediction using outlier detection and optimize...
PDF
Transform-Quality-Engineering-with-AI-A-60-Day-Blueprint-for-Digital-Success.pdf
PDF
Examining Bias in AI Generated News Content.pdf
PDF
Streamline Vulnerability Management From Minimal Images to SBOMs
PDF
Connector Corner: Transform Unstructured Documents with Agentic Automation
PDF
CEH Module 2 Footprinting CEH V13, concepts
PPTX
How to use fields_get method in Odoo 18
PDF
The-Future-of-Automotive-Quality-is-Here-AI-Driven-Engineering.pdf
PDF
ment.tech-Siri Delay Opens AI Startup Opportunity in 2025.pdf
PDF
Introduction to MCP and A2A Protocols: Enabling Agent Communication
PDF
Launch a Bumble-Style App with AI Features in 2025.pdf
PDF
Transform-Your-Factory-with-AI-Driven-Quality-Engineering.pdf
PDF
Co-training pseudo-labeling for text classification with support vector machi...
5-Ways-AI-is-Revolutionizing-Telecom-Quality-Engineering.pdf
The-2025-Engineering-Revolution-AI-Quality-and-DevOps-Convergence.pdf
NewMind AI Weekly Chronicles – August ’25 Week IV
A symptom-driven medical diagnosis support model based on machine learning te...
Altius execution marketplace concept.pdf
giants, standing on the shoulders of - by Daniel Stenberg
Advancing precision in air quality forecasting through machine learning integ...
Lung cancer patients survival prediction using outlier detection and optimize...
Transform-Quality-Engineering-with-AI-A-60-Day-Blueprint-for-Digital-Success.pdf
Examining Bias in AI Generated News Content.pdf
Streamline Vulnerability Management From Minimal Images to SBOMs
Connector Corner: Transform Unstructured Documents with Agentic Automation
CEH Module 2 Footprinting CEH V13, concepts
How to use fields_get method in Odoo 18
The-Future-of-Automotive-Quality-is-Here-AI-Driven-Engineering.pdf
ment.tech-Siri Delay Opens AI Startup Opportunity in 2025.pdf
Introduction to MCP and A2A Protocols: Enabling Agent Communication
Launch a Bumble-Style App with AI Features in 2025.pdf
Transform-Your-Factory-with-AI-Driven-Quality-Engineering.pdf
Co-training pseudo-labeling for text classification with support vector machi...

MariaDB MaxScale: an Intelligent Database Proxy

  • 1. MariaDB MaxScale: An Intelligent Database Proxy Why we should abstract the database cluster and how to do it
  • 2. Overview • Part 1 – What is a database cluster? – Why is database abstraction important for clusters? – Few Examples of simple cluster abstraction • Part 2 – Deep dive into MariaDB MaxScale: a Database Proxy
  • 3. Part 1 What is Database Cluster Abstraction and How it can be Done
  • 4. What is a Database Cluster? ● Two or more nodes ● Logically connected ○ Shared storage ○ Logical replication ● All nodes are active ○ Hot standby ○ Multi-master cluster
  • 5. Two Types of Database Clusters Master-Slave Cluster ● Logical replication ○ MariaDB/MySQL ● Shared storage ○ Amazon Aurora ● One authoritative node ○ Write to one, read from many ● Conflict-free Master SlaveSlave
  • 6. Synchronous Cluster ● Data synchronization ○ MariaDB Galera ○ MySQL Group Replication ○ MySQL NDB Cluster ● No authoritative nodes ○ Write to all, read from all ● Conflicts can occur Two Types of Database Clusters Master MasterMaster
  • 7. The Perfect Database: ● Behavior of a single database ○ Simple to use ○ Easy to manage ● Characteristics of a cluster ○ Robust and failure tolerant ○ Near-linear scalability What is Database Abstraction for Clusters? The Database
  • 8. Why is Database Abstraction Important for Clusters? ● Isolates the complexity of the cluster ○ One logical database, multiple physical databases ○ Build simpler applications ● Highly Available Database ○ Fault tolerant ○ Easier maintenance ● Improved performance ○ Load balancing ○ Read/Write splitting Database Abstraction Layer
  • 9. ● Readily available ○ Corosync/Pacemaker ○ Keepalived ● Well integrated in cloud ○ Amazon ELB ○ Azure Load Balancer ● Not really intended for databases Example: Floating/Virtual IP 10.0.0.1 192.168.0.180 192.168.0.30
  • 10. ● Built into application ○ No external dependencies ● Simple setup ○ e.g. JDBC connection string ● Not in all connectors ● Increases application complexity Example: Connectors/Drivers 2. 3.1.
  • 11. ● Specialized software ○ Isolates complexity ● Provides a service ○ Encapsulates resources ● One point of entry ○ Minimizes external footprint Example: Proxy Proxy
  • 12. ● Replacement of failed nodes ○ Activate standby nodes ○ Query interruptions ■ Retry failed queries ■ Replay transactions ● Changes in topology ● Read/Write splitting ○ Classification of queries Why Simple Abstraction is Not Enough: Problems Involved in Database Abstraction ● Session state ○ Session and user variables ○ Dependent queries ■ Last generated ID ■ Deleted/updated row count ○ Transactions ○ Temporary tables ○ Multi-statement queries
  • 13. Problem: Node Failure Failure of a single node should not be visible to the client Steps involved: ● Detect failed node ● Replace with standby node ● Retry interrupted query ● Replay interrupted transaction Database Abstraction Layer
  • 14. Problem: Changes in Topology 1. Initial state 2. Node type changes 3. New node is added 4. Node goes into maintenance Master SlaveSlave Slave SlaveMaster Slave SlaveMaster Slave Slave SlaveMaster Slave 2 3 41 Cluster abstraction must understand and handle all cases
  • 15. START TRANSACTION; SELECT name FROM accounts WHERE id = 1; INSERT INTO logins VALUES (‘john doe’); COMMIT; Problem: Transactions Transactional behavior must be kept intact ● Executed only on one node ● Replay transaction only when it is safe
  • 16. SELECT name FROM accounts WHERE id = 1; INSERT INTO logins VALUES (‘john doe’); SELECT LAST_INSERT_ID(); SET @@character_set_client=cp850; Problem: Query classification Read Write Dependent Query Session State Different queries require different behavior ● Writes to master ● Reads to slaves ● Dependent queries to previous server ● Session state modifications to all
  • 17. ● Non-transactional ○ Work on a single node ○ Fail when load balanced ● Depend on previous queries ○ Read inserted value Problem: Critical Reads INSERT INTO accounts VALUES (‘john doe’); SELECT name FROM accounts WHERE name = ’john doe’; ● Not compatible with load balancing ○ Can return a result without the inserted value ● Not the “correct way” to do it ○ Legacy application → hard to modify ○ Framework →impossible to modify
  • 18. Part 1: Summary ● Database clusters ○ Improve performance ○ Highly available ○ Not easy to handle ● Database cluster abstraction ○ Hide complexity ○ Simplifies application development ○ Easier node maintenance Not an easy problem to solve
  • 20. MaxScale Overview ● Modular Database Proxy ○ Only use what is needed ○ Extendable ● Content-aware ○ Understands routed traffic ● Cluster-aware ○ Active cluster monitoring ○ Understands different cluster types
  • 21. MaxScale Core Components Service ● A “virtual” database ● Collection of modules Router ● Main routing logic ● Handles load balancing Query Classifier ● Parses SQL ● Provides information Monitor ● Cluster-specific ● Actively monitors nodes
  • 22. SELECT WHERE id = 1; ● Provides both abstract and detailed information ○ Read or write ■ Does the query modify the database? ○ Query components ■ Is the table `t1` used in this query? ■ What are the values for the functions in the query? ○ Query characteristics ■ Does the query have a WHERE clause? ○ State changes ■ Was the default character set changed? ■ Is there an open transaction? The Brains: Query Classifier Read-only query
  • 23. ● Read/write splitting ○ Write to master, read from slaves ○ Major performance improvement ○ Prevents conflicts ● Session state tracking ○ Consistent session state ● Failure tolerant ○ Hides slave failures ● Multiple backend connections ○ Must-have for read/write splitting ○ Speeds up node failover The Brawn: ReadWriteSplit
  • 24. Looks at the cluster ● Tracks node status ○ Replication configuration →topology detection ○ Relevant global variables ○ Overall status →detect broken slaves ● Actively detects failures ○ Unresponsive servers ○ Out-of-sync nodes (mainly Galera) The Eyes: Monitors
  • 26. ● Classify servers ○ Up or Down? ○ Master or Slave? ○ In sync or not? ● Information used by routers ○ Masters used for writes ○ Slaves used for reads ● Detects events ○ Server went down ○ Slave is disconnected Overview: Monitors
  • 27. ● Detects topology ○ Builds the replication tree ● Assigns correct labels ○ Root node for writes ○ Other nodes for reads ● Detects replication lag ○ Write timestamp on master ○ Read from slave Master-Slave Monitor Master SlaveSlave This is a master This is a slave
  • 28. ● Galera Clusters ○ Synchronous Cluster ○ Globally conflict free ○ Conflicting transaction → Error on commit ● Abstracted in MaxScale ○ One “master” node ■ Prevents conflicts ○ Rest labeled as “slaves” ■ Good for scaleout Galera Cluster Monitor Master MasterMaster Use this for all writes... …and these two for reads
  • 30. 1. Classify query ○ Write, read, session state modification etc. ○ Uses Query Classifier 2. Choose routing target based on query attributes ○ Modifies the database → master ○ Read-only → slave ○ Session stateme is modified → all servers 3. Pick a target server ○ Pick most valid node ■ Governed by load balancing algorithm 4. Write query and read result ReadWriteSplit: Read/Write Splitting
  • 31. Based on server score ● Multiple algorithms ○ Active operation count → Default ■ MIN(operations) ○ Connection count ■ MIN(connections) ○ Replication delay ■ MIN(delay) ● Manually adjustable ○ Weight each server differently ■ MIN(score * weight) ReadWriteSplit: Load Balancing
  • 32. Read retry ● Hides “trivial” failures ○ SELECT statement ○ autocommit=1 ○ No open transaction ● Guaranteed reply ○ Try slaves first ○ Use master as last resort ReadWriteSplit: Hiding Node Failures
  • 33. ● Triggered on master failure ○ Master server down ○ Lost connection to master ● Read-only queries and transactions allowed ○ For read-heavy traffic ● Configurable behavior ○ Close connection on master failure ○ Close connection on first write ○ Send error on all writes ReadWriteSplit: Read-only Mode
  • 34. ● Consistent state for all connections ○ State modifications propagated ○ Truly abstracted reads ● State modification history ○ Node replacement ReadWriteSplit: Session State SET SQL_MODE=’ANSI’;
  • 36. ● Between client and router module ○ Pre-processing ○ Analytics ○ Target hinting ● Chainable ○ Output pipes to input ● Easy to write ○ First community contribution ■ tpmfilter Filter Overview
  • 37. ● Detects data modification ○ Writes “pin” the session to master ● Tags the query with a hint ○ Route to master ● Configurable ○ Number of queries ○ Time interval CCRFilter: Consistent Critical Reads INSERT INTO accounts VALUES (‘john doe’); SELECT name FROM accounts WHERE name = ’john doe’; Route this to the master!
  • 38. ● Match-replace functionality ○ PCRE2 regular expressions ● Fix broken SQL ○ “Patching” after release ● Allows neat tricks ○ Append a LIMIT clause ○ Add optimizer hints ○ Change storage engine Regexfilter: sed for SQL
  • 39. ● Monitors ○ Provide abstract information ○ Assign labels to nodes ● Routers ○ Hide node failures ○ Detect dependencies ○ Load balance queries ● Filters ○ Extend functionality ○ Tailored behavior Part 2: Summary
  • 40. Solution: Use the right tool. Work smart, not hard. Wrapping Up Problem: Database clusters are essential for performance and HA but are also hard to use properly.
  • 41. Wrapping Up MaxScale: A Toolbox for the Database. ● Abstracts database clusters into services ● Truly understands traffic and environment ● Makes database clusters easy to use efficiently
  • 42. Thank you Get Started with MaxScale SlideShare