SlideShare uma empresa Scribd logo
1 de 34
Baixar para ler offline
Jean-François Gagné
jeanfrancois DOT gagne AT booking.com
Presented at Percona Live Santa Clara 2015
Binlog Servers (and MySQL)
at Booking.com
Booking.com
2
Booking.com‟
● Based in Amsterdam since 1996
● Online Hotel and Accommodation Agent:
● 135 offices worldwide
● +619.000 properties in 211 countries
● 42 languages (website and customer service)
● Part of the Priceline Group
● And we are using MySQL:
● >3300 servers, ~85% replicating
● ~110 masters: ~30 >25 slaves, ~14 >50 slaves & ~4 >100 slaves
3
Binlog Server: Session Summary
1. Replication and the Binlog Server
2. Extreme Read Scaling
3. Remote Site Replication (and Easy Disaster Recovery)
4. Easy High Availability
5. Other Use-Cases (Crash Safety and Parallel Replication)
6. Binlog Servers at Booking.com
7. Promoting a new master without touching slaves
4
Binlog Server: Guiding Principles
● GTIDs are not needed for managing replication hierarchy
● Nor are Intermediate Masters
 log-slave-updates can be avoided (for replication)
5
Binlog Server: Replication
● One master / one or more slaves
● The master records all its writes in a journal: the binary logs
● Each slave:
● Downloads the journal and saves it locally (IO thread): relay logs
● Executes the relay logs on the local database (SQL thread)
● Could produce binary logs to be itself a master (log-slave-updates)
● Replication is:
● Asynchronous  lag
● Single threaded (in MySQL 5.6)  slower than the master
6
Binlog Server: Booking.com‟‟
● Typical replication deployment:
-----
| M |
-----
|
+------+-- ... --+---------------+-------- ...
| | | |
----- ----- ----- -----
| S1| | S2| | Sn| | M1|
----- ----- ----- -----
|
+-- ... --+
| |
----- -----
| T1| | Tm|
----- -----
7
● Si and Tj are for read scaling
● Mi are the DR master
Intermediate Master
 log-slave-update
:-(
Binlog Server: What
● Binlog Server (BLS): is a daemon that:
● Downloads the binary logs from the master
● Saves them in the same structure as on the master
● Serves them to slaves
● A or X are the same for B and C:
● By design, the binary logs served by A and X are the same
8
----- / 
| A | ---> / X 
----- -----
| |
----- -----
| B | | C |
----- -----
Binlog Server: Read Scaling
● Typical replication topology for read scaling:
-----
| M |
-----
|
+------+------+-- ... --+
| | | |
----- ----- ----- -----
| S1| | S2| | S3| | Sn|
----- ----- ----- -----
9
● When there are too many slaves,
the network interface of M is overloaded:
● 100 slaves x 1Mbit/s: very close to 1Gbit/s
● OSC or purging data in RBR becomes hard
 Slave lag or unreachable master for writes
Binlog Server: Read Scaling‟
● Typical solution: fan-out with Intermediary Masters (IM):
-----
| M |
-----
|
+----------+--- ... ---+
| | |
----- ----- -----
| M1| | M2| | Mm|
----- ----- -----
| | |
+--- ... +--- ... +--- ... ---+
| | | |
----- ----- ----- -----
| S1| | T1| |...| | Zi|
----- ----- ----- -----
10
● But Intermediate Masters bring problems:
● log-slave-updates  IM are slower than slaves
● Lag of an IM  all its slaves are lagging
● Rogue transaction on an IM  infection of all its slave
● Failure of an IM  all its slaves stop replicating
(and action must be taken fast)
Binlog Server: Read Scaling‟‟
● Solving Intermediate Master problems with shared disk:
● Filers (expensive) or DRBD (doubling the number of servers)
● HA needs sync_binlog=1 + trx_commit=1  replication is slower  lag
● After a crash of an Intermediate Master:
● we need InnoDB recovery  replication on slaves stalled  lag
● and the cache is cold  replication will be slow  lag
● Solving Intermediate Master problems with GTIDs:
● They allow slave repointing at the cost of added complexity :-|
● But they do not completely solve the lag problem :-(
● And we cannot migrate online with MySQL 5.6 :-( :-(
11
Binlog Server: Read Scaling‟‟‟
● New Solution: replace Intermediate Masters by Binlog Servers
-----
| M |
-----
|
+----------------+------ ... ------+
| | |
/  /  / 
/ I1 / I2 / Im
----- ----- -----
| | |
+------+ ... +--- ... +--- ... ---+
| | | | |
----- ----- ----- ----- -----
| S1| | S2| | Si| | Sj| | Sn|
----- ----- ----- ----- -----
● If a BLS fails, repoint its slaves to other BLSs (easy by design)
12
Binlog Server: Remote Site
● Typical deployment for remote site:
-----
| A |
-----
|
+------+------+---------------+
| | | |
----- ----- ----- -----
| B | | C | | D | | E |
----- ----- ----- -----
|
+------+------+
| | |
----- ----- -----
| F | | G | | H |
----- ----- -----
● E is an Intermediate Master  same problems as read scaling
13
Yuck !
Binlog Server: Remote Site‟
● Ideally, we would like this:
-----
| A |
-----
|
+------+------+---------------+------+------+------+
| | | | | | |
----- ----- ----- ----- ----- ----- -----
| B | | C | | D | | E | | F | | G | | H |
----- ----- ----- ----- ----- ----- -----
● No lag and no Single Point of Failure (SPOF)
● But no master on remote site for writes (easy solvable problem)
● And expensive in WAN bandwidth (harder problem to solve)
14
Binlog Server: Remote Site‟‟
● New solution: a Binlog Server on the remote site:
-----
| A |
-----
|
+------+------+---------------+
| | | |
----- ----- ----- / 
| B | | C | | D | / X 
----- ----- ----- -----
|
+------+------+------+
| | | |
----- ----- ----- -----
| E | | F | | G | | H |
----- ----- ----- -----
15
Binlog Server: Remote Site‟‟‟
● Or deploy 2 Binlog Servers to get better resilience:
-----
| A |
-----
|
+------+------+---------------+
| | | |
----- ----- ----- /  / 
| B | | C | | D | / X  ------> / Y 
----- ----- ----- ----- -----
| |
+------+ +------+
| | | |
----- ----- ----- -----
| E | | F | | G | | H |
----- ----- ----- -----
● If Y fails, repoint G and H to X; if X fails, repoint Y to A and E and F to Y
16
Binlog Server: Remote Site‟‟‟‟
● Interesting property: if A fails, E, F, G & H converge to a common state
-----
| A |
-----
|
+------+------+---------------+
| | | |
----- ----- ----- / 
| B | | C | | D | / X 
----- ----- ----- -----
|
+------+------+------+
| | | |
----- ----- ----- -----
| E | | F | | G | | H |
----- ----- ----- -----
● New master promotion is easy on remote site
17
Binlog Server: Remote Site‟‟‟‟‟
● Step by step master promotion:
1. The 1st slave that is up to date can be the new master
2. “SHOW MASTER STATUS” or “RESET MASTER”,
and “RESET SLAVE ALL” on the new master
3. Writes can be pointed to the new master
4. Once a slave is up to date, repoint it
to the new master at the position of step # 2
5. Keep delayed/lagging slaves under X until up to date
6. Once no slaves is left under X, recycle it as
a Binlog Server for the new master
18
/ 
/ X 
-----
|
+-------------+
|
-----
| G |
----- -----
| F |
-----
|
+------+
| |
----- -----
| E | | H |
----- -----
Binlog Server: High Availability
● This property can be used for high availability:
-----
| A |
-----
|
/ 
/ X 
-----
|
+------+------+------+------+------+------+------+
| | | | | | | |
----- ----- ----- ----- ----- ----- ----- -----
| B | | C | | D | | E | | F | | G | | H | | I |
----- ----- ----- ----- ----- ----- ----- -----
19
Binlog Server: Other Use-Cases
● Better Crash-Safe Replication
● http://blog.booking.com/
better_crash_safe_replication_for_mysql.html
● And Better Parallel Replication
● http://blog.booking.com/
better_parallel_replication_for_mysql.html
20
BLS@Booking.com
● Reminder: typical replication deployment at Booking.com:
-----
| M |
-----
|
+--- ... ---+ ... +-------------+--- ...
| | | |
----- ----- ----- -----
| S1| | Sj| | Sn| | M1|
----- ----- ----- -----
|
+-- ... --+
| |
----- -----
| T1| | To|
----- -----
21
BLS@Booking.com‟
● We are deploying Binlog Server Clusters to offload some masters:
-----
| M |
-----
|
+-----+-----+ ... +-------------+--- ...
| | | | |
/  /  ----- ----- -----
/ A1 / A2 | Sj| | Sn| | M1|
----- ----- ----- ----- -----
| | |
+-+-----+-+ ... -+-----+
| | | |
----- ----- /  / 
| S1| ... | Si| / Z1 / Z2
----- ----- ----- -----
22
● We have in production:
● 18 Binlog Servers
● 8 clusters (two with 3 BLSs)
● ~400 slaves replicating
from Binlog Servers
(those number are increasing)
BLS@Booking.com‟‟
● What is a Binlog Server Cluster ?
● At least 2 Binlog Servers
● Replicating from the same master
● With independent failure mode (not on the same switch/rack/…)
● With a Service DNS entry resolving to all IP addresses of the BLSs
 A failure of a Binlog Server is transparent to slaves
● Thanks to DNS, the slaves connected to a failing Binlog Server
reconnect to the other still working Binlog Server(s)
 Easy maintenance/upgrade of a Binlog Server
23
|
+-----+
| |
/  / 
/ A1 / A2
----- -----
| |
+-+-----+-+
| |
----- -----
| S1| ... | Si|
----- -----
MariaDB MaxScale Binlog Router
● High Performance Parallel Replication with Bin Log Router:
[…] provides efficient replication from master to slave without the need for intermediate masters.
This plugin receives binlog records from a master and makes them available immediately to
slaves […]. You can use MaxScale‟s binlog server for replication to slaves across one or more
datacenters and deliver a high performance user experience.
24
BLS@Booking.com‟‟‟
● We are also deploying BLS side-by-side with IM to reduce delay:
-----
| M |
-----
|
+-----+-----+ ... +-------------+-----+----------- ...
| | | | | |
/  /  ----- ----- ----- / -->/ 
/ A1 / A2 | Sj| | Sn| | M1| / B1 / B2
----- ----- ----- ----- ----- ----- -----
| | | | |
+-+-----+-+ ... +-+-----+-+
| | | |
----- ----- ----- -----
| S1| ... | Si| | Tk| ... | To|
----- ----- ----- -----
25
BLS@Booking.com‟‟‟‟
● We are planning to deploy our next Data Center without IM:
-----
| M |
-----
|
+-----+-----+ ... +-------------+-----+----------- ... -----+
| | | | | | |
/  /  ----- ----- ----- / -->/  / -->/ 
/ A1 / A2 | Sj| | Sn| | M1| / B1 / B2 / C1 / C2
----- ----- ----- ----- ----- ----- ----- ----- -----
| | | | | | |
+-+-----+-+ ... +-+-----+-+ +-+-----+-+
| | | | | |
----- ----- ----- ----- ----- -----
| S1| ... | Si| | Tk| ... | To| | U1| ... | Up|
----- ----- ----- ----- ----- -----
26
Future of Binlog Servers
● Distributed Binlog Serving Service (DBSS):
-----
| M |
-----
|
+----+----------- ... --------------- ... ----------------+
| |
+----+-------+--- ... ---+-------+--- ... ---+-------+----+
| | | | | |
----- ----- ----- ----- ----- -----
| S1|...| Sn| | T1|...| Tm| | U1|...| Uo|
----- ----- ----- ----- ----- -----
● Properties:
● A single Binlog Server failure does not disrupt the service (resilience)
● Minimise inter Data Center bandwidth requirements
● Allows to promote a new master without touching any slave
27
Future of Binlog Servers‟
● Zoom in DBSS:
|
+----|------------- ... ----------------- ... -----------------+
| | |
| +------------- ... ----+------------ ... ----+ |
| | | | |
| /  /  /  |
| / --->/  / --->/  / --->/  |
| ----- /  ----- /  ----- /  |
| | ----- | ----- | ----- |
+----|-------|----- ... ----|-------|---- ... ----|-------|----+
| | | | | |
28
Future of Binlog Servers‟‟
● Crash of the master:
● Step # 1: level the Binlog Servers (the slaves will follow)
+------------------ ... ----------------- ... -----------------+
| |
| |
| |
| /  /  /  |
| / --->/  / --->/  / --->/  |
| ----- /  ----- /  ----- /  |
| | ----- | ----- | ----- |
+----|-------|----- ... ----|-------|---- ... ----|-------|----+
| | | | | |
29
<------------------- ------------------>
Future of Binlog Servers‟‟‟
● Crash of the master:
● Step # 2: promote a slave as the new master (there is a trick)
|
+------------------ ... ----------------- ... ----|------------+
| | |
| +----------------------+---------------------+ |
| | | | |
| /  /  /  |
| / --->/  / --->/  / --->/  |
| ----- /  ----- /  ----- /  |
| | ----- | ----- | ----- |
+----|-------|----- ... ----|-------|---- ... ----|-------|----+
| | | | | |
30
Future of Binlog Servers‟‟‟‟
● Crash of the master - the trick:
● Needs the same binary log filename on master and slaves
1. “FLUSH BINARY LOGS” on candidate master until its binary log filename
follows the one available on the Binlog Servers
2. On the new master:
● “PURGE BINARY LOGS TO „<latest binary log file>'”
● “RESET SLAVE ALL”
3. Point the writes to the new master
4. Make the Binlog Servers replicate from the new master
● From the point of view of the Binlog Server, the master only rebooted
with a new ServerID and a new UUID.
31
New Master wo Touching Slaves
32
--/- -----
| X | | T1|
-/-- -----
|
+----+----------- ... ---+----------- ... ----------------+
| |
+----+-------+--- ... -----------+--- ... ---+-------+----+
| | | | |
----- ----- ----- ----- -----
| S1|...| Sn| ...| Tm| | U1|...| Uo|
----- ----- ----- ----- -----
Binlog Server: Links
● http://blog.booking.com/mysql_slave_scaling_and_more.html
● MaxScale High Performance Binlog Relay: https://mariadb.com/products/mariadb-maxscale
● HOWTO Install and Configure a MaxScale Binlog Server:
http://jfg-mysql.blogspot.com/2015/04/maxscale-binlog-server-howto-install-and-configure.html
● http://blog.booking.com/better_crash_safe_replication_for_mysql.html
● http://blog.booking.com/better_parallel_replication_for_mysql.html
● (http://blog.booking.com/evaluating_mysql_parallel_replication_2-slave_group_commit.html)
● The MaxScale mailing list (to ask questions): maxscale@googlegroups.com
● Note: the Binlog Servers concept should work with any version of
MySQL (5.7, 5.6, 5.5 and 5.1) or MariaDB (10.1, 10.0, 5.5. 5.3, 5.2 and 5.1)
33
Questions
Jean-François Gagné
jeanfrancois DOT gagne AT booking.com
(maxscale AT googlegroups.com)

Mais conteúdo relacionado

Destaque

Levels of formality in writing2
Levels of formality in writing2Levels of formality in writing2
Levels of formality in writing2
tjcassidy
 
code of ethics for professional teacher
code of ethics for professional teachercode of ethics for professional teacher
code of ethics for professional teacher
Alice Victor
 
PLAZA O DISTRIBUCION (marketing
PLAZA O DISTRIBUCION (marketing PLAZA O DISTRIBUCION (marketing
PLAZA O DISTRIBUCION (marketing
Eddy Lajara
 
Clothes ppt
Clothes pptClothes ppt
Clothes ppt
afofi
 
Face recognition ppt
Face recognition pptFace recognition ppt
Face recognition ppt
Santosh Kumar
 
Planos y ejes del cuerpo humano
Planos y ejes del cuerpo humanoPlanos y ejes del cuerpo humano
Planos y ejes del cuerpo humano
jubier94
 
Signos vitales
Signos vitalesSignos vitales
Signos vitales
Jose Giron
 

Destaque (15)

Aclaremos: ¿Sial, Sima...todavía?
Aclaremos: ¿Sial, Sima...todavía? Aclaremos: ¿Sial, Sima...todavía?
Aclaremos: ¿Sial, Sima...todavía?
 
Levels of formality in writing2
Levels of formality in writing2Levels of formality in writing2
Levels of formality in writing2
 
The rules of composition - Photography
The rules of composition - PhotographyThe rules of composition - Photography
The rules of composition - Photography
 
La columna periodística
La columna periodísticaLa columna periodística
La columna periodística
 
A PROJECT REPORT ON A Study On Online Shopping Behavior Of Hostel Students fu...
A PROJECT REPORT ON A Study On Online Shopping Behavior Of Hostel Students fu...A PROJECT REPORT ON A Study On Online Shopping Behavior Of Hostel Students fu...
A PROJECT REPORT ON A Study On Online Shopping Behavior Of Hostel Students fu...
 
code of ethics for professional teacher
code of ethics for professional teachercode of ethics for professional teacher
code of ethics for professional teacher
 
PLAZA O DISTRIBUCION (marketing
PLAZA O DISTRIBUCION (marketing PLAZA O DISTRIBUCION (marketing
PLAZA O DISTRIBUCION (marketing
 
Streaming Big Data with Spark, Kafka, Cassandra, Akka & Scala (from webinar)
Streaming Big Data with Spark, Kafka, Cassandra, Akka & Scala (from webinar)Streaming Big Data with Spark, Kafka, Cassandra, Akka & Scala (from webinar)
Streaming Big Data with Spark, Kafka, Cassandra, Akka & Scala (from webinar)
 
Clothes ppt
Clothes pptClothes ppt
Clothes ppt
 
Clinical pharmacy
Clinical pharmacyClinical pharmacy
Clinical pharmacy
 
Holidays and Traditions in the UK.
Holidays and Traditions in the UK.Holidays and Traditions in the UK.
Holidays and Traditions in the UK.
 
William Shakespeare powerpoint
William Shakespeare powerpointWilliam Shakespeare powerpoint
William Shakespeare powerpoint
 
Face recognition ppt
Face recognition pptFace recognition ppt
Face recognition ppt
 
Planos y ejes del cuerpo humano
Planos y ejes del cuerpo humanoPlanos y ejes del cuerpo humano
Planos y ejes del cuerpo humano
 
Signos vitales
Signos vitalesSignos vitales
Signos vitales
 

Mais de Jean-François Gagné

Mais de Jean-François Gagné (20)

MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
 
Almost Perfect Service Discovery and Failover with ProxySQL and Orchestrator
Almost Perfect Service Discovery and Failover with ProxySQL and OrchestratorAlmost Perfect Service Discovery and Failover with ProxySQL and Orchestrator
Almost Perfect Service Discovery and Failover with ProxySQL and Orchestrator
 
Demystifying MySQL Replication Crash Safety
Demystifying MySQL Replication Crash SafetyDemystifying MySQL Replication Crash Safety
Demystifying MySQL Replication Crash Safety
 
The consequences of sync_binlog != 1
The consequences of sync_binlog != 1The consequences of sync_binlog != 1
The consequences of sync_binlog != 1
 
Autopsy of a MySQL Automation Disaster
Autopsy of a MySQL Automation DisasterAutopsy of a MySQL Automation Disaster
Autopsy of a MySQL Automation Disaster
 
MySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated EnvironmentMySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated Environment
 
MySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated EnvironmentMySQL Scalability and Reliability for Replicated Environment
MySQL Scalability and Reliability for Replicated Environment
 
Demystifying MySQL Replication Crash Safety
Demystifying MySQL Replication Crash SafetyDemystifying MySQL Replication Crash Safety
Demystifying MySQL Replication Crash Safety
 
Demystifying MySQL Replication Crash Safety
Demystifying MySQL Replication Crash SafetyDemystifying MySQL Replication Crash Safety
Demystifying MySQL Replication Crash Safety
 
The Full MySQL and MariaDB Parallel Replication Tutorial
The Full MySQL and MariaDB Parallel Replication TutorialThe Full MySQL and MariaDB Parallel Replication Tutorial
The Full MySQL and MariaDB Parallel Replication Tutorial
 
MySQL Parallel Replication by Booking.com
MySQL Parallel Replication by Booking.comMySQL Parallel Replication by Booking.com
MySQL Parallel Replication by Booking.com
 
MySQL Parallel Replication (LOGICAL_CLOCK): all the 5.7 (and some of the 8.0)...
MySQL Parallel Replication (LOGICAL_CLOCK): all the 5.7 (and some of the 8.0)...MySQL Parallel Replication (LOGICAL_CLOCK): all the 5.7 (and some of the 8.0)...
MySQL Parallel Replication (LOGICAL_CLOCK): all the 5.7 (and some of the 8.0)...
 
MySQL/MariaDB Parallel Replication: inventory, use-case and limitations
MySQL/MariaDB Parallel Replication: inventory, use-case and limitationsMySQL/MariaDB Parallel Replication: inventory, use-case and limitations
MySQL/MariaDB Parallel Replication: inventory, use-case and limitations
 
The two little bugs that almost brought down Booking.com
The two little bugs that almost brought down Booking.comThe two little bugs that almost brought down Booking.com
The two little bugs that almost brought down Booking.com
 
Autopsy of an automation disaster
Autopsy of an automation disasterAutopsy of an automation disaster
Autopsy of an automation disaster
 
How Booking.com avoids and deals with replication lag
How Booking.com avoids and deals with replication lagHow Booking.com avoids and deals with replication lag
How Booking.com avoids and deals with replication lag
 
MySQL Parallel Replication: inventory, use-case and limitations
MySQL Parallel Replication: inventory, use-case and limitationsMySQL Parallel Replication: inventory, use-case and limitations
MySQL Parallel Replication: inventory, use-case and limitations
 
MySQL Parallel Replication: inventory, use-case and limitations
MySQL Parallel Replication: inventory, use-case and limitationsMySQL Parallel Replication: inventory, use-case and limitations
MySQL Parallel Replication: inventory, use-case and limitations
 
MySQL Parallel Replication: inventory, use-cases and limitations
MySQL Parallel Replication: inventory, use-cases and limitationsMySQL Parallel Replication: inventory, use-cases and limitations
MySQL Parallel Replication: inventory, use-cases and limitations
 
Riding the Binlog: an in Deep Dissection of the Replication Stream
Riding the Binlog: an in Deep Dissection of the Replication StreamRiding the Binlog: an in Deep Dissection of the Replication Stream
Riding the Binlog: an in Deep Dissection of the Replication Stream
 

Último

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

MySQL Binlog Servers at Booking.com

  • 1. Jean-François Gagné jeanfrancois DOT gagne AT booking.com Presented at Percona Live Santa Clara 2015 Binlog Servers (and MySQL) at Booking.com
  • 3. Booking.com‟ ● Based in Amsterdam since 1996 ● Online Hotel and Accommodation Agent: ● 135 offices worldwide ● +619.000 properties in 211 countries ● 42 languages (website and customer service) ● Part of the Priceline Group ● And we are using MySQL: ● >3300 servers, ~85% replicating ● ~110 masters: ~30 >25 slaves, ~14 >50 slaves & ~4 >100 slaves 3
  • 4. Binlog Server: Session Summary 1. Replication and the Binlog Server 2. Extreme Read Scaling 3. Remote Site Replication (and Easy Disaster Recovery) 4. Easy High Availability 5. Other Use-Cases (Crash Safety and Parallel Replication) 6. Binlog Servers at Booking.com 7. Promoting a new master without touching slaves 4
  • 5. Binlog Server: Guiding Principles ● GTIDs are not needed for managing replication hierarchy ● Nor are Intermediate Masters  log-slave-updates can be avoided (for replication) 5
  • 6. Binlog Server: Replication ● One master / one or more slaves ● The master records all its writes in a journal: the binary logs ● Each slave: ● Downloads the journal and saves it locally (IO thread): relay logs ● Executes the relay logs on the local database (SQL thread) ● Could produce binary logs to be itself a master (log-slave-updates) ● Replication is: ● Asynchronous  lag ● Single threaded (in MySQL 5.6)  slower than the master 6
  • 7. Binlog Server: Booking.com‟‟ ● Typical replication deployment: ----- | M | ----- | +------+-- ... --+---------------+-------- ... | | | | ----- ----- ----- ----- | S1| | S2| | Sn| | M1| ----- ----- ----- ----- | +-- ... --+ | | ----- ----- | T1| | Tm| ----- ----- 7 ● Si and Tj are for read scaling ● Mi are the DR master Intermediate Master  log-slave-update :-(
  • 8. Binlog Server: What ● Binlog Server (BLS): is a daemon that: ● Downloads the binary logs from the master ● Saves them in the same structure as on the master ● Serves them to slaves ● A or X are the same for B and C: ● By design, the binary logs served by A and X are the same 8 ----- / | A | ---> / X ----- ----- | | ----- ----- | B | | C | ----- -----
  • 9. Binlog Server: Read Scaling ● Typical replication topology for read scaling: ----- | M | ----- | +------+------+-- ... --+ | | | | ----- ----- ----- ----- | S1| | S2| | S3| | Sn| ----- ----- ----- ----- 9 ● When there are too many slaves, the network interface of M is overloaded: ● 100 slaves x 1Mbit/s: very close to 1Gbit/s ● OSC or purging data in RBR becomes hard  Slave lag or unreachable master for writes
  • 10. Binlog Server: Read Scaling‟ ● Typical solution: fan-out with Intermediary Masters (IM): ----- | M | ----- | +----------+--- ... ---+ | | | ----- ----- ----- | M1| | M2| | Mm| ----- ----- ----- | | | +--- ... +--- ... +--- ... ---+ | | | | ----- ----- ----- ----- | S1| | T1| |...| | Zi| ----- ----- ----- ----- 10 ● But Intermediate Masters bring problems: ● log-slave-updates  IM are slower than slaves ● Lag of an IM  all its slaves are lagging ● Rogue transaction on an IM  infection of all its slave ● Failure of an IM  all its slaves stop replicating (and action must be taken fast)
  • 11. Binlog Server: Read Scaling‟‟ ● Solving Intermediate Master problems with shared disk: ● Filers (expensive) or DRBD (doubling the number of servers) ● HA needs sync_binlog=1 + trx_commit=1  replication is slower  lag ● After a crash of an Intermediate Master: ● we need InnoDB recovery  replication on slaves stalled  lag ● and the cache is cold  replication will be slow  lag ● Solving Intermediate Master problems with GTIDs: ● They allow slave repointing at the cost of added complexity :-| ● But they do not completely solve the lag problem :-( ● And we cannot migrate online with MySQL 5.6 :-( :-( 11
  • 12. Binlog Server: Read Scaling‟‟‟ ● New Solution: replace Intermediate Masters by Binlog Servers ----- | M | ----- | +----------------+------ ... ------+ | | | / / / / I1 / I2 / Im ----- ----- ----- | | | +------+ ... +--- ... +--- ... ---+ | | | | | ----- ----- ----- ----- ----- | S1| | S2| | Si| | Sj| | Sn| ----- ----- ----- ----- ----- ● If a BLS fails, repoint its slaves to other BLSs (easy by design) 12
  • 13. Binlog Server: Remote Site ● Typical deployment for remote site: ----- | A | ----- | +------+------+---------------+ | | | | ----- ----- ----- ----- | B | | C | | D | | E | ----- ----- ----- ----- | +------+------+ | | | ----- ----- ----- | F | | G | | H | ----- ----- ----- ● E is an Intermediate Master  same problems as read scaling 13 Yuck !
  • 14. Binlog Server: Remote Site‟ ● Ideally, we would like this: ----- | A | ----- | +------+------+---------------+------+------+------+ | | | | | | | ----- ----- ----- ----- ----- ----- ----- | B | | C | | D | | E | | F | | G | | H | ----- ----- ----- ----- ----- ----- ----- ● No lag and no Single Point of Failure (SPOF) ● But no master on remote site for writes (easy solvable problem) ● And expensive in WAN bandwidth (harder problem to solve) 14
  • 15. Binlog Server: Remote Site‟‟ ● New solution: a Binlog Server on the remote site: ----- | A | ----- | +------+------+---------------+ | | | | ----- ----- ----- / | B | | C | | D | / X ----- ----- ----- ----- | +------+------+------+ | | | | ----- ----- ----- ----- | E | | F | | G | | H | ----- ----- ----- ----- 15
  • 16. Binlog Server: Remote Site‟‟‟ ● Or deploy 2 Binlog Servers to get better resilience: ----- | A | ----- | +------+------+---------------+ | | | | ----- ----- ----- / / | B | | C | | D | / X ------> / Y ----- ----- ----- ----- ----- | | +------+ +------+ | | | | ----- ----- ----- ----- | E | | F | | G | | H | ----- ----- ----- ----- ● If Y fails, repoint G and H to X; if X fails, repoint Y to A and E and F to Y 16
  • 17. Binlog Server: Remote Site‟‟‟‟ ● Interesting property: if A fails, E, F, G & H converge to a common state ----- | A | ----- | +------+------+---------------+ | | | | ----- ----- ----- / | B | | C | | D | / X ----- ----- ----- ----- | +------+------+------+ | | | | ----- ----- ----- ----- | E | | F | | G | | H | ----- ----- ----- ----- ● New master promotion is easy on remote site 17
  • 18. Binlog Server: Remote Site‟‟‟‟‟ ● Step by step master promotion: 1. The 1st slave that is up to date can be the new master 2. “SHOW MASTER STATUS” or “RESET MASTER”, and “RESET SLAVE ALL” on the new master 3. Writes can be pointed to the new master 4. Once a slave is up to date, repoint it to the new master at the position of step # 2 5. Keep delayed/lagging slaves under X until up to date 6. Once no slaves is left under X, recycle it as a Binlog Server for the new master 18 / / X ----- | +-------------+ | ----- | G | ----- ----- | F | ----- | +------+ | | ----- ----- | E | | H | ----- -----
  • 19. Binlog Server: High Availability ● This property can be used for high availability: ----- | A | ----- | / / X ----- | +------+------+------+------+------+------+------+ | | | | | | | | ----- ----- ----- ----- ----- ----- ----- ----- | B | | C | | D | | E | | F | | G | | H | | I | ----- ----- ----- ----- ----- ----- ----- ----- 19
  • 20. Binlog Server: Other Use-Cases ● Better Crash-Safe Replication ● http://blog.booking.com/ better_crash_safe_replication_for_mysql.html ● And Better Parallel Replication ● http://blog.booking.com/ better_parallel_replication_for_mysql.html 20
  • 21. BLS@Booking.com ● Reminder: typical replication deployment at Booking.com: ----- | M | ----- | +--- ... ---+ ... +-------------+--- ... | | | | ----- ----- ----- ----- | S1| | Sj| | Sn| | M1| ----- ----- ----- ----- | +-- ... --+ | | ----- ----- | T1| | To| ----- ----- 21
  • 22. BLS@Booking.com‟ ● We are deploying Binlog Server Clusters to offload some masters: ----- | M | ----- | +-----+-----+ ... +-------------+--- ... | | | | | / / ----- ----- ----- / A1 / A2 | Sj| | Sn| | M1| ----- ----- ----- ----- ----- | | | +-+-----+-+ ... -+-----+ | | | | ----- ----- / / | S1| ... | Si| / Z1 / Z2 ----- ----- ----- ----- 22 ● We have in production: ● 18 Binlog Servers ● 8 clusters (two with 3 BLSs) ● ~400 slaves replicating from Binlog Servers (those number are increasing)
  • 23. BLS@Booking.com‟‟ ● What is a Binlog Server Cluster ? ● At least 2 Binlog Servers ● Replicating from the same master ● With independent failure mode (not on the same switch/rack/…) ● With a Service DNS entry resolving to all IP addresses of the BLSs  A failure of a Binlog Server is transparent to slaves ● Thanks to DNS, the slaves connected to a failing Binlog Server reconnect to the other still working Binlog Server(s)  Easy maintenance/upgrade of a Binlog Server 23 | +-----+ | | / / / A1 / A2 ----- ----- | | +-+-----+-+ | | ----- ----- | S1| ... | Si| ----- -----
  • 24. MariaDB MaxScale Binlog Router ● High Performance Parallel Replication with Bin Log Router: […] provides efficient replication from master to slave without the need for intermediate masters. This plugin receives binlog records from a master and makes them available immediately to slaves […]. You can use MaxScale‟s binlog server for replication to slaves across one or more datacenters and deliver a high performance user experience. 24
  • 25. BLS@Booking.com‟‟‟ ● We are also deploying BLS side-by-side with IM to reduce delay: ----- | M | ----- | +-----+-----+ ... +-------------+-----+----------- ... | | | | | | / / ----- ----- ----- / -->/ / A1 / A2 | Sj| | Sn| | M1| / B1 / B2 ----- ----- ----- ----- ----- ----- ----- | | | | | +-+-----+-+ ... +-+-----+-+ | | | | ----- ----- ----- ----- | S1| ... | Si| | Tk| ... | To| ----- ----- ----- ----- 25
  • 26. BLS@Booking.com‟‟‟‟ ● We are planning to deploy our next Data Center without IM: ----- | M | ----- | +-----+-----+ ... +-------------+-----+----------- ... -----+ | | | | | | | / / ----- ----- ----- / -->/ / -->/ / A1 / A2 | Sj| | Sn| | M1| / B1 / B2 / C1 / C2 ----- ----- ----- ----- ----- ----- ----- ----- ----- | | | | | | | +-+-----+-+ ... +-+-----+-+ +-+-----+-+ | | | | | | ----- ----- ----- ----- ----- ----- | S1| ... | Si| | Tk| ... | To| | U1| ... | Up| ----- ----- ----- ----- ----- ----- 26
  • 27. Future of Binlog Servers ● Distributed Binlog Serving Service (DBSS): ----- | M | ----- | +----+----------- ... --------------- ... ----------------+ | | +----+-------+--- ... ---+-------+--- ... ---+-------+----+ | | | | | | ----- ----- ----- ----- ----- ----- | S1|...| Sn| | T1|...| Tm| | U1|...| Uo| ----- ----- ----- ----- ----- ----- ● Properties: ● A single Binlog Server failure does not disrupt the service (resilience) ● Minimise inter Data Center bandwidth requirements ● Allows to promote a new master without touching any slave 27
  • 28. Future of Binlog Servers‟ ● Zoom in DBSS: | +----|------------- ... ----------------- ... -----------------+ | | | | +------------- ... ----+------------ ... ----+ | | | | | | | / / / | | / --->/ / --->/ / --->/ | | ----- / ----- / ----- / | | | ----- | ----- | ----- | +----|-------|----- ... ----|-------|---- ... ----|-------|----+ | | | | | | 28
  • 29. Future of Binlog Servers‟‟ ● Crash of the master: ● Step # 1: level the Binlog Servers (the slaves will follow) +------------------ ... ----------------- ... -----------------+ | | | | | | | / / / | | / --->/ / --->/ / --->/ | | ----- / ----- / ----- / | | | ----- | ----- | ----- | +----|-------|----- ... ----|-------|---- ... ----|-------|----+ | | | | | | 29 <------------------- ------------------>
  • 30. Future of Binlog Servers‟‟‟ ● Crash of the master: ● Step # 2: promote a slave as the new master (there is a trick) | +------------------ ... ----------------- ... ----|------------+ | | | | +----------------------+---------------------+ | | | | | | | / / / | | / --->/ / --->/ / --->/ | | ----- / ----- / ----- / | | | ----- | ----- | ----- | +----|-------|----- ... ----|-------|---- ... ----|-------|----+ | | | | | | 30
  • 31. Future of Binlog Servers‟‟‟‟ ● Crash of the master - the trick: ● Needs the same binary log filename on master and slaves 1. “FLUSH BINARY LOGS” on candidate master until its binary log filename follows the one available on the Binlog Servers 2. On the new master: ● “PURGE BINARY LOGS TO „<latest binary log file>'” ● “RESET SLAVE ALL” 3. Point the writes to the new master 4. Make the Binlog Servers replicate from the new master ● From the point of view of the Binlog Server, the master only rebooted with a new ServerID and a new UUID. 31
  • 32. New Master wo Touching Slaves 32 --/- ----- | X | | T1| -/-- ----- | +----+----------- ... ---+----------- ... ----------------+ | | +----+-------+--- ... -----------+--- ... ---+-------+----+ | | | | | ----- ----- ----- ----- ----- | S1|...| Sn| ...| Tm| | U1|...| Uo| ----- ----- ----- ----- -----
  • 33. Binlog Server: Links ● http://blog.booking.com/mysql_slave_scaling_and_more.html ● MaxScale High Performance Binlog Relay: https://mariadb.com/products/mariadb-maxscale ● HOWTO Install and Configure a MaxScale Binlog Server: http://jfg-mysql.blogspot.com/2015/04/maxscale-binlog-server-howto-install-and-configure.html ● http://blog.booking.com/better_crash_safe_replication_for_mysql.html ● http://blog.booking.com/better_parallel_replication_for_mysql.html ● (http://blog.booking.com/evaluating_mysql_parallel_replication_2-slave_group_commit.html) ● The MaxScale mailing list (to ask questions): maxscale@googlegroups.com ● Note: the Binlog Servers concept should work with any version of MySQL (5.7, 5.6, 5.5 and 5.1) or MariaDB (10.1, 10.0, 5.5. 5.3, 5.2 and 5.1) 33
  • 34. Questions Jean-François Gagné jeanfrancois DOT gagne AT booking.com (maxscale AT googlegroups.com)