SlideShare a Scribd company logo
Engineer, Cloud Team, 10gen
Steve Briskin
Walking the Walk:
Developing the MongoDB
Backup Service With MongoDB
Agenda
• Intro: The Project
• How the backup service was built
– Keeping State
– Storage of Oplog Documents
– De-duped Snapshot Storage
• Q&A
The Project
• Started in December 2011 – 1 person
• 3 Engineers + PM & Manager by June 2012
• Private Beta – September 2012
• Limited Release – April 2013
• 6 Engineers (and hiring) + PM & Manager –
Now
• Agile Principles
Data Flow
Reconstructed Replica Sets
Sharded
Cluster
BRS
Daemon
Backu
p
Agent
Replica
Set 1
Customer
Replica
Set 4
Replica
Set 3
Replica
Set 2
Backup
Ingestion
10GEN
Backup
Daemon(s)
Main DB
Block
Store
RS
1
RS
2
RS
3
RS
4
2. Initial
Sync3. OpLog Data
1. Configuration
4. Save
Sync/Oplog Data
5. Reconstruct
Replica Set
6. Persist
Snapshot
7. Retrieve
Snapshot
8. SCP Data
Files
How We Built It (Iteratively)
Keeping State – First Version
• One document per replica set being backed up
{
_id : ObjectId("5194ecde036446e958b9df9b"),
groupId : “Customer Group”,
replicaSet : ”ReplSet Name",
broken : false,
workingOn : “Initial Sync”,
numOplogs : NumberInt(100),
head :Timestamp(1370982242,1),
lastOplog :Timestamp(1370982243,1),
lastSnapshot:Timestamp(1370981940,1),
machine : "backup1.10gen.com"
}
Keeping State – Current
Version
• More fields, Nested Documents. Still No Joins.
{
_id:ObjectId("5194ecde036446e958b9df9b"),
groupId:“CustomerGroup”,
replicaSet:”ReplSetName",
broken:false,
workingOn:{…},
head:{ts:Timestamp(1370982242,1),
hash:49238479326510
},
lastOplog:{ts:Timestamp(1370982243,1),
hash:93408342387492
}
numOplogs:NumberLong(9400),
oplogNamespace:“CustomerGroup.oplogs_ReplSetName”
lastSnapshot:Timestamp(1370981940,1),
nextSnapshot:Timestamp1371003540,1),
schedule:{
reference:13709812343,
rules{[{…},{…}]}
}
machine:"backup1.10gen.com"
}
Simple Value -> Nested
Document
Integer -> Long
Complex, Nested Document
Imitating a Secondary:
Capturing and storing the oplog
Capture Oplog
• Use replication oplog to capture activity
• Oplog is a Capped Collection – local.oplog.rs
– We can tail Capped Collections
• Strategy
– Tail the Oplog
– Read 10 MB of Data
– Compress and Send to 10gen
Store Oplog – First Version
• Single Capped Collection
• Pros
– Easy
• Cons
– Doesn’t scale!
– Customers will have an impact on each other
Store Oplog – Good Version
• DB per customer and Collection per replica set
• TTL Index for cleanup
• Pros
– Logical and Physical separation of customer data
– Can scale quickly and easily
– Configurable by end user
Storing the Snapshots
Storage – First Version
• Archive and Compress MongoDB data files
• Scatter archives across machines
– Pros
• Fast and Easy
– Cons
• No Redundancy, Hard to Scale, Wastes Space
Machine 1
Snapshot_1.tar.gz
Snapshot_4.tar.gz
Machine 2
Snapshot_2.tar.gz
Snapshot_5.tar.gz
Machine 3
Snapshot_3.tar.gz
Snapshot_6.tar.gz
Goal 1: De-Duplicated
Storage
• Observation
– Data change is low and localized
– Data is compressible
• Huge benefits in de-duplicating
Worst Case
0% de-dupe
No compression
Best Case
100% de-dupe
10x compression
Typical Case
90% de-dupe
3x compression
100G
B
100G
B
100G
B
100G
B
100G
B
100G
B
10GB 0GB 100G
B
100G
B
33GB 3GB
Goal 2: Redundancy and
Scalability
• Require HighAvailability & Redundancy
– MongoDB Replication!
• RequireAbility to Scale
– MongoDB Sharding!
Block Store
db_file.0
SHA-256 Hash = “de23425..”
Data = BinData[……]
SHA-256 Hash = “3af37..”
Data = BinData[……]
SHA-256 Hash = “e721ac..”
Data = BinData[……]
Block Store
• File reference
Block Store Internals
Files Collection
{
_id :
ObjectId("5194ece0036446e958b9dfa1"),
filename : ”db_file.0",
size : NumberLong(786432),
blocks : [
{
hash : "de2f256064….",
size : 96
},
{
hash : ”47a9834f23….",
size : 32121
},
….
}
Blocks Collection
{
_id :
"de2f256064a0af797747c2b9755dcb9f3df0de4f489eac7
31c23ae9ca9cc31",
bytes :
BinData(0,"H4sIAAAAAAAAAO3BAQEAAACAkP6v7gg
KAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAauuOl9cAAAEA"),
zippedSize : 96,
size : 65536
}
SHA-256 Hash
SHA-256
Hash
Putting the file back together
• For each file
– For each block
• Retrieve block
• Uncompress
Block Store Garbage
Collection
• 1st Attempt
– Reference counting
– Slow and non-parallelizable
• 2nd Attempt
– Mark and Sweep
– Parallelizable
– Requires more space
Q&A

More Related Content

What's hot (20)

PDF
Ceph Client librbd Performance Analysis and Learnings - Mahati Chamarthy
Ceph Community
 
PPTX
Day 2 General Session Presentations RedisConf
Redis Labs
 
PPTX
Running MongoDB 3.0 on AWS
MongoDB
 
PDF
Mongo db3.0 wired_tiger_storage_engine
Kenny Gorman
 
PPTX
Powering Microservices with Docker, Kubernetes, Kafka, and MongoDB
MongoDB
 
PDF
Taking Your Database Global with Kubernetes
Christopher Bradford
 
PDF
MongoDB WiredTiger Internals
Norberto Leite
 
PPTX
Webinar: Backups + Disaster Recovery
MongoDB
 
PDF
Engineering an Encrypted Storage Engine
MongoDB
 
PDF
Redis Day Keynote Salvatore Sanfillipo Redis Labs
Redis Labs
 
PDF
Mongo presentation conf
Shridhar Joshi
 
PDF
Caching methodology and strategies
Tiep Vu
 
PPTX
Managing 50K+ Redis Databases Over 4 Public Clouds ... with a Tiny Devops Team
Redis Labs
 
PDF
Monitoring and Scaling Redis at DataDog - Ilan Rabinovitch, DataDog
Redis Labs
 
PPTX
WiredTiger Overview
WiredTiger
 
PDF
MongoDB Evenings Boston - An Update on MongoDB's WiredTiger Storage Engine
MongoDB
 
PPTX
How Scylla Manager Handles Backups
ScyllaDB
 
PPTX
Gocd – Kubernetes/Nomad Continuous Deployment
Leandro Totino Pereira
 
POTX
Mobile 3: Launch Like a Boss!
MongoDB
 
PPTX
RedisConf17- Using Redis at scale @ Twitter
Redis Labs
 
Ceph Client librbd Performance Analysis and Learnings - Mahati Chamarthy
Ceph Community
 
Day 2 General Session Presentations RedisConf
Redis Labs
 
Running MongoDB 3.0 on AWS
MongoDB
 
Mongo db3.0 wired_tiger_storage_engine
Kenny Gorman
 
Powering Microservices with Docker, Kubernetes, Kafka, and MongoDB
MongoDB
 
Taking Your Database Global with Kubernetes
Christopher Bradford
 
MongoDB WiredTiger Internals
Norberto Leite
 
Webinar: Backups + Disaster Recovery
MongoDB
 
Engineering an Encrypted Storage Engine
MongoDB
 
Redis Day Keynote Salvatore Sanfillipo Redis Labs
Redis Labs
 
Mongo presentation conf
Shridhar Joshi
 
Caching methodology and strategies
Tiep Vu
 
Managing 50K+ Redis Databases Over 4 Public Clouds ... with a Tiny Devops Team
Redis Labs
 
Monitoring and Scaling Redis at DataDog - Ilan Rabinovitch, DataDog
Redis Labs
 
WiredTiger Overview
WiredTiger
 
MongoDB Evenings Boston - An Update on MongoDB's WiredTiger Storage Engine
MongoDB
 
How Scylla Manager Handles Backups
ScyllaDB
 
Gocd – Kubernetes/Nomad Continuous Deployment
Leandro Totino Pereira
 
Mobile 3: Launch Like a Boss!
MongoDB
 
RedisConf17- Using Redis at scale @ Twitter
Redis Labs
 

Viewers also liked (6)

PPTX
Real-Time Integration Between MongoDB and SQL Databases
MongoDB
 
PDF
Exploring the replication in MongoDB
Igor Donchovski
 
PDF
Building Real Time Systems on MongoDB Using the Oplog at Stripe
MongoDB
 
PDF
MongoDB Database Replication
Mehdi Valikhani
 
PDF
Building Real Time Systems on MongoDB Using the Oplog at Stripe
MongoDB
 
PDF
Building Real Time Systems on MongoDB Using the Oplog at Stripe
Stripe
 
Real-Time Integration Between MongoDB and SQL Databases
MongoDB
 
Exploring the replication in MongoDB
Igor Donchovski
 
Building Real Time Systems on MongoDB Using the Oplog at Stripe
MongoDB
 
MongoDB Database Replication
Mehdi Valikhani
 
Building Real Time Systems on MongoDB Using the Oplog at Stripe
MongoDB
 
Building Real Time Systems on MongoDB Using the Oplog at Stripe
Stripe
 
Ad

Similar to Walking the Walk: Developing the MongoDB Backup Service with MongoDB (20)

PPTX
Keeping MongoDB Data Safe
Tony Tam
 
PDF
Evolution of MongoDB Replicaset and Its Best Practices
Mydbops
 
PDF
MongoDB at MapMyFitness
MapMyFitness
 
PDF
MongoDB.local Austin 2018: Solving Your Backup Needs Using MongoDB Ops Manage...
MongoDB
 
PDF
MongoDB.local DC 2018: Solving Your Backup Needs Using MongoDB Ops Manager, C...
MongoDB
 
PDF
Solving Your Backup Needs Using MongoDB Ops Manager, Cloud Manager and Atlas
MongoDB
 
PPTX
Backup, Restore, and Disaster Recovery
MongoDB
 
PDF
Evolution Of MongoDB Replicaset
M Malai
 
PDF
MongoDB World 2019: Modern Data Backup and Recovery from On-premises to the P...
MongoDB
 
PPTX
Backup, Restore, and Disaster Recovery
MongoDB
 
KEY
MongoDB vs Mysql. A devops point of view
Pierre Baillet
 
PPTX
Automated testing with OffScale and MongoDB
Omer Gertel
 
PPTX
MongoDB.local Atlanta: Modern Data Backup and Recovery from On-Premises to th...
MongoDB
 
PDF
Solving your Backup Needs - Ben Cefalo mdbe18
MongoDB
 
PPTX
Replication and replica sets
Chris Westin
 
PDF
MongoDB at MapMyFitness from a DevOps Perspective
MongoDB
 
PDF
MongoDB World 2018: Solving Your Backup Needs Using MongoDB Ops Manager, Clou...
MongoDB
 
PDF
MongoDB: Advantages of an Open Source NoSQL Database
FITC
 
PPTX
MongoDB San Francisco 2013: Storing eBay's Media Metadata on MongoDB present...
MongoDB
 
PPTX
Storing eBay's Media Metadata on MongoDB, by Yuri Finkelstein, Architect, eBay
MongoDB
 
Keeping MongoDB Data Safe
Tony Tam
 
Evolution of MongoDB Replicaset and Its Best Practices
Mydbops
 
MongoDB at MapMyFitness
MapMyFitness
 
MongoDB.local Austin 2018: Solving Your Backup Needs Using MongoDB Ops Manage...
MongoDB
 
MongoDB.local DC 2018: Solving Your Backup Needs Using MongoDB Ops Manager, C...
MongoDB
 
Solving Your Backup Needs Using MongoDB Ops Manager, Cloud Manager and Atlas
MongoDB
 
Backup, Restore, and Disaster Recovery
MongoDB
 
Evolution Of MongoDB Replicaset
M Malai
 
MongoDB World 2019: Modern Data Backup and Recovery from On-premises to the P...
MongoDB
 
Backup, Restore, and Disaster Recovery
MongoDB
 
MongoDB vs Mysql. A devops point of view
Pierre Baillet
 
Automated testing with OffScale and MongoDB
Omer Gertel
 
MongoDB.local Atlanta: Modern Data Backup and Recovery from On-Premises to th...
MongoDB
 
Solving your Backup Needs - Ben Cefalo mdbe18
MongoDB
 
Replication and replica sets
Chris Westin
 
MongoDB at MapMyFitness from a DevOps Perspective
MongoDB
 
MongoDB World 2018: Solving Your Backup Needs Using MongoDB Ops Manager, Clou...
MongoDB
 
MongoDB: Advantages of an Open Source NoSQL Database
FITC
 
MongoDB San Francisco 2013: Storing eBay's Media Metadata on MongoDB present...
MongoDB
 
Storing eBay's Media Metadata on MongoDB, by Yuri Finkelstein, Architect, eBay
MongoDB
 
Ad

More from MongoDB (20)

PDF
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB
 
PDF
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB
 
PDF
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB
 
PDF
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB
 
PDF
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB
 
PDF
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB
 
PDF
MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB
 
PDF
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB
 
PDF
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB
 
PDF
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB
 
PDF
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB
 
PDF
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB
 
PDF
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB
 
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB
 
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB
 
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB
 
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB
 
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB
 
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB
 
MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB
 
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB
 
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB
 
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB
 
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB
 
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB
 
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB
 
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB
 
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB
 
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB
 
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB
 
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB
 
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB
 
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB
 

Recently uploaded (20)

PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 

Walking the Walk: Developing the MongoDB Backup Service with MongoDB

  • 1. Engineer, Cloud Team, 10gen Steve Briskin Walking the Walk: Developing the MongoDB Backup Service With MongoDB
  • 2. Agenda • Intro: The Project • How the backup service was built – Keeping State – Storage of Oplog Documents – De-duped Snapshot Storage • Q&A
  • 3. The Project • Started in December 2011 – 1 person • 3 Engineers + PM & Manager by June 2012 • Private Beta – September 2012 • Limited Release – April 2013 • 6 Engineers (and hiring) + PM & Manager – Now • Agile Principles
  • 4. Data Flow Reconstructed Replica Sets Sharded Cluster BRS Daemon Backu p Agent Replica Set 1 Customer Replica Set 4 Replica Set 3 Replica Set 2 Backup Ingestion 10GEN Backup Daemon(s) Main DB Block Store RS 1 RS 2 RS 3 RS 4 2. Initial Sync3. OpLog Data 1. Configuration 4. Save Sync/Oplog Data 5. Reconstruct Replica Set 6. Persist Snapshot 7. Retrieve Snapshot 8. SCP Data Files
  • 5. How We Built It (Iteratively)
  • 6. Keeping State – First Version • One document per replica set being backed up { _id : ObjectId("5194ecde036446e958b9df9b"), groupId : “Customer Group”, replicaSet : ”ReplSet Name", broken : false, workingOn : “Initial Sync”, numOplogs : NumberInt(100), head :Timestamp(1370982242,1), lastOplog :Timestamp(1370982243,1), lastSnapshot:Timestamp(1370981940,1), machine : "backup1.10gen.com" }
  • 7. Keeping State – Current Version • More fields, Nested Documents. Still No Joins. { _id:ObjectId("5194ecde036446e958b9df9b"), groupId:“CustomerGroup”, replicaSet:”ReplSetName", broken:false, workingOn:{…}, head:{ts:Timestamp(1370982242,1), hash:49238479326510 }, lastOplog:{ts:Timestamp(1370982243,1), hash:93408342387492 } numOplogs:NumberLong(9400), oplogNamespace:“CustomerGroup.oplogs_ReplSetName” lastSnapshot:Timestamp(1370981940,1), nextSnapshot:Timestamp1371003540,1), schedule:{ reference:13709812343, rules{[{…},{…}]} } machine:"backup1.10gen.com" } Simple Value -> Nested Document Integer -> Long Complex, Nested Document
  • 8. Imitating a Secondary: Capturing and storing the oplog
  • 9. Capture Oplog • Use replication oplog to capture activity • Oplog is a Capped Collection – local.oplog.rs – We can tail Capped Collections • Strategy – Tail the Oplog – Read 10 MB of Data – Compress and Send to 10gen
  • 10. Store Oplog – First Version • Single Capped Collection • Pros – Easy • Cons – Doesn’t scale! – Customers will have an impact on each other
  • 11. Store Oplog – Good Version • DB per customer and Collection per replica set • TTL Index for cleanup • Pros – Logical and Physical separation of customer data – Can scale quickly and easily – Configurable by end user
  • 13. Storage – First Version • Archive and Compress MongoDB data files • Scatter archives across machines – Pros • Fast and Easy – Cons • No Redundancy, Hard to Scale, Wastes Space Machine 1 Snapshot_1.tar.gz Snapshot_4.tar.gz Machine 2 Snapshot_2.tar.gz Snapshot_5.tar.gz Machine 3 Snapshot_3.tar.gz Snapshot_6.tar.gz
  • 14. Goal 1: De-Duplicated Storage • Observation – Data change is low and localized – Data is compressible • Huge benefits in de-duplicating Worst Case 0% de-dupe No compression Best Case 100% de-dupe 10x compression Typical Case 90% de-dupe 3x compression 100G B 100G B 100G B 100G B 100G B 100G B 10GB 0GB 100G B 100G B 33GB 3GB
  • 15. Goal 2: Redundancy and Scalability • Require HighAvailability & Redundancy – MongoDB Replication! • RequireAbility to Scale – MongoDB Sharding!
  • 16. Block Store db_file.0 SHA-256 Hash = “de23425..” Data = BinData[……] SHA-256 Hash = “3af37..” Data = BinData[……] SHA-256 Hash = “e721ac..” Data = BinData[……]
  • 17. Block Store • File reference
  • 18. Block Store Internals Files Collection { _id : ObjectId("5194ece0036446e958b9dfa1"), filename : ”db_file.0", size : NumberLong(786432), blocks : [ { hash : "de2f256064….", size : 96 }, { hash : ”47a9834f23….", size : 32121 }, …. } Blocks Collection { _id : "de2f256064a0af797747c2b9755dcb9f3df0de4f489eac7 31c23ae9ca9cc31", bytes : BinData(0,"H4sIAAAAAAAAAO3BAQEAAACAkP6v7gg KAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAauuOl9cAAAEA"), zippedSize : 96, size : 65536 } SHA-256 Hash SHA-256 Hash
  • 19. Putting the file back together • For each file – For each block • Retrieve block • Uncompress
  • 20. Block Store Garbage Collection • 1st Attempt – Reference counting – Slow and non-parallelizable • 2nd Attempt – Mark and Sweep – Parallelizable – Requires more space
  • 21. Q&A

Editor's Notes

  • #2: A presentation on we build the MongoDB Backup Service in house. Not a sales pitch.
  • #5: FixBackup Agent = Exernal program, similar to MMS Agent. Written in Go.Ingestion = RESTfulwebservices. Responsible for all agent communication (configuration and ingestion)Daemons = Actual processing
  • #7: “Evolving Schema with MongoDB”Complexity crept in – complex rules,graceful recovery, accurate representation of data, additional state. “More bells And whistles”
  • #8: Schema Talk – how the application will use data. Start simple and evolve.
  • #10: Explain what a capped collection is – circular bufferExplain what the oplog is
  • #11: 500GB -> 1TB oplog.Timeline– why this chosen, how long it lasted, why and when it stopped working (can’t shard, single point of contention, lose dynamic schema, customers intertwined)Start with somethingTTL indexes did not exist“”
  • #12: MongoDB 2.2 coincided with this stage of developmentAdded in 2.2. Time To Live index. DB-level locking, TTLand dynamic schemaAnd we can shard shardingTTL window – hard to manage at first, made easier later
  • #15: Worst case – no worse than tar.gz of files
  • #17: Be prepared to discusszfs and why it wasn’t chosen
  • #19: Risk: CorruptionBig Idea: De-duping -> save the stuff that changed
  • #21: Multiple slides with details – what went wrong, why. E.g. indexes we used, read vs. wright, disk io was the bottleneck