SlideShare a Scribd company logo
The MySQL Availability Company
INTELLIGENT DATABASE PROXIES
Routing and transparent failover
Gilles Rayrat
About the Presenter
Gilles Rayrat
VP of Engineering
Co-author and main developer of the Tungsten Proxy
IN THE LAST EPISODE…
Recap
Proxies make clusters appear as simple
Databases to applications
Application
Proxy
Recap
Proxies make clusters appear as simple
Databases to applications
Even in complex topologies
Application
Proxy
Recap
Proxies make clusters appear as simple
Databases to applications
Even in complex topologies
With read scaling optimizations
Application
Proxy
2 BREEDS OF PROXIES
2 BREEDS OF PROXIES: SIMPLE
The fast and simple
Application
Proxy
The fast and simple
Application
Proxy
Connects to a single node
The fast and simple aka. layer 4 proxy
Application
Proxy
Connects to a single node
Can route to replicas, pick at connection time
The fast and simple aka. layer 4 proxy
Application
Proxy
Connects to a single node
Can route to replicas, pick at connection time
Fast & Transparent
The fast and simple aka. layer 4 proxy
Application
Proxy
Connects to a single node
Can route to replicas, pick at connection time
Fast & Transparent
Broken node = broken connection
The fast and simple aka. layer 4 proxy
Application
Proxy
Some players:
• HA proxy
• Nginx
• Envoy
• F5
• ELB
The fast and simple aka. layer 4 proxy
Application
Tungsten Proxy
Some players:
• HA proxy
• Nginx
• Envoy
• F5
• ELB
• Tungsten Proxy
Tungsten Cluster
2 BREEDS OF PROXIES: INTELLIGENT
The intelligent proxy
Application
Proxy
”Real” connection to the proxy
Wire protocol understood
The intelligent proxy
Application
Proxy
”Real” connection to the proxy
Wire protocol understood
Even at connection time
The intelligent proxy
Application
Proxy
”Real” connection to the proxy
Wire protocol understood
Even at connection time
Automatic or app-driven load balancing
The intelligent proxy
Application
Proxy
”Real” connection to the proxy
Wire protocol understood
Even at connection time
Automatic or app-driven load balancing
Transparent failover
The intelligent proxy
Application
Proxy
Some players:
• ProxySQL
• Maxscale
• MySQL router
• Tungsten Proxy
TRANSPARENT FAILOVER
Connection to a proxy
Application
Tungsten Proxy
application <> proxy connection
proxy <> database connection
Failure
Application
Tungsten Proxy
application <> proxy
proxy <> database connection BROKEN
Failure
Application
Tungsten Proxy
application <> proxy connection OK
proxy <> database connection BROKEN
Failover
Application
Tungsten Proxy
application <> proxy: Traffic is paused
proxy <> database: automatic reconnection (Manager)
Reconnection
Application
Tungsten Proxy
application <> proxy: traffic resumed
proxy <> database: fresh connection
READ-WRITE SPLITTING
READ-WRITE SPLITTING
• Layer 4 proxies r/w split
• With intelligent proxies
• SQL parsing
• Application driven
• Smart scale
With a layer 4 proxy
Application
Proxy
Single node picked per connection
Port based
Application
Proxy
Target PORT on the proxy determines the
connection type
33063307
Host based
Application
Proxy
Target HOST reroutes to the desired node127.0.0.1127.0.0.2
READ-WRITE SPLITTING
• Layer 4 proxies r/w split
• With intelligent proxies
• SQL parsing
• Application driven
• Smart scale
R/W splitting with an intelligent proxy
Application
Tungsten Proxy
3307 3306 Port and Host based r/w split also available
READ-WRITE SPLITTING
• Layer 4 proxies r/w split
• With intelligent proxies
• SQL parsing
• Application driven
• Smart scale
Automatic R/W splitting
Application
Tungsten Proxy
Automated SQL analysis
SELECTSHOW
Automatic R/W splitting
Application
Tungsten Proxy
Transactions remain on master
BEGIN… COMMIT
READ-WRITE SPLITTING
• Layer 4 proxies r/w split
• With intelligent proxies
• SQL parsing
• Application driven
• Smart scale
Application-driven R/W splitting
Application
Tungsten Proxy
Directives given through SQL comments
TUNGSTEN USE
RO_RELAXED
Application-driven R/W splitting
Application
Tungsten Proxy
Directives given through SQL comments
• For a single statement
TUNGSTEN USE
RO_RELAXED
/* TUNGSTEN USE RO_RELAXED */ SELECT xxx
Application-driven R/W splitting
Application
Tungsten Proxy
Directives given through SQL comments
• For a single statement
• For a block
TUNGSTEN USE
RO_RELAXED
/* TUNGSTEN USE RO_RELAXED */ SELECT xxx
-- TUNGSTEN USE RO_RELAXED
SELECT xxx
SELECT yyy
READ-WRITE SPLITTING
• Layer 4 proxies r/w split
• With intelligent proxies
• SQL parsing
• Application driven
• Smart scale
Smart Scale
Application
Tungsten Proxy
Avoids reading stale data by recording write
positionWrite position N
Smart Scale
Application
Tungsten Proxy
Avoids reading stale data by recording write
position
Reads from slave only if last write has reached
the replica
Write position N
Is Write N replicated?
Smart Scale
Application
Tungsten Proxy
Avoids reading stale data by recording write
position
Reads from slave only if last write has reached
the replica
Otherwise reads from primary
Write position N
Until replicas catch up
RECAP
Fast and simple proxy
Application
Proxy
Intelligent proxy
Application
Proxy
Transparent failover
Application
Tungsten Proxy
Read from replicas
Application
Tungsten Proxy
Many read/write splitting possibilities
Write position N
Is Write N replicated?
For More Info…
Product and General Information:
info@continuent.com
Sales Requests:
sales@continuent.com
THANK YOU FOR LISTENING
continuent.com
The MySQL Availability Company
Gilles Rayrat

More Related Content

Webinar Slides: Intelligent Database Proxies: Routing & Transparent Failover