ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers...

121
ProxySQL hand-on René Cannaò ProxySQL Frankfurt, 5 th Nov 2018 René Cannaò ProxySQL Frankfurt, 5 th Nov 2018

Transcript of ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers...

Page 1: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

ProxySQL hand-on René Cannaò

ProxySQL

Frankfurt, 5th Nov 2018

René Cannaò

ProxySQL

Frankfurt, 5th Nov 2018

Page 2: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

2

A bit about ProxySQL LLCWe provide services to help build, support

as well as improve the performance &

reliability of your Cloud-Based or On-

Premise MySQL infrastructure:

• ProxySQL Development

• Remote Consulting

• ProxySQL Support Services

• ProxySQL Training

We provide services to help build, support

as well as improve the performance &

reliability of your Cloud-Based or On-

Premise MySQL infrastructure:

• ProxySQL Development

• Remote Consulting

• ProxySQL Support Services

• ProxySQL Training

Page 3: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

3

A bit about me…

Rene Cannao

• Founder of ProxySQL

• MySQL DBA

Rene Cannao

• Founder of ProxySQL

• MySQL DBA

Page 4: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

4

Agenda

● What is ProxySQL?● Features● Fundamentals● What is new?● Internals● Admin● Clustering● Rules● Mirroring● Failover● New protocols● GTID casual reads

● What is ProxySQL?● Features● Fundamentals● What is new?● Internals● Admin● Clustering● Rules● Mirroring● Failover● New protocols● GTID casual reads

Page 5: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

5

Other sessions

HA and clustering solution: ProxySQL as an intelligent router for Galera and Group Replication

Wednesday 7th November , 2018 @11:20AM

ProxySQL Adaptive query routing based on GTID tracking

Wednesday 7th November, 2018 @4:30PM

HA and clustering solution: ProxySQL as an intelligent router for Galera and Group Replication

Wednesday 7th November , 2018 @11:20AM

ProxySQL Adaptive query routing based on GTID tracking

Wednesday 7th November, 2018 @4:30PM

Page 6: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

Overview of ProxySQL

Page 7: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

7

What is ProxySQL

The MySQL data stargateThe MySQL data stargate

Page 8: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

8

ProxySQL Architecture Overview

Data gatewayClients connect to ProxySQLRequests are evaluatedActions are performed

Page 9: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

9

Main motivations

empower the DBAsimprove operationunderstand and improve performancecreate a proxy layer to shield the databaseHigh performance and High Availability

Page 10: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

10

Some 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: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

11

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: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

12

Some of the most interesting features:● support for millions of users

● support for tens of thousands of database servers

● native ProxySQL Clustering solution

● support for ClickHouse as a backend

● support for Aurora

● SSL support for frontend

● SSLv1.2

● native Support for Galera

● causal reads using GTID

Page 13: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

13

Page 14: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

14

Hostgroups and Query Routing

All backends are grouped into hostgroups

Hostgroups have logical functionalities

All backends are grouped into hostgroups

Hostgroups have logical functionalities

Page 15: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

15

Hostgroups example #1

HostGroup0 (HG0): Write masters

HostGroup1( HG1): Read slaves

Read/Write split

Page 16: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

16

Hostgroups example #2

HG0: main write mastersHG1: main read slavesHG2: reporting slavesHG3: ad-hoc queries slavesHG4: data warehouse write masters HG5: data warehouse read slaves HG6: remote site serversHG7: test servers

HG8 : mirror for traffic on HG0HG9 : mirror for traffic on HG1

HG0: main write mastersHG1: main read slavesHG2: reporting slavesHG3: ad-hoc queries slavesHG4: data warehouse write masters HG5: data warehouse read slaves HG6: remote site serversHG7: test servers

HG8 : mirror for traffic on HG0HG9 : mirror for traffic on HG1

Page 17: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

17

Basic designHG0

HG2

HG1

ProxySQL

APP1

APP2

APP3

Page 18: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

18

Basic designHG0

HG2

HG1

APPAPP

ProxySQL

Very low latency usingUnix Domain Socket (?)

Page 19: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

19

One ProxySQL per host

Page 20: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

20

One ProxySQL per host

The most common setupIt scales to hundreds or thousands of nodeTry this solution before anything else!

Page 21: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

21

Silos approach

Page 22: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

22

Clustered ProxySQL Architecture

DB DBDB

APP

DB

PROXYSQL

DB DB

APP

PROXYSQL

APP

PROXYSQL

APP

PROXYSQL

PROXYSQL PROXYSQL

DBMANAGER

PROXYSQL

Clustered Proxy Layer

Page 23: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

23

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 950k connections

ProxySQL 1.4 is able to process up to 750k QPS

Tested 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 950k connections

ProxySQL 1.4 is able to process up to 750k QPS

Page 24: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

24

ProxySQL at scaleReal setups:

Over 1000 proxysql instances in a single network

Over 100 mysql servers configured on a single proxysql instances

Over 2 millions unique users

Routing with over 100 thousands shards

Real setups:

Over 1000 proxysql instances in a single network

Over 100 mysql servers configured on a single proxysql instances

Over 2 millions unique users

Routing with over 100 thousands shards

Page 25: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

ProxySQL Internals

Page 26: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

26

ProxySQL Modules in 1.3.x

HG0

HG1

APP1ProxySQL

Queries cache

Query Processor

APP2

APP3

Thr

ead

#1

Thr

ead

#2

Thr

ead

#3

Users Auth

ConnectionPool

HostgroupManager

Admin

Monitoring

Page 27: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

27

ProxySQL Modules in 1.4.x

HG0

HG1

APP1ProxySQL

Queries cache

Query Processor

APP2

APP3

Thr

ead

#1

Thr

ead

#2

Thr

ead

#3

Users AuthConnection

Pool

HostgroupManager

Admin

MonitoringClickHouse Server

ClickHouse Auth

Cluster

SQLite3 Server

Th

read

#3

idle

s

Thr

ead

#2 id

les

Thr

ead

#1

idle

s Purge Thread

Page 28: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

28

Thread pool in MySQL

Threads in ProxySQL are known as "MySQL Threads"Fixed number of worker threads (configurable)All threads listen on the same port(s)Client connections are not shared between threadsAll threads perform their own network I/OUses "poll()"... (does it scale?)

Page 29: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

29

Threads never share client connections

Pros:Thread contention is reducedNo need for synchronizationEach thread calls "poll()"

Cons:Possibly imbalanced load

Thread 1

Thread 2

Thread 3

Page 30: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

30

poll() vs. epoll()

"poll()" is O(N)"epoll()" is O(1)"epoll()" scales better than "poll()"

Why does ProxySQL use "poll()"?It is faster than "epoll()" for fewer connections (~1000)Performance degrades when there are a lot of connections

Page 31: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

31

ProxySQL Auxiliary Threads

Each worker thread has an auxiliary threadWorker thread uses "poll()"Auxiliary thread uses "epoll()"Worker thread passes idle connections to auxiliary threadWhen a connections becomes active auxiliary thread passes connection to the worker thread

Solution scales to almost 1 million connections

Thread 1

Aux 1

Thread 2

Aux 2

Thread 3

Aux 3

Page 32: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

32

MySQL Thread Overview

MySQL Session

MySQL Session

MySQL Session

MySQL Session

MySQL Thread

MySQL Session

MySQL Session

All other Modules:• Query Processor• Query Cache• Hostgroups Manager• Authentication• Others

For low contention, threads independently:Track internal metricsStore values for mysql-XXX variablesStore a copy of the defined query rules

Page 33: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

33

Queries Processor

Based on Queries Rules

Defines what to cache

Defines the hostgroup target

Timeout/delay

Firewall

Mirroring

Rewrite queries

Based on Queries Rules

Defines what to cache

Defines the hostgroup target

Timeout/delay

Firewall

Mirroring

Rewrite queries

Page 34: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

34

Queries rules

Complex 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

Complex 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 35: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

35

Queries Cache and Rewrite

Caching on the wireInternal key/value storageIn memory onlyPattern basedExpired by timeout

Rewrite on the wireRegex match/replace on query on digest textOptionally cached or mirrored

Caching on the wireInternal key/value storageIn memory onlyPattern basedExpired by timeout

Rewrite on the wireRegex match/replace on query on digest textOptionally cached or mirrored

Page 36: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

36

Users Authentication

Credentials stored in the proxy

User login always possible (even without backends)

Max connections

Login credentials are encrypted

Extremely scalable, up to millions of users:

https://www.percona.com/live/e17/sessions/scaling-million-databases-000webhost-lt

Credentials stored in the proxy

User login always possible (even without backends)

Max connections

Login credentials are encrypted

Extremely scalable, up to millions of users:

https://www.percona.com/live/e17/sessions/scaling-million-databases-000webhost-lt

Page 37: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

37

Hostgroups Manager

Management of servers

Track servers status

Manages the connections pool

Management of servers

Track servers status

Manages the connections pool

Page 38: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

38

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

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 39: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

39

Connections Pool

Page 40: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

40

Connections Pool

Page 41: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

41

Connection Pool

Replies to ping.From hundreds of millions of ping per day, to 0:

https://www.percona.com/blog/2017/09/01/life360-used-proxysql-lower-database-load/

Replies to ping.From hundreds of millions of ping per day, to 0:

https://www.percona.com/blog/2017/09/01/life360-used-proxysql-lower-database-load/

Page 42: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

42

Purge Thread

Unsafe connections are reset instead of being dropped

Drastically reduce the need to establish new connections

In ProxySQL 2.0 : each worker thread performs most of the reset

Unsafe connections are reset instead of being dropped

Drastically reduce the need to establish new connections

In ProxySQL 2.0 : each worker thread performs most of the reset

Page 43: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

43

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

Automatic detection of failures

Graceful handling

Auto-reconnect when possible

Pause until a backend becomes available

Re-execution of queries

Page 44: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

44

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

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 45: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

45

No ProxySQL:

ProxySQL:

Page 46: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

46

No ProxySQL: ProxySQL:

Page 47: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

47

ProxySQL:No ProxySQL:

Page 48: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

48

Page 49: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

49

Multiplexing

https://www.percona.com/blog/2017/09/01/life360-used-proxysql-lower-database-load/https://www.percona.com/blog/2017/09/01/life360-used-proxysql-lower-database-load/

Page 50: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

50

MySQL Threads and Connection Pool

MyHGM is a shared resource so it can cause contention when accessed by MySQL Threads

MySQL_ThreadMySQL_Thread

MyHGM

Page 51: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

51

Thread Connection Cache

MySQL_ThreadMySQL_Thread

MyHGMConnectionsCache

ConnectionsCache

Page 52: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

ProxySQL Web UI

Page 53: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

53

Multiplexing (see it in web UI)

Page 54: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

54

Multiplexing (see it in web)

Page 55: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

55

More metrics on web UI

Page 56: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

56

More metrics on web UI

Page 57: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

57

More metrics on web UI

Page 58: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

58

Monitoring Module

It monitors backends and collects metrics

Monitors replication lag and shun hosts

Monitors read_only (and super_read_only and innodb_read_only in 2.0) variables (replication hostgroups)

Ping and terminates unresponsive nodes

It monitors backends and collects metrics

Monitors replication lag and shun hosts

Monitors read_only (and super_read_only and innodb_read_only in 2.0) variables (replication hostgroups)

Ping and terminates unresponsive nodes

Page 59: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

59

Monitoring Module

Built in support for asynchronous replication: second behind master and pt-heartbeat

Support for any type of clustering solution via external scripts(Galera/PXC , and any heterogeneous replication setup)

In ProxySQL 1.4, support for Group Replication

In ProxySQL 2.0, support for Galera

Built in support for asynchronous replication: second behind master and pt-heartbeat

Support for any type of clustering solution via external scripts(Galera/PXC , and any heterogeneous replication setup)

In ProxySQL 1.4, support for Group Replication

In ProxySQL 2.0, support for Galera

Page 60: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

Admin Module

Page 61: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

61

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

Allows runtime configuration

Exports internal statuses

It uses MySQL protocol

Configuration possible from any client/tool using MySQL API

Covered during the tutorial

Page 62: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

62

Admin Interface

DiskMemoryRuntime

DiskMemoryRuntime

Runtime

Memory

DiskConfig

Page 63: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

63

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

Source code on GitHub:https://github.com/sysown/proxysql/

Forum:https://groups.google.com/forum/#!forum/proxysql

Tutorials on:http://www.proxysql.com

Page 64: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

Demo Environment

Page 65: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

65

Demo

Code on GitHub:https://github.com/renecannao/ProxySQL-Tutorial-PLSC2018

Some hosts provided: Username: plscPasswords: proxysql

Code on GitHub:https://github.com/renecannao/ProxySQL-Tutorial-PLSC2018

Some hosts provided: Username: plscPasswords: proxysql

Page 66: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

ProxySQL Cluster

Page 67: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

67

ProxySQL Cluster

Introduced in 1.4.2

Support for MySQL Query Rules, MySQL Users, MySQL Servers and ProxySQL Servers (no Global Variables, no Scheduler)

A group of instances constantly check each other for changes in configuration

A configuration change applied in a proxy is pulled by the other proxies

Allow to keep multiple ProxySQL instances with the same configuration(s)

Introduced in 1.4.2

Support for MySQL Query Rules, MySQL Users, MySQL Servers and ProxySQL Servers (no Global Variables, no Scheduler)

A group of instances constantly check each other for changes in configuration

A configuration change applied in a proxy is pulled by the other proxies

Allow to keep multiple ProxySQL instances with the same configuration(s)

Page 68: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

68

ProxySQL Cluster

● Core Nodes● Satellite Nodes

Largest setup we know:

1) 3 core nodes

2) 900 satellite nodes

Page 69: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

69

ProxySQL Cluster

Conflict resolution is timestamp based• No order• Last win

No quorum (in the roadmap)

Highly scalable: Core nodes vs satellite nodes

Conflict resolution is timestamp based• No order• Last win

No quorum (in the roadmap)

Highly scalable: Core nodes vs satellite nodes

Page 70: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

70

ProxySQL Cluster - Configmysql> SET admin-cluster_username='radmin';mysql> SET admin-cluster_password='radmin';mysql> LOAD ADMIN VARIABLES TO RUNTIME;mysql> SAVE ADMIN VARIABLES TO DISK;

mysql> INSERT INTO proxysql_servers (hostname) VALUES ('proxysql1'),('proxysql2'),('proxysql3');mysql> LOAD PROXYSQL SERVERS TO RUNTIME;mysql> SAVE PROXYSQL SERVERS TO DISK;

mysql> SET admin-cluster_username='radmin';mysql> SET admin-cluster_password='radmin';mysql> LOAD ADMIN VARIABLES TO RUNTIME;mysql> SAVE ADMIN VARIABLES TO DISK;

mysql> INSERT INTO proxysql_servers (hostname) VALUES ('proxysql1'),('proxysql2'),('proxysql3');mysql> LOAD PROXYSQL SERVERS TO RUNTIME;mysql> SAVE PROXYSQL SERVERS TO DISK;

mysql> SHOW VARIABLES LIKE 'admin-cluster%';+---------------------------------------------------+--------+| Variable_name | Value |+---------------------------------------------------+--------+| admin-cluster_username | radmin || admin-cluster_password | radmin || admin-cluster_check_interval_ms | 1000 || admin-cluster_check_status_frequency | 10 || admin-cluster_mysql_query_rules_diffs_before_sync | 3 || admin-cluster_mysql_servers_diffs_before_sync | 3 || admin-cluster_mysql_users_diffs_before_sync | 3 || admin-cluster_proxysql_servers_diffs_before_sync | 3 || admin-cluster_mysql_query_rules_save_to_disk | true || admin-cluster_mysql_servers_save_to_disk | true || admin-cluster_mysql_users_save_to_disk | true || admin-cluster_proxysql_servers_save_to_disk | true |+---------------------------------------------------+--------+12 rows in set (0.00 sec)

mysql> SHOW VARIABLES LIKE 'admin-cluster%';+---------------------------------------------------+--------+| Variable_name | Value |+---------------------------------------------------+--------+| admin-cluster_username | radmin || admin-cluster_password | radmin || admin-cluster_check_interval_ms | 1000 || admin-cluster_check_status_frequency | 10 || admin-cluster_mysql_query_rules_diffs_before_sync | 3 || admin-cluster_mysql_servers_diffs_before_sync | 3 || admin-cluster_mysql_users_diffs_before_sync | 3 || admin-cluster_proxysql_servers_diffs_before_sync | 3 || admin-cluster_mysql_query_rules_save_to_disk | true || admin-cluster_mysql_servers_save_to_disk | true || admin-cluster_mysql_users_save_to_disk | true || admin-cluster_proxysql_servers_save_to_disk | true |+---------------------------------------------------+--------+12 rows in set (0.00 sec)

Page 71: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

71

ProxySQL Cluster - Monitoring

stats_proxysql_servers_checksums

stats_proxysql_servers_metrics

stats_proxysql_servers_checksums

stats_proxysql_servers_metrics

Page 72: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

ProxySQL Cluster DEMO

Page 73: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

MySQL Query rules

Page 74: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

74

Query rewriting overview

SQL-aware

Regex-based

flexible

SQL-aware

Regex-based

flexible

Page 75: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

75

Query rewriting examples

read/write splitting

Data masking

Sharding

read/write splitting

Data masking

Sharding

Page 76: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

76

Query rewriting flow

Page 77: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

77

Match Related Tables

mysql_users• active• fast_forward(bypass)

mysql_users• active• fast_forward(bypass)

mysql_query_rules• username• schemaname• flagIN/OUT• client_addr• proxy_addr• proxy_port• digest• match_digest• match_pattern• negate_match_pattern

mysql_query_rules• username• schemaname• flagIN/OUT• client_addr• proxy_addr• proxy_port• digest• match_digest• match_pattern• negate_match_pattern

Page 78: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

78

Action related fields

flagOUTreplace_patterndestination_hostgroupcache_ttltimeoutretriesdelaymirror_flagOUTmirror_hostgroupOK_msgerror_msglogmultiplexapply

flagOUTreplace_patterndestination_hostgroupcache_ttltimeoutretriesdelaymirror_flagOUTmirror_hostgroupOK_msgerror_msglogmultiplexapply

active

New in 2.0 :gtid_from_hostgroupcache_empty_resultcache_timeout

active

New in 2.0 :gtid_from_hostgroupcache_empty_resultcache_timeout

Page 79: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

79

3 layers for ProxySQL tables

DiskMemoryRuntime

DiskMemoryRuntime

Runtime

Memory

DiskConfig

Page 80: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

80

Precautions

Confirm the query hits with stats_mysql_query_rulesdouble check rules and rewrite resultshold off on writing rules to disk until you're sure they are working as expectedhave a rollback plan

• load from disk, • then load from memory to runtime

test select query rules and rewrites on a slaves firsttest mutable rules on a mirror or other throw away db.

Confirm the query hits with stats_mysql_query_rulesdouble check rules and rewrite resultshold off on writing rules to disk until you're sure they are working as expectedhave a rollback plan

• load from disk, • then load from memory to runtime

test select query rules and rewrites on a slaves firsttest mutable rules on a mirror or other throw away db.

Page 81: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

81

mysql> SELECT username, default_hostgroup FROM mysql_users\G*************************** 1. row *************************** username: rootdefault_hostgroup: 01 row in set (0.00 sec)

mysql> SELECT match_digest, destination_hostgroup FROM mysql_query_rules\G*************************** 1. row *************************** match_digest: ^SELECT.*FOR UPDATEdestination_hostgroup: 0*************************** 2. row *************************** match_digest: ^SELECTdestination_hostgroup: 12 rows in set (0.00 sec)

mysql> SELECT username, default_hostgroup FROM mysql_users\G*************************** 1. row *************************** username: rootdefault_hostgroup: 01 row in set (0.00 sec)

mysql> SELECT match_digest, destination_hostgroup FROM mysql_query_rules\G*************************** 1. row *************************** match_digest: ^SELECT.*FOR UPDATEdestination_hostgroup: 0*************************** 2. row *************************** match_digest: ^SELECTdestination_hostgroup: 12 rows in set (0.00 sec)

Example - Simple R/W

This example is a simple one, NOT for production use

For production configuration guide, see:https://proxysql.com/blog/configure-read-write-split

Page 82: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

Query Rewriting with ProxySQLDEMO

Click to add textClick to add text

Page 83: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

ProxySQL Upgradewith zero downtime

Page 84: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

84

Multiple instances running on the same port

Requires Linux Kernel 3.9

Use different datadir (optionally different config file)

Close the listener for a process

Drain connections from one node

Wait all the connections to pass over

Requires Linux Kernel 3.9

Use different datadir (optionally different config file)

Close the listener for a process

Drain connections from one node

Wait all the connections to pass over

Page 85: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

Mirroring with ProxySQL

Click to add textClick to add text

Page 86: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

86

What is mirroring?

Page 87: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

87

What is mirroring?

Page 88: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

88

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)

Validate performance on a different server using different hostgroups.

Validate performance of query rewrite or schema change

Pre-fetch slave replication (Replication Booster)

Page 89: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

89

How to mirror

mysql>SHOW CREATE TABLE mysql_query_rules\G*********************** 1. row ************************ table: mysql_query_rulesCreate 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*)

mysql>SHOW CREATE TABLE mysql_query_rules\G*********************** 1. row ************************ table: mysql_query_rulesCreate 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 90: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

90

Mirroring flow

Page 91: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

91

Mirroring - example #1

mysql> SELECT username, destination_hostgroup, mirror_hostgroup, mirror_flagOUT FROM mysql_query_rules WHERE username='plam_mirror'\G****************** 1. row ********************** username: pl_mirrordestination_hostgroup: 3 mirror_hostgroup: 4 mirror_flagOUT: NULL

mysql> SELECT username, destination_hostgroup, mirror_hostgroup, mirror_flagOUT FROM mysql_query_rules WHERE username='plam_mirror'\G****************** 1. row ********************** username: pl_mirrordestination_hostgroup: 3 mirror_hostgroup: 4 mirror_flagOUT: NULL

Page 92: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

92

Mirroring - example #2

Page 93: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

Mirroring Demo

Click to add textClick to add text

Page 94: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

94

Mirroring caveats

Can be dropped: mysql-mirror_max_concurrency,

mysql-mirror_max_queue_length

Can be executed out of order

No error handling of failed queries

Can be dropped: mysql-mirror_max_concurrency,

mysql-mirror_max_queue_length

Can be executed out of order

No error handling of failed queries

Page 95: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

Failover with ProxySQL

Page 96: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

96

Failover highlights

improve 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

improve 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 97: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

97

Failover scenario - without ProxySQL

Page 98: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

98

Failover scenario - without ProxySQL

Page 99: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

99

Failover scenario - with ProxySQL

Page 100: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

100

Failover scenario - with ProxySQL

Page 101: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

101

Failover scenario - with ProxySQL

Page 102: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

102

Failover scenario - with ProxySQL

Page 103: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

103

Failover without ProxySQL (10 minute outage)

https://www.nylas.com/blog/growing-up-with-mysql/

Page 104: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

104

Failover with ProxySQL (10 second outage)

https://www.nylas.com/blog/growing-up-with-mysql/

Page 105: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

105

Failover - MySQL Servers

mysql> SELECT hostgroup_id, hostname, status FROM mysql_servers WHERE hostname IN ('mysql1, 'mysql2’)\G*************************** 1. row *************************** hostgroup_id: 0

hostname: mysql1 status: ONLINE*************************** 2. row *************************** hostgroup_id: 1

hostname: mysql2 status: ONLINE2 rows in set (0.00 sec)

mysql> SELECT hostgroup_id, hostname, status FROM mysql_servers WHERE hostname IN ('mysql1, 'mysql2’)\G*************************** 1. row *************************** hostgroup_id: 0

hostname: mysql1 status: ONLINE*************************** 2. row *************************** hostgroup_id: 1

hostname: mysql2 status: ONLINE2 rows in set (0.00 sec)

Page 106: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

106

Failover - Replication Hostgroups

mysql> SELECT * FROM mysql_replication_hostgroups\G*************************** 1. row ***************************writer_hostgroup: 0reader_hostgroup: 1 comment:1 row in set (0.00 sec)

mysql> SELECT * FROM mysql_replication_hostgroups\G*************************** 1. row ***************************writer_hostgroup: 0reader_hostgroup: 1 comment:1 row in set (0.00 sec)

Page 107: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

107

ProxySQL Failover ProTIP

ProxySQL does not handle promotion or re-slaving

External process needed, such as MHA or Orchestrator

ProxySQL does not handle promotion or re-slaving

External process needed, such as MHA or Orchestrator

Page 108: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

Failover Demo

Click to add textClick to add text

Page 109: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

Some New Features

Click to add textClick to add text

Page 110: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

110

ClickHouse Server

New in 1.4.3 – experimental (not fully completed, subject to change)

Support for ClickHouse: https://clickhouse.yandex/

Fast, really fast data analytics using MySQL client

Users management

Supports only one backendSupports only DDL and SELECT (no INSERT)

New in 1.4.3 – experimental (not fully completed, subject to change)

Support for ClickHouse: https://clickhouse.yandex/

Fast, really fast data analytics using MySQL client

Users management

Supports only one backendSupports only DDL and SELECT (no INSERT)

Page 111: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

111

ClickHouse Server

Page 112: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

112

ClickHouse Server

Page 113: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

113

SQLite3 Server

New in 1.4.3 – experimental (not fully completed, subject to change)

Support for SQLite3 : https://www.sqlite.org/

Fully transactional, in-memory

Same users as MySQL backends

A lot of features in the roadmap

New in 1.4.3 – experimental (not fully completed, subject to change)

Support for SQLite3 : https://www.sqlite.org/

Fully transactional, in-memory

Same users as MySQL backends

A lot of features in the roadmap

Page 114: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

114

You-Name-It Server

What other service should become part of ProxySQL ?What other service should become part of ProxySQL ?

Page 115: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

115

Causal read with GTID

Feature introduced in 2.0

Ensures that reads sent to slave returns what the client has written on master

Requires GTID and MySQL 5.7+

Feature introduced in 2.0

Ensures that reads sent to slave returns what the client has written on master

Requires GTID and MySQL 5.7+

Page 116: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

116

116

ProxSQL Read / Write Split

Page 117: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

117

117

ProxySQL Binlog Reader

Page 118: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

118

118

ProxySQL Binlog Reader

Page 119: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

119

Hundreds of thousands of shardsFeature introduced in 1.4.7Simpler version of mysql_query_rulesUsed as a hash table

mysql> SELECT username,schemaname,flagIN, destination_hostgroup dest FROM mysql_query_rules_fast_routing;

+----------+------------+--------+------+

| username | schemaname | flagIN | dest |

+----------+------------+--------+------+

| userA | shard1 | 0 | 1 |

| userA | shard2 | 0 | 1 |

| userA | shard3 | 0 | 1 |

| userA | shard4 | 0 | 1 |

| userA | shard5 | 0 | 2 |

| userA | shard6 | 0 | 2 |

| userA | shard7 | 0 | 2 |

+----------+------------+--------+------+

Feature introduced in 1.4.7Simpler version of mysql_query_rulesUsed as a hash table

mysql> SELECT username,schemaname,flagIN, destination_hostgroup dest FROM mysql_query_rules_fast_routing;

+----------+------------+--------+------+

| username | schemaname | flagIN | dest |

+----------+------------+--------+------+

| userA | shard1 | 0 | 1 |

| userA | shard2 | 0 | 1 |

| userA | shard3 | 0 | 1 |

| userA | shard4 | 0 | 1 |

| userA | shard5 | 0 | 2 |

| userA | shard6 | 0 | 2 |

| userA | shard7 | 0 | 2 |

+----------+------------+--------+------+

Page 120: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

120

Rate My Session

Page 121: ProxySQL hand-on - Percona...databases-000webhost-lt 3 7 Hostgroups Manager Management of servers Track servers status Manages the connections pool 3 8 Connections Pool Reduced the

121

Thank you!

• Please remember to report feature requests and bug reports:

https://github.com/sysown/proxysql/

• Community support can be found on our forum:

https://groups.google.com/forum/#!forum/proxysql

• Useful blog articles are available at our site: http://proxysql.com/blog

• Visit us at http://proxysql.com/support for subscription and support options

• Please remember to report feature requests and bug reports:

https://github.com/sysown/proxysql/

• Community support can be found on our forum:

https://groups.google.com/forum/#!forum/proxysql

• Useful blog articles are available at our site: http://proxysql.com/blog

• Visit us at http://proxysql.com/support for subscription and support options