maxscale - the pluggable router

29
© SkySQL Corporation Ab. Company Confidential. MaxScale – The Pluggable Router Anders Karlsson Senior Sales Engineer, SkySQL

Upload: mariadb

Post on 06-Jul-2015

1.095 views

Category:

Software


0 download

DESCRIPTION

MaxScale - The Pluggable Router by Anders Karlsson, SkySQL Presented 24.6.2014 at the MariaDB Roadshow in Maarssen, The Netherlands.

TRANSCRIPT

Page 1: MaxScale - The Pluggable Router

© SkySQL Corporation Ab. Company Confidential.

MaxScale – The Pluggable Router

Anders KarlssonSenior Sales Engineer, SkySQL

Page 2: MaxScale - The Pluggable Router

© SkySQL Corporation Ab. Company Confidential.

Agenda

• What is MaxScale and why do we need it?

• MaxScale Design

• MaxScale modules

• MaxScale use cases

• Demo

Page 3: MaxScale - The Pluggable Router

© SkySQL Corporation Ab. Company Confidential.

Scaling beyond a single server

• Scaling with a single server is expensive• A single large server is more expensive than

many small ones• A single large server is more vulnerable than

many small ones

• Scaling across many small servers can be

difficult though• A Load Balancer works but doesn’t know about

MariaDB traffic

Page 4: MaxScale - The Pluggable Router

© SkySQL Corporation Ab. Company Confidential.

Why do we need MaxScale

• We need something better and different than

just a Load Balancer

• We need something that knows about MariaDB

traffic

• We need something fast and flexible, yet

lightweight

Page 5: MaxScale - The Pluggable Router

© SkySQL Corporation Ab. Company Confidential.

We need a scale out server

• A server that scales out the load to other

servers

• A server that is transparent to applications and

servers

• A server that can parse SQL requests and act

accordingly depending on the content

Page 6: MaxScale - The Pluggable Router

© SkySQL Corporation Ab. Company Confidential.

MaxScale Objectives

•Highly scalable

•Transparent to the application

•Highly available

•Extendible

•Flexible

•Modules define MaxScale functionality

•Open source, GPL2 softwaresince 8th of Jan. 2014

Page 7: MaxScale - The Pluggable Router

© SkySQL Corporation Ab. Company Confidential.

Implementation details

• Mostly written in C (with a little C++) (thank you!)

• Multi-threaded

• epoll() based mechanism

• Dynamic configuration and reconfiguration

supported

• State of servers determined dynamically

• Multiple setup in allowed in a single MaxScale

setup

Page 8: MaxScale - The Pluggable Router

© SkySQL Corporation Ab. Company Confidential.

MaxScale modules

Core of MaxScale is multi-threaded, event-driven network IO processor

10/06/2014

Client authenticates once - with MaxScale

Alter, block or log client requests and results

Content-aware or unaware routers

Configuration and state aware monitors

Allows multiple protocols for clients and servers

Page 9: MaxScale - The Pluggable Router

© SkySQL Corporation Ab. Company Confidential.

Protocol modules

• Implements a protocol that can access

MaxScale

• MySQL / MariaDB Client and server supported

• http and telnet for monitoring, configuration and

debugging

Page 10: MaxScale - The Pluggable Router

© SkySQL Corporation Ab. Company Confidential.

Authentication modules

• Authenticates clients

• Based on data from connected servers

• MaxScale does not in and of itself have an

authentication / user database, this is picked up

from connected servers

Page 11: MaxScale - The Pluggable Router

© SkySQL Corporation Ab. Company Confidential.

Monitor modules

• Monitors the state of connected servers

• Used to provide information for routing modules

• Currently monitors MySQL / MariaDB and

Galera Clusters

Page 12: MaxScale - The Pluggable Router

© SkySQL Corporation Ab. Company Confidential.

Router modules

• Router traffic from clients to servers, using a

specified rule

• Two router modules are currently available• Connection routing• Read / Write split

• This is the most important type of

module

Page 13: MaxScale - The Pluggable Router

© SkySQL Corporation Ab. Company Confidential.

Filter modules

• Optional type of module

• Allows filtering and processing of SQL

statements and results

• Simple regex filter available with MaxScale 0.7

• Queries may be inspected, modified or rejected

• Multiple filters may be chained

Page 14: MaxScale - The Pluggable Router

© MariaDB. Company Confidential.

Read Scalability with MySQL Replicationusing MaxScale’s Connection Load Balancing

ClientClient Client For applications that need read scalability and load balancing and can use separate connections for reads and writes.

Each client establishes one connection for writes and one for reads

Master Slave Slave

[write service]

type=service

router=readconnroute

router_options=master

servers=s1,s2,s3,..,sn

[read service]

type=service

router=readconnroute

router_options=slave

servers=s1,s2,s3,..,sn

Slave Slave...

Page 15: MaxScale - The Pluggable Router

© MariaDB. Company Confidential.

Consistent Read Scalability with Galerausing MaxScale’s Read/Write Split Router

ClientClient Client For applications that require read scalability with consistent reads and High Availability with fast failovers.

MaxScale selects one as a master and one or more cluster members to slave(s)

If node fails a new master can be chosen immediately.

Page 16: MaxScale - The Pluggable Router

© MariaDB. Company Confidential.

Query rewrite and filteringby using MaxScale’s filters

ClientClient ClientFor applications with multiple different backend databases. For database firewalling, etc.

CREATE TABLE SUPPLIER(ID INTEGER, NAME VARCHAR) TYPE=INNODB

[regex]

type=filter

module=regexfilter

match=TYPE

replace=ENGINE

CREATE TABLE SUPPLIER(ID INTEGER, NAME VARCHAR) ENGINE=INNODB

Page 17: MaxScale - The Pluggable Router

© MariaDB. Company Confidential.

Query rewrite and filtering (cont.)by using MaxScale’s filters

ClientClient ClientFor sloppy administrators :-)

Select count(*) f0rm mysql.user

[regex]

type=filter

module=regexfilter

match=[Ff][Oo0][Rr][Mm]

replace=FROM

Select count(*) FROM mysql.user

Page 18: MaxScale - The Pluggable Router

© MariaDB. Company Confidential.

Basic Setup

● Clients access MaxScale

● MaxScale in the app server, UNIX sockets

● Database servers accessed via TCP

● Clients● Application Server

Database Cluster

Page 19: MaxScale - The Pluggable Router

© MariaDB. Company Confidential.

Typical Scenarios

● MySQL Replication with● Read connection load

balancing● Read/Write statement

splitting

● Galera Cluster● Connection load balancing● Read/Write statement

splitting● Write conflict avoidance

(planned)

Page 20: MaxScale - The Pluggable Router

© MariaDB. Company Confidential.

Inside MaxScaleMySQL Local Authentication

Backends Clients

ok

“read user, host” connect/auth

Users are loaded at start

Page 21: MaxScale - The Pluggable Router

© MariaDB. Company Confidential.

Inside MaxScaleRead/write splitting

“call my_proc(1)”

Master

Slave

Query Classifier

Page 22: MaxScale - The Pluggable Router

© MariaDB. Company Confidential.

Inside MaxScale Routing

Page 23: MaxScale - The Pluggable Router

© MariaDB. Company Confidential.

Inside MaxScale Routing

Page 24: MaxScale - The Pluggable Router

© MariaDB. Company Confidential.

What’s new in R/W split router

● Session Commands● Local variables, User change,

SET auto commit● Execute in master & slave but

maintain execution order● Current limitation : queries not

supported in session commands

SET @a=(SELECT COUNT(*) FROM mysql.user) is executed in both nodes.

● Galera H/A Support

● Fault Tolerance● Replication consistency● Transaction support

● Within active transaction everything is routed to master

● Detection of implicit BEGIN and ROLLBACK/COMMIT

Page 25: MaxScale - The Pluggable Router

© MariaDB. Company Confidential.

MaxScale 0.7

● Galera support○ Read/Write Split router for Galera Cluster

● Multiple slaves support○ Read/Write Split router allows multiple

slave connections

● Debug Interface enhancements○ Support for wide variety of MaxScale

objects○ User mode support

Page 26: MaxScale - The Pluggable Router

© MariaDB. Company Confidential.

MaxScale 0.7

● Maintenance mode for servers

● Configurable monitoring interval

● Replication Lag Heartbeat Monitor

● Filter Modules support

● MariaDB 10 Replicationsupport

Page 27: MaxScale - The Pluggable Router

© MariaDB. Company Confidential.

Demo scenarios

● 1 Master

● 2 Slaves

Page 28: MaxScale - The Pluggable Router

© MariaDB. Company Confidential.

Get involved

● Check on GitHub https://github.com/skysql/MaxScale

● MariaDB Source https://downloads.mariadb.org/

● Bugs reporthttp://bugs.skysql.com/buglist.cgi?product=Maxscale

● Google groupshttps://groups.google.com/forum/#!forum/maxscale

● Binary Tarballhttp://downloads.skysql.com/files/SkySQL/MaxScale

● SkySQL website http://www.skysql.com

Page 29: MaxScale - The Pluggable Router

© MariaDB. Company Confidential.

MaxScale - Thank you!