Proxies are building blocks of high availability setups for MySQL. They can detect failed nodes and route queries to hosts which are still available. If your master failed and you had to promote one of your slaves, proxies will detect such topology changes and route your traffic accordingly.
More advanced proxies can do much more, such as route traffic based on precise query rules, cache queries or mirror them. They can be even used to implement different types of sharding.
In this webinar we talk about support for proxies for MySQL HA setups in ClusterControl: how they differ and what their pros and cons are. And we show you how you can easily deploy and manage HAProxy, MaxScale and ProxySQL from ClusterControl during a live demo.
AGENDA
Introduction
Why use a proxy layer?
Comparison of proxies - the pros & cons
- HAProxy
- MaxScale
- ProxySQL
Live demo of proxy support in ClusterControl
SPEAKER
Krzysztof Książek, Senior Support Engineer at Severalnines, is a MySQL DBA with experience managing complex database environments for companies like Zendesk, Chegg, Pinterest and Flipboard.
Webinar slides: How to deploy and manage HAProxy, MaxScale or ProxySQL with ClusterControl
1. Copyright 2017 Severalnines AB
I'm Jean-Jérôme from the Severalnines Team and
I'm your host for today's webinar!
Feel free to ask any questions in the Questions
section of this application or via the Chat box.
You can also contact me directly via the chat box
or via email: jj@severalnines.com during or
after the webinar.
Your host & some logistics
7. Copyright 2017 Severalnines AB
Krzysztof Książek, Senior Support Engineer @Severalnines
krzysztof@severalnines.com
Presenter
How to deploy and manage HAProxy,
MaxScale or ProxySQL with
ClusterControl
May, 9th 2017
8. Copyright 2017 Severalnines AB
Why proxies?
Overview of proxies deployable by ClusterControl
•HAProxy
•MaxScale
•ProxySQL
Demo of proxy support in ClusterControl
Agenda
10. Copyright 2017 Severalnines AB
High availability
•Detect node health
•Route traffic away from failed nodes
Performance
•Scale out by routing traffic to multiple
nodes
•Minimize number of connections to
databases
Why proxies?
Keep complexity away from the application
•Monitor node state
•Understand replication topology
•Failover client connections
Additional features
•Collect performance data from cluster
•Rewrite queries as they pass the proxy
•Route queries depending on some rules
(e.g. Read/write split)
12. Copyright 2017 Severalnines AB
Industry standard - thousands of
installations across the world
1.7 released in November, 2016
•1.7.5 released on April, 3rd, 2017
Proxies in ClusterControl - HAProxy
TCP reverse proxy
•Load balancing, scaling out, failover
•Lack of advanced internal support for
MySQL backends
•Requires scripts to support MySQL states
13. Copyright 2017 Severalnines AB
Lack of ability to perform read/write split on
a single port
•Two backends on two different ports are
required
•Could be a blocker if an application can’t
split reads from writes
Proxies in ClusterControl - HAProxy
No understanding of MySQL state
•Only simple check on port 3306:
handshake or authentication
Workaround exists: clustercheck
•HTTP check, xinetd, external script to
monitor MySQL/Galera states
17. Copyright 2017 Severalnines AB
Created by MariaDB Corporation, currently
in version 2.0.5 (2.1 in beta)
•ClusterControl deploys 1.4.x
Tool designed to solve load balancing
needs of DBA’s
•Handles read/write split
•Automatically tracks health of backend
nodes
•Understands MySQL and Galera states
•Master or slave? Synced or donor?
Proxies in ClusterControl - MaxScale
18. Copyright 2017 Severalnines AB
Support for SSL
Support for replication, Galera and MySQL
Cluster
Statement hinting
•Where to route
•Maximum replication lag
Nagios integration
Query mirroring
Proxies in ClusterControl - MaxScale
Caching of the queries (in 2.1)
Result set masking (in 2.1)
Result set limiting (in 2.1)
Consistent Critical Reads (in 2.1)
19. Copyright 2017 Severalnines AB
Several types of routers are available:
•readwritesplit - performs read/write split
•readconnroute - round-robin access
•dbfwfilter - filters queries based on regex
•schemarouter - implements schema-
based sharding
•binlogrouter - MaxScale as a binlog
server
•avrorouter - saves binlogs in Avro file
Proxies in ClusterControl - MaxScale
Design decisions
•Read queries are routed to master if
executed within a transaction
•Stored procedures, UDF’s, prepared
statements are sent to the master only
•Session variables and settings are sent to
all hosts
•No connection multiplexing
20. Copyright 2017 Severalnines AB
Lack of real-time traffic statistics (slightly
improved in 2.1)
No remote admin interface (available in
1.4.x, removed in 2.0)
Most of configuration settings require restart
(improved in 2.1)
Lack of more advanced routing
configuration
•Route to master or slave, using hints
•No regex-based routing
Proxies in ClusterControl - MaxScale
Serious scalability issues when running with
high concurrency
•Mostly fixed in 2.1 branch
Performance regression when using more than
8 internal threads for MaxScale
Non-GPL license starting from 2.0
•Up to two nodes free (more - paid)
•GPL fork of 1.3 branch - AirBnB MaxScale
21. Copyright 2017 Severalnines AB
320 connections:
Proxies in ClusterControl - MaxScale
16 connections:
200 connections:
24. Copyright 2017 Severalnines AB
Created by René Cannaò, currently in
version 1.3.6 (1.4 announced as beta)
Designed to handle complex topologies
•Implements read write split
•Support for multiple hostgroups
•Tracks health of backends on per-query
basis
•Advanced routing based on query rules
Proxies in ClusterControl - ProxySQL
25. Copyright 2017 Severalnines AB
Admin interface uses SQL
•INSERT INTO mysql_servers …
•SET mysql-query_retries_on_failure=…;
•ClusterControl UI makes it easy to
administer
Virtually every setting can be changed
dynamically
Proxies in ClusterControl - ProxySQL
Query rules mechanism for great flexibility
•Match queries using regex, digest hash,
user, schema, IP, port
•Route queries based on above
conditions
•Query rewrite and query mirroring
•Query caching - TTL and memory limit
•All of this can be done from
ClusterControl’s UI
26. Copyright 2017 Severalnines AB
Connection multiplexing - minimizes number of
connections to backends
Support for MySQL replication and Group
Replication (in 1.4)
Support for Galera Cluster using external scripts
•Example monitoring script is provided with the
ProxySQL - ClusterControl sets it up for you
Proxies in ClusterControl - ProxySQL
Non-standard approach to backend health
monitoring
•Health check happens when traffic is sent
•Monitor module extends functionality
Detailed statistics about traffic handled by
the ProxySQL
•Presented by ClusterControl in UI
28. Copyright 2017 Severalnines AB
No client side SSL support - in the roadmap
Lack of out-of-the-box support for explicit
transactions
•You have to either use SET autocommit=0
•Or enable persistent transactions for app
user
Session variables are tricky to support
•You have to make sure they are routed to
a single, writable node (i.e. replication
master)
Proxies in ClusterControl - ProxySQL
Lack of direct nagios integration
Lack of internal support for Galera
•Although support via external script gives
you more options for customization
No advanced logging options (JSON,
Kafka)