keeping the lights on with mongodb
DESCRIPTION
A presentation by Tony Tam at the MongoSV conference in Silicon Valley, hosted by MongoDB creator 10gen.TRANSCRIPT
![Page 1: Keeping the Lights On with MongoDB](https://reader036.vdocuments.us/reader036/viewer/2022062418/554f90acb4c905d25b8b51b9/html5/thumbnails/1.jpg)
MONGO SVKeeping the lights on with MongoDB
Tony Tam
12/3/2010
![Page 2: Keeping the Lights On with MongoDB](https://reader036.vdocuments.us/reader036/viewer/2022062418/554f90acb4c905d25b8b51b9/html5/thumbnails/2.jpg)
PRESENTATION OVERVIEW
Data >>> codeTreat it appropriately
Manage and maintain MongoMongo is young (and robust!)
Performance and FeaturesThe right hooks exist
![Page 3: Keeping the Lights On with MongoDB](https://reader036.vdocuments.us/reader036/viewer/2022062418/554f90acb4c905d25b8b51b9/html5/thumbnails/3.jpg)
WHO IS WORDNIK
Wordnik is:The world’s largest English Language
reference ~10M words!
Mapping every word, based on real data
(free ) API to add word information, everywhere
![Page 4: Keeping the Lights On with MongoDB](https://reader036.vdocuments.us/reader036/viewer/2022062418/554f90acb4c905d25b8b51b9/html5/thumbnails/4.jpg)
WORDNIK’S MONGODB DEPLOYMENT
Over 12 Months with MongoCorpus/UGC/Structured Data/StatisticsMaster/Slave~3TB data~12B recordsWe love Mongo’s performanceRead more:
http://blog.wordnik.com/12-months-with-mongodb
![Page 5: Keeping the Lights On with MongoDB](https://reader036.vdocuments.us/reader036/viewer/2022062418/554f90acb4c905d25b8b51b9/html5/thumbnails/5.jpg)
ENGINEERING + IT OPS
First, Guiding PrinciplesKnow your dataDon’t rely on IT magic
Equal Importance in WebApps / SaaSHold hands and be friendsIf you can’t manage it, don’t deploy it
![Page 6: Keeping the Lights On with MongoDB](https://reader036.vdocuments.us/reader036/viewer/2022062418/554f90acb4c905d25b8b51b9/html5/thumbnails/6.jpg)
ADMINS: BE PREPARED
ok, this sucks.
![Page 7: Keeping the Lights On with MongoDB](https://reader036.vdocuments.us/reader036/viewer/2022062418/554f90acb4c905d25b8b51b9/html5/thumbnails/7.jpg)
HOW?
Replicate!Is that enough?Well, not if your company is on the line
SnapshotEvery minute???
Export oftenReally???
![Page 8: Keeping the Lights On with MongoDB](https://reader036.vdocuments.us/reader036/viewer/2022062418/554f90acb4c905d25b8b51b9/html5/thumbnails/8.jpg)
THEN WHAT?
Yes, Mongo can do IncrementalUse the mongo slave mechanism
It’s exposedIt’s supportedIt’s very easyIt’s extremely fast
How?Snapshot your dataStream write ops to diskRepeat
![Page 9: Keeping the Lights On with MongoDB](https://reader036.vdocuments.us/reader036/viewer/2022062418/554f90acb4c905d25b8b51b9/html5/thumbnails/9.jpg)
BETTER THAN FREE
Take our tools-They work!!!SnapshotUtil
Selectively snapshot in BSON Index info too!
IncrementalBackupUtilTail the oplog, stream to disk
Only the collections you want! Compress & rotate
RestoreUtilRecover your snapshots
Apply indexes yourself
ReplayUtilApply your Incremental backups
![Page 10: Keeping the Lights On with MongoDB](https://reader036.vdocuments.us/reader036/viewer/2022062418/554f90acb4c905d25b8b51b9/html5/thumbnails/10.jpg)
WHAT IF SCENARIOS
One collection gets corrupt?Restore itApply all operations to it
“My top developer dropped a collection!”Restore just that oneApply operations to it until that POT
“We got hacked!”Restore it allApply operations until that POT
![Page 11: Keeping the Lights On with MongoDB](https://reader036.vdocuments.us/reader036/viewer/2022062418/554f90acb4c905d25b8b51b9/html5/thumbnails/11.jpg)
WHAT ELSE IS POSSIBLE?
ReplicationWhy not use built-in?
Control, of courseSame logic as Incremental + Replay
Add some filters and it gets interesting
![Page 12: Keeping the Lights On with MongoDB](https://reader036.vdocuments.us/reader036/viewer/2022062418/554f90acb4c905d25b8b51b9/html5/thumbnails/12.jpg)
HOT DATACENTER
Create incremental backupsCompressPush to DC in batchApply to master
SCP
Primary Datacenter
Master
Incremental Backup
Files
Hot Datacenter
Master
Replay Util
![Page 13: Keeping the Lights On with MongoDB](https://reader036.vdocuments.us/reader036/viewer/2022062418/554f90acb4c905d25b8b51b9/html5/thumbnails/13.jpg)
DEV ENVIRONMENT
Developers need production-ish dataAnonymize while replicating to dev
server
![Page 14: Keeping the Lights On with MongoDB](https://reader036.vdocuments.us/reader036/viewer/2022062418/554f90acb4c905d25b8b51b9/html5/thumbnails/14.jpg)
MULTIPLE UPSTREAM MASTERS
Aggregate to single collectionTarget can be a master!
Master C
Master A
db.page_views
Master B
db.page_views
![Page 15: Keeping the Lights On with MongoDB](https://reader036.vdocuments.us/reader036/viewer/2022062418/554f90acb4c905d25b8b51b9/html5/thumbnails/15.jpg)
UNBLOCK MAPREDUCE
Map Reduce can lock up your serverReplicate source data to another mongodReplicate results back to master
MasterMR
Server
db.source_data
db.summary_data
![Page 16: Keeping the Lights On with MongoDB](https://reader036.vdocuments.us/reader036/viewer/2022062418/554f90acb4c905d25b8b51b9/html5/thumbnails/16.jpg)
MESH MODE
Write to Multiple MastersFilter by “Server Identifier”
Master 1 Master 2
db.documentsdocuments.src != 1
> db.documents.find().limit(2){"_id":99887,"src":2,"title":"favorite.png","fsid":33774}{"_id":128773,"src":1,"title":"select.png","fsid":837743}
db.documentsdocuments.src != 2
![Page 17: Keeping the Lights On with MongoDB](https://reader036.vdocuments.us/reader036/viewer/2022062418/554f90acb4c905d25b8b51b9/html5/thumbnails/17.jpg)
WHAT’S NEXT
Multi-Master in Wordnik ProductionMultiple Datacenter PresenceMore data => more challenges
![Page 18: Keeping the Lights On with MongoDB](https://reader036.vdocuments.us/reader036/viewer/2022062418/554f90acb4c905d25b8b51b9/html5/thumbnails/18.jpg)
TRY IT OUT
http://blog.wordnik.com/mongoutils
Questions?