SlideShare a Scribd company logo
Massively Distributed Backups at Facebook Scale - Shlomo Priymak, Facebook - DevOpsDays Tel Aviv 2015
Massively Distributed Backup

at Facebook Scale
Shlomo Priymak (shlomo@fb.com, @shlomoid)
Production Engineering Manager, MySQL Infrastructure
MySQL at Facebook
Sharding
fbid is 64bit integer
map(fbid) = shard id
{
"id": "101231234567123",
"name": "Shlomo Priymak"
}
graph API Example
graph.facebook.com/me
server
instance
shard #4
shard #3
shard #2
shard #1
server
instance
shard #4
shard #3
shard #2
shard #1
server
instance
shard #4
shard #3
shard #2
shard #1
server
instance
shard #4
shard #3
shard #2
shard #1
Master
Slaves
Replica Set
Prineville, Oregon
Altoona, Iowa
Forest City, North Carolina
Ashburn,Virginia
Luleå, Sweden
100
1000+
Massively Distributed Backups at Facebook Scale - Shlomo Priymak, Facebook - DevOpsDays Tel Aviv 2015
Massively Distributed Backups at Facebook Scale - Shlomo Priymak, Facebook - DevOpsDays Tel Aviv 2015
Backup Fundamentals
• `mysqldump`
• --single-transaction
• Logical Read Ahead
Full Dumps
Logical vs. Physical
Logical Physical
External Tools Yes No
Size Small Large
Single Table Restore Easy Difficult
Debug Corruption Easy Difficult
Compressibility Excellent Meh
Backup / Restore Duration Long Short
Differential Backup
Differential Backup
0
2
4
6
8
% of space taken by differential backups
Day 1 Day 2 Day 3 Day 4
0
25
50
75
100
Relative backup space usage
Day 1 Day 2 Day 3 Day 4
Full Backup Differential Backup
Differential Backup Generation
INSERT INTO t VALUES
(1, ‘San Fransisco’),
(2, ‘Santa Clara`),
(400, ‘Los Angeles’),

[...]
);
INSERT INTO t1 VALUES (
);
INSERT INTO t1 VALUES (
);
INSERT INTO t VALUES
(1, ‘San Fransisco’),
(2, ‘Oakland`),
(3, ‘Menlo Park’),

[...]
);
No Change
Inserted Rows
CREATE TABLE t (id int,
city char(50);
/* ORDERING KEY : (id) */
Full Backup (old) Full Backup (new)
Deleted Rows
Differential Backup Generation
INSERT INTO t VALUES
(1, ‘San Fransisco’),
(2, ‘Santa Clara`),
(400, ‘Los Angeles’),

[...]
);
INSERT INTO t1 VALUES (
(2, ‘Santa Clara’),
);
INSERT INTO t1 VALUES (
(2, ‘OakLand’),
);
INSERT INTO t VALUES
(1, ‘San Fransisco’),
(2, ‘Oakland`),
(3, ‘Menlo Park’),

[...]
);
Row Updated
Inserted RowsDeleted Rows
Full Backup (old) Full Backup (new)
CREATE TABLE t (id int,
city char(50);
/* ORDERING KEY : (id) */
Differential Backup Generation
INSERT INTO t VALUES
(1, ‘San Fransisco’),
(2, ‘Santa Clara`),
(400, ‘Los Angeles’),

[...]
);
INSERT INTO t1 VALUES (
(2, ‘Santa Clara’),
);
INSERT INTO t1 VALUES (
(2, ‘OakLand’),
(3, ‘Menlo Park’),
);
INSERT INTO t VALUES
(1, ‘San Fransisco’),
(2, ‘Oakland`),
(3, ‘Menlo Park’),

[...]
);
Row Deleted
Inserted RowsDeleted Rows
Full Backup (old) Full Backup (new)
CREATE TABLE t (id int,
city char(50);
/* ORDERING KEY : (id) */
Differential Backup Generation
INSERT INTO t VALUES
(1, ‘San Fransisco’),
(2, ‘Santa Clara`),
(400, ‘Los Angeles’),

[...]
);
INSERT INTO t1 VALUES (
(2, ‘Santa Clara’),
(400, ‘Los Angeles’),
);
INSERT INTO t1 VALUES (
(2, ‘OakLand’),
(3, ‘Menlo Park’),
);
INSERT INTO t VALUES
(1, ‘San Fransisco’),
(2, ‘Oakland`),
(3, ‘Menlo Park’),

[...]
);
Row Inserted
Inserted RowsDeleted Rows
Full Backup (old) Full Backup (new)
CREATE TABLE t (id int,
city char(50);
/* ORDERING KEY : (id) */
Final Output
INSERT INTO t1 VALUES (
(2, ‘Santa Clara’),
(400, ‘Los Angeles’),
);
INSERT INTO t1 VALUES (
(2, ‘OakLand’),
(3, ‘Menlo Park’),
);
Inserted RowsDeleted Rows
Restoring Diff Backup
INSERT INTO t1 VALUES (
(2, ‘Santa Clara’),
(400, ‘Los Angeles’),
);
Inserted Rows
INSERT INTO t1 VALUES (
(2, ‘OakLand’),
(3, ‘Menlo Park’),
);
Deleted Rows
INSERT INTO t VALUES
(1, ‘San Fransisco’),
(2, ‘Oakland`),
(3, ‘Menlo Park’),

[...]
);
Full Backup (old)
3-Way Merge
INSERT INTO t VALUES
(1, ‘San Fransisco’),
(2, ‘Santa Clara`),
(400, ‘Los Angeles’),

[...]
);
Full Backup (new)
• Point in time recovery
• Global Transaction IDs
Binary Logs
Continuous Restore
∞
• Everything, Every Day
• Streaming Binary Logs
• Multiple stages
• HDFS
• Offsite
Backup Schedule
What, When, Where
Backup Schedule
Full, Diff, Diff, Diff, Full, Diff, Diff, Diff, Full, Diff, Diff, Diff…
Full
5
Diff
6
Diff
7
Diff
8
Full
9
Diff
10
Diff
11
Diff
12
Full
1
Diff
2
Diff
3
Diff
4
Backup Traffic
3.5 Tb/s
Peak
~0.5 Tb/s
Trough
Differential Backup Stages
1) mysql HDFSFull (new)
2) HDFS
Full (new)
Full (old)
Diff (new) HDFSDiffer
• Too much HDFS I/O
• Too much network I/O
• Too long
#fail
Differential Backup Stages
1) mysql HDFSFull (new)
2) HDFS
Full (new)
Full (old)
Diff (new) HDFSDiffer
Differential Streaming
mysql
HDFS
Full(new)
Full(old) Diff (new)Differ HDFS
Database Server
Prineville, Oregon
Altoona, Iowa
Forest City, North Carolina
Ashburn,Virginia
Luleå, Sweden
1. Target
2. Source
• Equalize HDFS cluster usage
• Minimize cross-region traffic
• Avoid broken replicas
• Consistency
• Backup at least once!
System Design Goals
• Define allocation globally
• Hash shards into a 1000 buckets
• Allocate buckets to clusters,
proportional to size
Distribution Algorithm
server
instance
shard 14
shard 13
shard 12
shard 11
shard 10
shard 9
shard 8
shard 7
shard 6
shard 5
shard 4
shard 3
shard 2
shard 1
998997 999
4
1000
321
shard 14
shard 13shard 12
shard 11
shard 10
shard 9 shard 8
shard 7 shard 6
shard 5
shard 4
shard 3
shard 2
shard 1
1000 Buckets
HDFS 2HDFS 1 HDFS 3 HDFS 4 HDFS 5
101 400100 401 600 601 850 851 1000
1 PB 3 PB 2 PB 2.5 PB 1.5 PB
1
100 buckets 300 buckets 200 buckets 250 buckets 150 buckets
Total buckets: 1000
Total size: 10 PB (Example)
HDFS 2HDFS 1 HDFS 3 HDFS 4 HDFS 5
101 400100 401 600 601 850 851 1000
1 PB 3 PB 2 PB 2.5 PB 1.5 PB
Bucket 20
Bucket 200
Bucket 500
Bucket 650
Bucket 900
Bucket 30
Bucket 400
1
Bucket 700
Bucket 800
Unified Pool
Some are More Equal than Others?
sorted unsorted
sorted unsorted
Rebalance / Convergence
A
CB
1. C
2. A
3. B
1. C
2. A
3. B
1. C
2. A
3. B
Is Alive?
A
CB
α
HDFS
ɣ
HDFS
Δ(B, α) = 10
Δ(A, α) = 0
Δ(A, ɣ) = 20
Δ(B, ɣ) = 15
Δ(C, ɣ) = 0
HDFS Priority
ɣ 0
α 1
rank(mysql, hdfs) ≡ (
Δ(mysql, hdfs),
priority(hdfs),
)
𝕄 ={A, B, C}// MySQL Servers
𝓗 ={α, ɣ}// HDFS Clusters
𝕄×𝓗 ={(m, h): m∈𝕄 ∧ h∈𝓗}
return sort(𝕄×𝓗,
key=rank(m, h))
Δ priority
A, α 0 1
A, ɣ 20 0
B, α 10 1
B, ɣ 15 0
C, α 20 1
C, ɣ 0 0
Δ priority
C, ɣ 0 0
A, α 0 1
B, α 10 1
B, ɣ 15 0
A, ɣ 20 0
C, α 20 1
Pile it Up
A
CB
War Story: Cluster Turn Up
• New HDFS Cluster
• New Datacenter
• Slow Ramp-Up
New Region Cluster Turn Up
• Network woes
• Pulling full backups to create diffs!
• Fix: run full when target HDFS changes
New Region Cluster Turn Up
New Region Cluster Turn Up, cont.
New Region Cluster Turn Up, cont.
Call From the Engine Room
• Emergency meeting
• Fix: Turn off a few racks
Divert Power to the Shields!
The Future!
• Record previous value by default
• Binary Logs + Binary Logs => Diff
• Full + Diff => Full
• In theory, run full backup only once!
Row Based Binary Logs
Questions!
Shlomo Priymak (shlomo@fb.com)

@shlomoid

More Related Content

PPTX
Lecture2 mysql by okello erick
PDF
9. R data-import data-export
PPTX
Intro to my sql
PPTX
Hive commands
PPT
Oracle 10g Performance: chapter 00 sampling
PDF
Sql cheat sheet
ODP
Patterns for slick database applications
PDF
Testing stateful, concurrent, and async systems using test.check
Lecture2 mysql by okello erick
9. R data-import data-export
Intro to my sql
Hive commands
Oracle 10g Performance: chapter 00 sampling
Sql cheat sheet
Patterns for slick database applications
Testing stateful, concurrent, and async systems using test.check

What's hot (20)

PDF
HPCC Systems - ECL for Programmers - Big Data - Data Scientist
PDF
7. Data Import – Data Export
 
PDF
Codigos
PDF
R data-import, data-export
 
PDF
Diagnosing Open-Source Community Health with Spark-(William Benton, Red Hat)
TXT
Hive integration
PPTX
SPL - The Undiscovered Library - PHPBarcelona 2015
PDF
John Melesky - Federating Queries Using Postgres FDW @ Postgres Open
DOCX
Exadata - BULK DATA LOAD Testing on Database Machine
PDF
Postgres performance for humans
PDF
Using Scala Slick at FortyTwo
PPTX
Slick: Bringing Scala’s Powerful Features to Your Database Access
PPT
Intro to my sql
PPTX
R part iii
PDF
PostgreSQL, performance for queries with grouping
PDF
ClickHouse Unleashed 2020: Our Favorite New Features for Your Analytical Appl...
PDF
How to Use JSON in MySQL Wrong
PDF
ClickHouse Features for Advanced Users, by Aleksei Milovidov
PDF
Deep dive to PostgreSQL Indexes
PPTX
Php data structures – beyond spl (online version)
HPCC Systems - ECL for Programmers - Big Data - Data Scientist
7. Data Import – Data Export
 
Codigos
R data-import, data-export
 
Diagnosing Open-Source Community Health with Spark-(William Benton, Red Hat)
Hive integration
SPL - The Undiscovered Library - PHPBarcelona 2015
John Melesky - Federating Queries Using Postgres FDW @ Postgres Open
Exadata - BULK DATA LOAD Testing on Database Machine
Postgres performance for humans
Using Scala Slick at FortyTwo
Slick: Bringing Scala’s Powerful Features to Your Database Access
Intro to my sql
R part iii
PostgreSQL, performance for queries with grouping
ClickHouse Unleashed 2020: Our Favorite New Features for Your Analytical Appl...
How to Use JSON in MySQL Wrong
ClickHouse Features for Advanced Users, by Aleksei Milovidov
Deep dive to PostgreSQL Indexes
Php data structures – beyond spl (online version)
Ad

Similar to Massively Distributed Backups at Facebook Scale - Shlomo Priymak, Facebook - DevOpsDays Tel Aviv 2015 (20)

PDF
System design handwritten notes guidance
PDF
System Design.pdf
PPTX
Cloud storage
PPTX
Scalabe MySQL Infrastructure
PDF
Cassandra Explained
PDF
About "Apache Cassandra"
PPTX
The breakup
PPTX
The Breakup - Logically Sharding a Growing PostgreSQL Database
PDF
Retaining globally distributed high availability
PPTX
Infrastructure review - Shining a light on the Black Box
PDF
MySQL Conference 2011 -- The Secret Sauce of Sharding -- Ryan Thiessen
PPTX
Hadoop Backup and Disaster Recovery
PDF
Five data models for sharding and which is right | PGConf.ASIA 2018 | Craig K...
PDF
Five Data Models for Sharding | Nordic PGDay 2018 | Craig Kerstiens
PDF
Dublin Meetup: Cassandra anti patterns
PPT
Key Challenges in Cloud Computing and How Yahoo! is Approaching Them
PDF
Outside The Box With Apache Cassnadra
PDF
Scaling Databases On The Cloud
PDF
Scaing databases on the cloud
PDF
Cassandra summit keynote 2014
System design handwritten notes guidance
System Design.pdf
Cloud storage
Scalabe MySQL Infrastructure
Cassandra Explained
About "Apache Cassandra"
The breakup
The Breakup - Logically Sharding a Growing PostgreSQL Database
Retaining globally distributed high availability
Infrastructure review - Shining a light on the Black Box
MySQL Conference 2011 -- The Secret Sauce of Sharding -- Ryan Thiessen
Hadoop Backup and Disaster Recovery
Five data models for sharding and which is right | PGConf.ASIA 2018 | Craig K...
Five Data Models for Sharding | Nordic PGDay 2018 | Craig Kerstiens
Dublin Meetup: Cassandra anti patterns
Key Challenges in Cloud Computing and How Yahoo! is Approaching Them
Outside The Box With Apache Cassnadra
Scaling Databases On The Cloud
Scaing databases on the cloud
Cassandra summit keynote 2014
Ad

More from DevOpsDays Tel Aviv (20)

PDF
YOUR OPEN SOURCE PROJECT IS LIKE A STARTUP, TREAT IT LIKE ONE, EYAR ZILBERMAN...
PPTX
GRAPHQL TO THE RES(T)CUE, ELLA SHARAKANSKI, Salto
PPTX
MICROSERVICES ABOVE THE CLOUD - DESIGNING THE INTERNATIONAL SPACE STATION FOR...
PPTX
THE (IR)RATIONAL INCIDENT RESPONSE: HOW PSYCHOLOGICAL BIASES AFFECT INCIDENT ...
PPTX
PRINCIPLES OF OBSERVABILITY // DANIEL MAHER, DataDog
PPTX
NUDGE AND SLUDGE: DRIVING SECURITY WITH DESIGN // J. WOLFGANG GOERLICH, Duo S...
PPTX
(Ignite) TAKE A HIKE: PREVENTING BATTERY CORROSION - LEAH VOGEL, CHEGG
PPTX
BUILDING A DR PLAN FOR YOUR CLOUD INFRASTRUCTURE FROM THE GROUND UP, MOSHE BE...
PPTX
THE THREE DISCIPLINES OF CI/CD SECURITY, DANIEL KRIVELEVICH, Cider Security
PDF
THE PLEASURES OF ON-PREM, TOMER GABEL
PPTX
CONFIGURATION MANAGEMENT IN THE CLOUD NATIVE ERA, SHAHAR MINTZ, EggPack
PPTX
SOLVING THE DEVOPS CRISIS, ONE PERSON AT A TIME, CHRISTINA BABITSKI, Develeap
PPTX
OPTIMIZING PERFORMANCE USING CONTINUOUS PRODUCTION PROFILING ,YONATAN GOLDSCH...
PPTX
HOW TO SCALE YOUR ONCALL OPERATION, AND SURVIVE TO TELL, ANTON DRUKH
PPTX
HOW TO OPTIMIZE NON-CODING TIME, ORI KEREN, LinearB
PPTX
FLYING BLIND - ACCESSIBILITY IN MONITORING, FEU MOUREK, Icinga
PPTX
(Ignite) WHAT'S BURNING THROUGH YOUR CLOUD BILL - GIL BAHAT, CIDER SECURITY
PPTX
SLO DRIVEN DEVELOPMENT, ALON NATIV, Tomorrow.io
PPTX
ONBOARDING IN LOCKDOWN, HILA FOX, Augury
PPTX
DON'T PANIC: GETTING YOUR INFRASTRUCTURE DRIFT UNDER CONTROL, ERAN BIBI, Firefly
YOUR OPEN SOURCE PROJECT IS LIKE A STARTUP, TREAT IT LIKE ONE, EYAR ZILBERMAN...
GRAPHQL TO THE RES(T)CUE, ELLA SHARAKANSKI, Salto
MICROSERVICES ABOVE THE CLOUD - DESIGNING THE INTERNATIONAL SPACE STATION FOR...
THE (IR)RATIONAL INCIDENT RESPONSE: HOW PSYCHOLOGICAL BIASES AFFECT INCIDENT ...
PRINCIPLES OF OBSERVABILITY // DANIEL MAHER, DataDog
NUDGE AND SLUDGE: DRIVING SECURITY WITH DESIGN // J. WOLFGANG GOERLICH, Duo S...
(Ignite) TAKE A HIKE: PREVENTING BATTERY CORROSION - LEAH VOGEL, CHEGG
BUILDING A DR PLAN FOR YOUR CLOUD INFRASTRUCTURE FROM THE GROUND UP, MOSHE BE...
THE THREE DISCIPLINES OF CI/CD SECURITY, DANIEL KRIVELEVICH, Cider Security
THE PLEASURES OF ON-PREM, TOMER GABEL
CONFIGURATION MANAGEMENT IN THE CLOUD NATIVE ERA, SHAHAR MINTZ, EggPack
SOLVING THE DEVOPS CRISIS, ONE PERSON AT A TIME, CHRISTINA BABITSKI, Develeap
OPTIMIZING PERFORMANCE USING CONTINUOUS PRODUCTION PROFILING ,YONATAN GOLDSCH...
HOW TO SCALE YOUR ONCALL OPERATION, AND SURVIVE TO TELL, ANTON DRUKH
HOW TO OPTIMIZE NON-CODING TIME, ORI KEREN, LinearB
FLYING BLIND - ACCESSIBILITY IN MONITORING, FEU MOUREK, Icinga
(Ignite) WHAT'S BURNING THROUGH YOUR CLOUD BILL - GIL BAHAT, CIDER SECURITY
SLO DRIVEN DEVELOPMENT, ALON NATIV, Tomorrow.io
ONBOARDING IN LOCKDOWN, HILA FOX, Augury
DON'T PANIC: GETTING YOUR INFRASTRUCTURE DRIFT UNDER CONTROL, ERAN BIBI, Firefly

Recently uploaded (20)

PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Machine learning based COVID-19 study performance prediction
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Big Data Technologies - Introduction.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
NewMind AI Weekly Chronicles - August'25 Week I
Diabetes mellitus diagnosis method based random forest with bat algorithm
Per capita expenditure prediction using model stacking based on satellite ima...
The Rise and Fall of 3GPP – Time for a Sabbatical?
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Review of recent advances in non-invasive hemoglobin estimation
Machine learning based COVID-19 study performance prediction
Spectral efficient network and resource selection model in 5G networks
Mobile App Security Testing_ A Comprehensive Guide.pdf
The AUB Centre for AI in Media Proposal.docx
Unlocking AI with Model Context Protocol (MCP)
Build a system with the filesystem maintained by OSTree @ COSCUP 2025

Massively Distributed Backups at Facebook Scale - Shlomo Priymak, Facebook - DevOpsDays Tel Aviv 2015