with a gpl license! proxy for mysql high performance & high availability … · 2017-05-05 ·...
TRANSCRIPT
![Page 1: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/1.jpg)
ProxySQL TutorialHigh Performance & High Availability
Proxy for MySQL
With a GPL license!Santa Clara, California | April 24th – 27th, 2017
![Page 2: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/2.jpg)
Who we are
David Turner DBA, Uber
Derek Downey OSDB Practice Advocate, Pythian
René Cannaò MySQL SRE, Dropbox / ProxySQL
![Page 3: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/3.jpg)
Agenda
● ProxySQL: Fundamentals (René Cannaò)● The 3 Rs of ProxySQL (David Turner)● Failover and Mirroing with ProxySQL (Derek Downey)
![Page 4: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/4.jpg)
Other Sessions
Use ProxySQL to Improve Your MySQL High Availability Solution
Marco "The Grinch" Tusa
Tuesday April 25th , 11:30AM - 12:20PM - Ballroom D
Percona XtraDB Cluster 5.7 with ProxySQL for your high availability and clustering needs
Ramesh Sivaraman, Krunal Bauskar
Tuesday April 25th , 4:20PM - 4:45PM - Room 209
![Page 5: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/5.jpg)
Other Sessions (2)
Advance Sharding Solution with ProxySQL Marco "The Grinch" Tusa
Tuesday April 25th, 4:50PM - 5:15PM - Ballroom A
MySQL Load Balancers - MaxScale, ProxySQL, HAProxy, MySQL Router & nginx - a close up look
Krzysztof Książek
Wednesday April 26th, 11.10AM - 12.00PM - Ballroom D
![Page 6: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/6.jpg)
Other Sessions (3)
ProxySQL Use Case Scenarios Alkin Tezuysal, René Cannaò
Wednesday April 26th, 11.10AM - 12.00PM - Room 210
Inexpensive Datamasking for MySQL with ProxySQL - data anonymization for developers
Frédéric Descamps, René Cannaò
Wednesday April 27th, 11.00AM - 11.50AM - Ballroom F
![Page 7: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/7.jpg)
Overview of ProxySQL
![Page 8: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/8.jpg)
What is ProxySQL?
The MySQL data stargate
![Page 9: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/9.jpg)
Main motivations
empower the DBAs
improve operation
understand and improve performance
create a proxy layer to shield the database
High performance and High Availability
![Page 10: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/10.jpg)
ProxySQL FeaturesSome of the most interesting features:
● on-the-fly rewrite of queries
● caching reads outside the database server
● connection pooling and multiplexing
● complex query routing and read/write split
● load balancing
● real time statistics
● monitoring
● Data masking
● Multiple instances on same ports
![Page 11: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/11.jpg)
ProxySQL Features (2)Some of the most interesting features:
● High Availability and Scalability
● seamless failover
● firewall
● query throttling
● query timeout
● query mirroring
● runtime reconfiguration
● Scheduler
● Support for Galera/PXC and Group Replication
![Page 12: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/12.jpg)
![Page 13: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/13.jpg)
Hostgroups and Query Routing
All backends are grouped into hostgroups
Hostgroups have logical functionalities
![Page 14: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/14.jpg)
Hostgroups example #1
HostGroup0 (HG0): Write mastersHostGroup1( HG1): Read slaves
Read/Write split
![Page 15: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/15.jpg)
Hostgroups example #2HG0: main write masters
HG1: main read slaves
HG2: reporting slaves
HG3: ad-hoc queries slaves
HG4: data warehouse write masters
HG5: data warehouse read slaves
HG6: remote site servers
HG7: test servers
HG8 : mirror for traffic on HG0
HG9 : mirror for traffic on HG1
![Page 16: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/16.jpg)
Basic designHG0
HG2
HG1
ProxySQL
APP1
APP2
APP3
![Page 17: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/17.jpg)
Basic designHG0
HG2
HG1
APPAPP
ProxySQL
Very low latency usingUnix Domain Socket
![Page 18: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/18.jpg)
One ProxySQL per host
![Page 19: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/19.jpg)
Silos approach
![Page 20: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/20.jpg)
Clustered ProxySQL Architecture
DB DBDB
APP
DB
PROXYSQL
DB DB
APPPROXYSQL
APPPROXYSQL
APPPROXYSQL
PROXYSQL PROXYSQL
DBMANAGER
PROXYSQL
Clustered Proxy Layer
![Page 21: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/21.jpg)
Clustered ProxySQL at scaleTested with:
● 8 app servers with 3k clients’ connections each (24k total)
● 4 middle layer proxysqls processing 4k connections each from local proxysqls (16k total)
● 256 backends/shard (meaning 256 routing rules) processing 600 connections each (150k total)
Single ProxySQL was tested with up to 150k connections
At today, ProxySQL is able to process up to 750k QPS
![Page 22: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/22.jpg)
What’s new in ProxySQL 1.4.0Native Support for Group Replication
Multiple regex engines
Better performance
Support for hundreds of thousands of users
Support for tens of thousands of database servers
Better queries control
http://www.proxysql.com/blog/releasing-proxysql-140
![Page 23: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/23.jpg)
ProxySQL Internals
![Page 24: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/24.jpg)
ProxySQL ModulesHG0
HG1
APP1ProxySQL
Queries cache
Query Processor
APP2
APP3 Thre
ad
#1 Thre
ad
#2 Thre
ad
#3
Users Auth
ConnectionPool
HostgroupManager
Admin
Monitoring
![Page 25: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/25.jpg)
Queries ProcessorBased on Queries Rules
Defines what to cache
Defines the hostgroup target
Timeout/delay
Firewall
Mirroring
Rewrite queries
![Page 26: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/26.jpg)
Queries rulesComplex rules to match incoming traffic:
● regex on query
● regex on digest text
● username
● schemaname
● Source IP address
● Bind IP address/port
● digest
Rules can be chained
![Page 27: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/27.jpg)
Queries Cache and RewriteCaching on the wire
Internal key/value storage
In memory only
Pattern based
Expired by timeout
Rewrite on the wire
Regex match/replace on query on digest text
Optionally cached or mirrored
![Page 28: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/28.jpg)
Users Authentication
Credentials stored in the proxy
User login always possible (even without backends)
Max connections
Login credentials are encrypted
![Page 29: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/29.jpg)
Hostgroups Manager
Management of servers
Track servers status
Tightly integrated with the connections pool
![Page 30: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/30.jpg)
Connections Pool
Reduced the overhead of creating new connections, and are recycled when not in use
One to many connections
Multiplexing & maximum connections
Auto-reconnect and automatic re-execution of queries
Failover management
![Page 31: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/31.jpg)
Auto-reconnect and re-execution
Automatic detection of failures
Graceful handling
Auto-reconnect when possible
Pause until a backend becomes available
Re-execution of queries
![Page 32: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/32.jpg)
Multiplexing
Reduce the number of connections against mysqld (configurable)
Many clients connections (tens of thousands) can use few backend connections (few hundreds)
Tracks connection status (transactions, user variables, temporary tables, etc)
Order by waiting time
![Page 33: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/33.jpg)
Monitoring Module
It monitors backends and collects metrics
Monitors replication lag and shun hosts
Monitors read_only variables (replication hostgroups)
Ping and terminates unresponsive nodes
![Page 34: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/34.jpg)
Monitoring ModuleBuilt in support for asynchronous replication
Support for any type of clustering solution via external scripts
(Galera/PXC , and any heterogeneous replication setup)
In ProxySQL 1.4.0, support for Group Replication
![Page 35: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/35.jpg)
Admin Module
![Page 36: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/36.jpg)
Admin Interface
Allows runtime configuration
Exports internal statuses
It uses MySQL protocol
Configuration possible from any client/tool using MySQL API
Covered during the tutorial
![Page 37: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/37.jpg)
Try it!Source code on GitHub:
https://github.com/sysown/proxysql/
Forum:
https://groups.google.com/forum/#!forum/proxysql
Tutorials on:
http://www.proxysql.com
Join us at booth #102
![Page 38: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/38.jpg)
Demo Environment
![Page 39: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/39.jpg)
DemoCode on GitHub:
https://github.com/dtest/proxysql-tutorial
Run locally: Docker, Ansible
Some hosts provided:
Username: plsc
Passwords: proxysql
![Page 40: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/40.jpg)
The 3 Rs of ProxySQL and related statistics
![Page 41: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/41.jpg)
ProxySQL
● The 3 Rs○ Rules○ Rewrite○ Routing
● Related Statistics○ Identify offensive queries and resources consumed○ View results of Remediation
![Page 42: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/42.jpg)
ProxySQL Troubleshooting Methodology
● Identify problem via stats tables● Arrive at a solution
○ Match columns○ Action columns
![Page 43: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/43.jpg)
Identify the problem
● stats_mysql_query_rules● stats_mysql_commands_counters● stats_mysql_processlist● stats_mysql_connection_pool● stats_mysql_query_digest● stats_mysql_query_digest_reset● stats_mysql_global
![Page 44: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/44.jpg)
![Page 45: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/45.jpg)
● mysql_users○ active○ fast_forward(bypass)
● global_variables● mysql_collations
○ Default(utf8)○ No stats
Match Related Tables
● mysql_rules○ username○ schemaname○ flagIN/OUT○ client_addr○ proxy_addr○ proxy_port○ digest○ match_digest○ match_pattern○ Negate_match_pattern
![Page 46: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/46.jpg)
Action related fields
● flagOUT● replace_pattern● destination_hostgroup● cache_ttl● reconnect● timeout● retries● delay● mirror_flagOUT● mirror_hostgroup● error_msg● log● apply
● active
![Page 47: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/47.jpg)
3 Levels for ProxySQL Tables
● Disk● Memory● Runtime
![Page 48: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/48.jpg)
Precautions
● Confirm the query hits with stats_mysql_query_rules● double check rules and rewrite results● hold off on writing rules to disk until you're sure they are
working as expected● have a rollback plan
○ load from disk, then memory to runtime○ load from repo, then memory to runtime and later load to disk
● test select query rules and rewrites on a slaves first● test mutable rules on a mirror or other throw away db.
![Page 49: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/49.jpg)
Stats and Query Rewrite Tutorial
● http://tiny.cc/proxysql
![Page 50: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/50.jpg)
● Derek Downey● Krzysztof Ksiazek● Marco Tusa
● Rene Cannao
Links● https://github.com/sysown/proxysql/tree/master/doc● https://www.percona.com/blog/2016/08/30/mysql-sharding-with-proxysql/● https://tusacentral.net/joomla/index.php/mysql-blogs/183-proxysql-percona-
cluster-galera-integration.html● http://severalnines.com/blog/how-proxysql-adds-failover-and-query-control-y
our-mysql-replication-setup
Thank you
![Page 51: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/51.jpg)
Uber is hiring
● Growing and talented team● Embracing Open Source Technologies● Awesome projects awaiting you● Cool campuses● Build the future● Uber Eats / Monthly credits (weekend coverage)● Automated vehicles for all employees
![Page 52: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/52.jpg)
Failover with ProxySQL
![Page 53: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/53.jpg)
Failover highlightsimprove failover time as perceived by the application
prevent errors sent to the application
perform transparent database failovers: gracefully redirecting traffic without the application knowing
existing applications do not have to be rewritten to autoreconnect since connections are not lost from failovers
![Page 54: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/54.jpg)
Failover scenario - without ProxySQL
![Page 55: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/55.jpg)
Failover scenario - without ProxySQL
![Page 56: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/56.jpg)
Replication hostgroups
https://www.nylas.com/blog/growing-up-with-mysql/
Failover without ProxySQL (10 minute outage)
![Page 57: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/57.jpg)
Failover scenario - with ProxySQL
![Page 58: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/58.jpg)
Failover scenario - with ProxySQL
![Page 59: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/59.jpg)
Failover scenario - with ProxySQL
![Page 60: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/60.jpg)
Failover scenario - with ProxySQL
![Page 61: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/61.jpg)
Replication hostgroups
https://www.nylas.com/blog/growing-up-with-mysql/
Failover without ProxySQL (10 minute outage)
![Page 62: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/62.jpg)
Replication hostgroups
https://www.nylas.com/blog/growing-up-with-mysql/
Failover with ProxySQL (10 second outage)
![Page 63: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/63.jpg)
Failover - MySQL Serversmysql> SELECT hostgroup_id, hostname, status FROM mysql_servers
WHERE hostname IN ('master', 'slave')\G
*************************** 1. row ***************************
hostgroup_id: 1
hostname: master
status: ONLINE
*************************** 2. row ***************************
hostgroup_id: 2
hostname: slave
status: ONLINE
2 rows in set (0.00 sec)
![Page 64: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/64.jpg)
Failover - Replication Hostgroupsmysql> SELECT * FROM mysql_replication_hostgroups\G
*************************** 1. row ***************************
writer_hostgroup: 1
reader_hostgroup: 2
comment:
1 row in set (0.00 sec)
![Page 65: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/65.jpg)
ProxySQL Failover ProTIPProxySQL does not handle promotion or re-slaving
External process needed, such as MHA or Orchestrator
![Page 66: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/66.jpg)
Failover Demonstration
http://tinyurl.com/dtest-proxysql
![Page 67: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/67.jpg)
Mirroring with ProxySQL
![Page 68: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/68.jpg)
What is mirroring?
![Page 69: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/69.jpg)
What is mirroring?
![Page 70: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/70.jpg)
Why mirror queries?
Validate performance on a different server using different hostgroups.
Validate performance of query rewrite or schema change
Pre-fetch slave replication (Replication Booster)
![Page 71: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/71.jpg)
How to mirrormysql>SHOW CREATE TABLE mysql_query_rules\G
*********************** 1. row ************************
table: mysql_query_rules
Create Table: CREATE TABLE mysql_query_rules (
rule_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
active INT CHECK (active IN (0,1)) NOT NULL DEFAULT 0,
username VARCHAR,
schemaname VARCHAR,
flagIN INT NOT NULL DEFAULT 0,
*snip*
mirror_flagOUT INT UNSIGNED,
mirror_hostgroup INT UNSIGNED,
error_msg VARCHAR,
*snip*)
![Page 72: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/72.jpg)
Mirroring flow
![Page 73: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/73.jpg)
Mirroring - example #1
mysql> SELECT username, destination_hostgroup, mirror_hostgroup,
mirror_flagOUT FROM mysql_query_rules WHERE
username='plam_mirror'\G
****************** 1. row **********************
username: plam_mirror
destination_hostgroup: 3
mirror_hostgroup: 4
mirror_flagOUT: NULL
![Page 74: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/74.jpg)
Mirroring - example #2
![Page 75: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/75.jpg)
Mirroring Demonstration
![Page 76: With a GPL license! Proxy for MySQL High Performance & High Availability … · 2017-05-05 · Precautions Confirm the query hits with stats_mysql_query_rules double check rules and](https://reader035.vdocument.in/reader035/viewer/2022070805/5f03b7937e708231d40a6caa/html5/thumbnails/76.jpg)
Questions?