KEMBAR78
Anatomy of A Proxy Server | PDF | Proxy Server | My Sql
0% found this document useful (0 votes)
139 views34 pages

Anatomy of A Proxy Server

This document provides an overview of MaxScale, a database proxy server. It discusses what a database proxy is and how MaxScale works. MaxScale acts as an intermediary between clients and databases, receiving requests and directing them to the appropriate database server. It uses an event-based architecture and non-blocking I/O to improve performance. MaxScale implements various modules like routers, monitors, and filters to route requests and integrate features like high availability.

Uploaded by

nagendra pratap
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
139 views34 pages

Anatomy of A Proxy Server

This document provides an overview of MaxScale, a database proxy server. It discusses what a database proxy is and how MaxScale works. MaxScale acts as an intermediary between clients and databases, receiving requests and directing them to the appropriate database server. It uses an event-based architecture and non-blocking I/O to improve performance. MaxScale implements various modules like routers, monitors, and filters to route requests and integrate features like high availability.

Uploaded by

nagendra pratap
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

Anatomy of a Proxy Server

MaxScale Internals

Ivan Zoratti - Percona Live Europe - September 2015


Meet ScaleDB Inc.
• Database company based in
Menlo Park
• Developers of
IDC - Intelligent Data Cluster
and
UDE - Universal Data Engine
• Main focus on Streaming Data,
Time Series and Real Time
Analytics, all in one Engine
• Put it simply,
Big Data on MySQL
• Try the Free version: www.
2 scaledb.com
A Bit of “Externals”
What is a Database Proxy?
A Database Proxy is a specialised Proxy Server

4
What is a Database Proxy?
A Database Proxy is a specialised Proxy Server

• A Database Proxy is an intermediary for requests from client


applications or other databases
• A Database Proxy
• Receives a request
• Evaluates the request and acts accordingly
• Connects to a database, directs the request to a database server, discards the request, logs the
request etc.
• Follows up on future events associated to the request
• Receives data from a database server, prepares and send a response etc.

5
What is MaxScale?
MaxScale is an event-based, I/O dispatcher that acts as a
database proxy.
MaxScale can be used to capture, analyze, log, transform, reroute incoming requests from a frontend
(client) to a backend (server) and the outcoming results from the backend to the frontend

• Client / Frontend - One or more applications, web servers, database servers etc.
• Server / Backend - One or more database servers, proxy servers, message brokers etc.

6
MaxScale - Prehistory and History

MySQL
Proxy

7
MaxScale - Prehistory and History

MySQL
Proxy

8
MaxScale - Prehistory and History

Apache-based
MySQL prototype
Proxy

9
MaxScale - Prehistory and History

Apache-based
MySQL prototype
Proxy

10
MaxScale - Prehistory and History

Apache-based
MySQL prototype
Proxy

epoll architecture
11 & MaxScale 0.1
MaxScale Modern Days
• Active Project at MariaDB Corporation (renamed MariaDB MaxScale)
• https://github.com/mariadb-corporation/MaxScale
• Used in production in many companies (including Booking.com), MariaDB and
Percona customers
• More projects are on going at ScaleDB and other companies

Current version: 1.2


• Packaged for Ubuntu/Debian and CentOS/RH
• Running as a service
• Many modules already available

12
MaxScale Architecture and
Implementation
The MaxScale Pentagon

14
MaxScale Modules
• Routers: ReadConn Route, ReadWrite Split, Schema Router,
Master/Master
• Monitors: MySQL Replication, MySQL Cluster/NDB, Galera
• Filters: Firewall, Query Log, Query Routing, RabbitMQ, Query Re-
write, Tee, Query Top
• Authentication: MySQL Authentication (up to MySQL 5.6)
• Protocol: MySQL Client, MySQL Server

15
MaxScale and MySQL Replication

16
MaxScale and Galera

17
MaxScale Master/Master

18
MaxScale Cop :-)

19
MaxScale Binlog Server

20
MaxScale Internals
MaxScale Design

The Three Golden Rules


1. Never wait for a response
2. Network sockets must be non-
blocking
3. Do not use mutexes that cause
I/O threads queueing

22
MaxScale Design
• NOT a database
• “Object Orientated”
The Three Golden Rules • Pure multi-threading
1. Never wait for a response • Non Preemptive
2. Network sockets must be non- • Event-driven I/O model
blocking • Events are queued for
3. Do not use mutexes that cause processing by a thread
I/O threads queueing • Implementation of IOCP
• epoll abstraction
• Self contained, isolated
23
plugins
Event Model Implementation
• epoll Implementation of event abstraction
• poll_init > epoll_create
• poll_add_dcb
• poll_remove_dcb
• poll_waitevents > polling and event dispatching with timeout bias
• pollq > choose an event to be executed by a thread
• poll_add_event_to_dcb
• The event queue is implemented within the DCB structure (DCBEVENTQ)
• Next/Previous event list
• Set of pending events
• Set of processing event
• Processing flag
• Event queue lock
• Event process:
• Lock dcb->evq structure
• Copy pending events to processing events
• Set processing flag
24 • Unlock dcb->evq structure
Functions & Classes
• spinlock
• acquire - wait for spinlock to
be available
• acquire_nowait
• release
• Not to be used when
making system calls

25
Functions & Classes
• spinlock
• acquire - wait for spinlock to
be available
• acquire_nowait
• release
• Not to be used when
making system calls

26
Functions & Classes
• spinlock
• atomic_add
• Basis for spinlock
• Add signed value
and return the
previous value

27
Functions & Classes
• spinlock
• atomic_add
• GWBUF
• Sharing buffers between different
threads without copies
• Chopping buffers up without copy
• Creating lists of buffers for
read/write (scatter/gather approach)

28
DCB - Descriptor Control Block
• One DCB per connection
• DCB holds the connection state
• Registered with epoll
• Buffer queues
• DCB->writeq
• DCB->delayq
• DCB->dcb_readqueue
Operations
• connect - Create a connection to the specified server
using a specific protocol for the session
• read - Read data from a socket
• write - Data write entry point (generic)
• close - Remove the DCB from the poll set
• write_ready- EPOLLOUT handler for the socket,
indicates that the socket is ready to send more data
• error - EPOLLERR handler for the socket
• hangup - EPOLLHUP handler for the socket
• 29 accept - Accept handler for listener socket only
Plugins - An Example
Filter Plugin (QLA)

30
Plugins - An Example
Filter Plugin (QLA)

31
Plugins - An Example
Filter Plugin (QLA)

32
The Future of MaxScale
• Memory Allocation and optimisation
• Authentication Plugin
• Parser Plugin (and optimisation)
• Protocol Plugins
• Router Plugins

33
Thank You!
Images
● MySQL 2007 Logo - Courtesy of Oracle Corporation
● ScaleBase Logo - Courtesy of ScaleArc
● Jan Kneschke, Massimiliano Pinto, Massimo Brignoli, Mark Riddoch - Courtesy of Twitter and Percona
● Jean-Francois Gagne Presentation - http://www.slideshare.net/JeanFranoisGagn/binlog-servers-at-bookingcom?qid=1fdc1af3-5658-400e-
8a9c-964ad40319c1&v=qf1&b=&from_search=3
● Caffe Trieste - Christopher Michel - https://www.flickr.com/photos/cmichel67/17596540570/in/photostream/

You might also like