MySQL Backup and Restore at Facebook Scale
Ola Berjak
Production Engineer at MySQL Infrastructure, Facebook London
MySQL Backup and Restore at Facebook Scale Ola Berjak Production - - PowerPoint PPT Presentation
MySQL Backup and Restore at Facebook Scale Ola Berjak Production Engineer at MySQL Infrastructure, Facebook London MySQL Backup and Restore at Facebook Scale and how its not rocket science Ola Berjak Production Engineer at MySQL
MySQL Backup and Restore at Facebook Scale
Ola Berjak
Production Engineer at MySQL Infrastructure, Facebook London
MySQL Backup and Restore at Facebook Scale
Production Engineer at MySQL Infrastructure, Facebook London
…and how it’s not rocket science Ola Berjak
When do we need backups? How do we perform backups? How do we restore backups?
4When do we need backups? How do we perform backups? How do we restore backups?
5When do we need backups? How do we perform backups? How do we restore backups?
6When do we need backups?
7FULL DUMPS DIFFS
10How do we perform backups?
11Every database, every day
12LOGICAL BACKUPS PHYSICAL BACKUPS CUSTOMER LOGIC Ea Easy sy Complex DEBUGGING Ea Easy sy Complex SINGLE TABLE RESTORE Ea Easy sy Complex PORTABILITY Con Consistent Inconsistent BACKUP AND RESTORE DURATION Long Short
13mysqldump number of rows for each table zstd compression
Technical setup
FULL DUMPS
trailing index
14mysqldump --single-transaction --skip-lock- tables (...)
mysqldump --single-transaction --skip-lock- tables (...) | compress and add index
mysqldump --single-transaction --skip-lock- tables (...) | compress and add index | upload
17Trailing index
{ "size": 7331, "offset": 1337, "table_name": "foo" }, { "size": 223, "offset": 8668, "table_name": "bar" }
18mysqldump: https://github.com/facebook/mysql-5.6 zstd: https://github.com/facebook/zstd
Open-source
19Open source tooling will get the job done
20Open source tooling will get the job done
au autom
sqlbacku ackup
scheduling email notifications custom backup rotation
21Open source tooling will get the job done
au autom
sqlbacku ackup
scheduling email notifications custom backup rotation
mo monitoring tools
alerting
22full dump format 2 files for a single diff backup rows removed
Technical setup
DIFFS
rows inserted and updated
24diff2 diff1
most recent dump backup, “base dump” new dump
DiffDatabase
CREATE TABLE foo INSERT INTO foo
CREATE TABLE bar INSERT INTO bar CREATE TABLE foo INSERT INTO foo
CREATE TABLE bar INSERT INTO bar
25diff1 MergeDatabase
CREATE TABLE foo INSERT INTO foo
CREATE TABLE bar INSERT INTO bar
new dump
diff2
CREATE TABLE foo INSERT INTO foo
CREATE TABLE bar INSERT INTO bar
base dump
26D D D D F D D D D F F
27less space used
28Explore the open source tooling
29Explore the open source tooling
au autom
sqlbacku ackup
scheduling email notifications custom backup rotation
di different ntial al bac acku kups
30Due diligence checklist
31Due diligence checklist
32Due diligence checklist
33Due diligence checklist
34all transactions for all databases from master compressed using zstd
Technical setup
BINARY LOGS
metadata stored
36Due diligence checklist
37Due diligence checklist
38Due diligence checklist
39How do we restore backups?
40Continuous restore pipeline
41Scheduler
Continuous restore pipeline
42Warchief Loadbalancer
Continuous restore pipeline
43Scheduler
DB
Continuous restore pipeline
Loadbalancer
44Scheduler
Worker Worker Worker Worker
MySQL MySQL MySQL MySQL
DB
Continuous restore pipeline
Loadbalancer
45Scheduler
SELECT CHECKSUM DOWNLOAD LOAD VERIFY REPLAY
46SELECT CHECKSUM DOWNLOAD LOAD VERIFY REPLAY
47SELECT CHECKSUM DOWNLOAD LOAD VERIFY REPLAY
48SELECT CHECKSUM DOWNLOAD LOAD VERIFY REPLAY
49SELECT CHECKSUM DOWNLOAD LOAD VERIFY REPLAY
50SELECT CHECKSUM DOWNLOAD LOAD VERIFY REPLAY
51Start small and build up
52BUSINESS PRIORITIES DEVELOPMENT TIME BUSINESS CONTINUITY DATA RESILIENCE
53Today’s agenda
Why do we need backups? Backups and restores made easy How to make sure our backups don’t go to ’’/dev/null”?
54Today’s agenda
Why do we need backups? Backups and restores made easy How to make sure our backups don’t go to ’’/dev/null”?
55Today’s agenda
Why do we need backups? Backups and restores made easy How to make sure our backups don’t go to ’’/dev/null”?
56“The best outages are the ones that don’t happen.”
PRETTY MUCH EVERY PRODUCTION ENGINEER I KNOW
58Thank you
59Ola Berjak
aberjak@fb.com @Lexxzor
60