SlideShare a Scribd company logo
Thoughts on Deployment
   roger@10Gen.com
        @rogerb
Congratulations !

  Development done ?

Great ! Ready to Deploy :-)
some points to consider
Agenda
• A word on performance
• Sizing Your Hardware
   • memory   / cpu / disk io
• Software
   • os / filesystem
• Installing MongoDB / Upgrades
• EC2 Notes
• Security
• Backup
• Durability
• Upgrading
• Monitoring
• Scaling out
A Word on Performance
• Ensure your queries are being executed correctly
   • Enable profiling
   • db.setProfilingLevel(n)
       • n=1: slow operations, n=2: all operations
   • Viewing profile information
       • db.system.profile.find({info: /test.foo/})
   •http://www.mongodb.org/display/DOCS/Database+Profiler

• Query execution plan:
   •db.xx.find({..}).explain()
   •http://www.mongodb.org/display/DOCS/Optimization
• Make sure your Queries are properly indexed.
Sizing Hardware: Memory
• Working set should be as much in memory as possible, but
   • your whole data set doesn’t have to
•Memory Mapped files
   • Maps Files on Filesystem to Virtual Memory
      • Not Physical RAM
   • Page Faults - not in memory - from disk - expensive
• Indices
   • Part of the regular DB files
• Consider Warm Starting your Database
Sizing Hardware: CPU
• MongoDB uses multiple cores
   • For working-set queries, CPU usage is minimal
   • Generally, faster CPU are better

• Aggregation, Full Tablescans
   •Makes heavy use of CPU / Disk
   •Instead of counting / computing:
       • cache / precompute
• Map Reduce
   • Currently Single threaded
       •Can be run in parallel across shards.
   • This restriction may be eliminated, investigating options
Sizing Hardware: I/O
• Disk I/O determines performance of non-working set queries
• More Disks = Better
    • Improved throughput, Reduced Seek times
    • Raid 0 - Striping: improved write performance
    • Raid 1 - Mirroring: survive single disk failure
    • Raid 10 - both
• Consider Flash ?
    • Expensive, getting cheaper
    • Significantly reduced seek time, increased IO throughput
• Network
   • It’s easy to saturate your network
   • (Average doc size * number of document writes, reads) / sec
MongoStat

• Tool that comes with MongoDB
• Shows
   • counters for I/O, time spent in write lock, ...
IOStat
iostat
‐x
2
iostat
‐w
1
            disk0                 disk1                 disk2         cpu         load average
 KB/t      tps MB/s            KB/t tps   MB/s          KB/t tps    MB/s    us   sy id   1m    5m 15m
12.83        3 0.04            2.01   0   0.00         12.26   2    0.02    11    5 83 0.35 0.26 0.25
11.12       75 0.81            0.00   0   0.00          0.00   0    0.00    60   24 16 0.68 0.34 0.28
 4.00        3 0.01            0.00   0   0.00          0.00   0    0.00    60   23 17 0.68 0.34 0.28


avg-cpu:    %user     %nice %system %iowait   %steal   %idle
             0.00      0.00    7.96   29.85     0.50   61.69

Device:             rrqm/s    wrqm/s    r/s      w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await   svctm   %util
sda1                  0.00      0.00   0.00     0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00
sda2                  0.50   4761.19   6.47   837.31    75.62 43681.59    51.86    38.38   42.33    0.46   38.41


     Monitor
disk
transfers
:

       >
200
‐
300
Mb/s
on
XL
EC2,

but
your
mileage
may
vary
    CPU
usage
      >
30
%
during
normal
operations

OS
• For production: Use a 64bit OS
   • 32bit has 2G limit
   • Clients can be 32 bit
• MongoDB supports (little endian only):
   • Linux, FreeBSD, OS X
   • Windows
   • Solaris (joyent)
Filesystem
• All data, namespace files stored in data directory
   • Possible to create links
   • Better to aggregrate IO across disks
•File Allocation
Filesystem
• Logfiles:
    • --logpath <file>
    • Rotate:
        • db.runCommand(“logRotate”)
        • kill -SIGUSR1 <mongod pid>
    •Does not work for ./mongod > <file>
• MongoDB is filesystem-neutral:
    • ext3, ext4 and XFS are most used
    • ext4 / XFS preferred (posix_allocate())
        • improved performance for file allocation
    • Support for NTFS for windows
MongoDB Version Policy


• Production:   run even numbers
   • 1.4.x, 1.6.x, 1.8.x
•Development
   •1.5.x, 1.7.x
• Critical bugs are back ported to even versions
Installing MongoDB
• Installing from Source
    • Requires Scons, C++ compiler, Boost libraries, SpiderMonkey,
    PCRE

• Installing from Binaries (easiest)
    • curl -O http://downloads.mongodb.org/_os_/_version_

• Upgrading database
    • Install new version of MongoDB
    • Stop previous version
    • Start new version

•In case of database file changes,
    •mongodump / mongorestore
EC2 Notes
• Default storage instance is EXT3
   • For best performance, reformat to EXT4 / XFS
   • Use recent version of EXT4
• Use Striping (using MDADM or LVM) aggregates I/O
   •This is a good thing
• EC2 can experience spikes in latency
   • 400-600mS
   •This is a bad thing
More EC2 Notes


• EBS snapshots can be used for backups
   • EBS can disappear
• S3 can be used for longer term backups
• Use Amazon availability zones
   • High Availability
   • Disaster Recovery
Security
• Mongo supports basic security
• We encourage to run mongoDB in a safe environment
• Authenticates a User on a per Database basis
• Start database with --auth
• Admin user stored in the admin database
    use admin
    db.addUser("administrator", "password")
    db.auth(“administrator”, “password”)

• Regular users stored in other databases
    use personnel
    db.addUser("joe", "password")
    db.addUser(“fred”, “password”, true)
Backup
• Typically backups are driven from a slave
• Eliminates impact to client / application traffic to master
Backup



•Two main Strategies
   • mongodump / mongorestore
   • Filesystem backup / snapshot
• Filelock + fsync
mongodump

• binary, compact object dump
• each consistent object is written
• not necessarily consistent from start to finish
   • unless you lock database:
   • db.runCommand({fsync:1,lock:1})
• mongorestore to restore database
   • database does not have to be up to restore
Filesystem Backup

• MUST
   • fsync - flushes buffers to disk
   • lock - blocks writes
      db.runCommand({fsync:1,lock:1})

• Use file-system / LVM / storage snapshot
• unlock
   db.$cmd.sys.unlock.findOne();
Database Maintenance

• When doing a lot of updates or deletes
   • occasional database compaction might be needed
       • indices and datafiles
   • db.repair()
• With replica sets
   • Rolling: start up node with --repair param
Durability


 What failures do you need to recover from?
• Loss of a single database node?
• Loss of a group of nodes?
Durability - Master only

• Write acknowledged
when in memory on
master only
Durability - Master + Slaves
• W=2
• Write acknowledged
when in memory on
master + slave
• Will survive failure of a
single node
Durability - Master + Slaves +
                 fsync
• W=n
• Write acknowledged
when in memory on
master + slaves
• Pick a “majority” of
nodes
• fsync in batches (since
it blocking)
Slave delay
• Protection against app
faults
• Protection against
administration mistakes
• Slave runs X amount of
time behind
Scale out
read

       shard1   shard2   shard3

                                    mongos
/

       rep_a1   rep_a2   rep_a3   config
server


                                    mongos
/

       rep_b1   rep_b2   rep_b3   config
server


                                    mongos
/

       rep_c2   rep_c2   rep_c3   config
server




                                                 write
Monitoring


   • We like Munin ..
   • ... but other frameworks
       work as well


   • Primary function:
   • Measure stats over time
   • Tells you what is going on with
      your system
Thank You :-)
  @rogerb
download at mongodb.org

        conferences,
appearances,
and
meetups
                  http://www.10gen.com/events




   Facebook









|








Twitter








|








LinkedIn
http://bit.ly/mongoN
        @mongodb          http://linkd.in/joinmongo

More Related Content

What's hot (20)

ODP
Optimizing Linux Servers
Davor Guttierrez
 
PDF
SSD Deployment Strategies for MySQL
Yoshinori Matsunobu
 
PPTX
Tuning linux for mongo db
Soumya Bhattacharyya
 
PDF
Performance comparison of Distributed File Systems on 1Gbit networks
Marian Marinov
 
PDF
MySQL on ZFS
Gordan Bobic
 
PDF
LinuxCon_2013_NA_Eckermann_Filesystems_btrfs.pdf
degarden
 
PDF
PostgreSQL Extensions: A deeper look
Jignesh Shah
 
PDF
92 grand prix_2013
PostgreSQL Experts, Inc.
 
PDF
PostgreSQL High Availability in a Containerized World
Jignesh Shah
 
PDF
MySQL for Large Scale Social Games
Yoshinori Matsunobu
 
PPT
Backup, restore and repair database in mongo db linux file
Prem Regmi
 
PPTX
Live memory forensics
Shekh Md Mehedi Hasan
 
PDF
Tuning DB2 in a Solaris Environment
Jignesh Shah
 
PDF
PostgreSQL on EXT4, XFS, BTRFS and ZFS
Tomas Vondra
 
PPTX
MongoDB World 2015 - A Technical Introduction to WiredTiger
WiredTiger
 
PDF
Page reclaim
siburu
 
PDF
Introduction to PostgreSQL for System Administrators
Jignesh Shah
 
PDF
Linux IO internals for database administrators (SCaLE 2017 and PGDay Nordic 2...
PostgreSQL-Consulting
 
PDF
Introduction of mesos persistent storage
Zhou Weitao
 
PPTX
Backing Up Data with MMS
MongoDB
 
Optimizing Linux Servers
Davor Guttierrez
 
SSD Deployment Strategies for MySQL
Yoshinori Matsunobu
 
Tuning linux for mongo db
Soumya Bhattacharyya
 
Performance comparison of Distributed File Systems on 1Gbit networks
Marian Marinov
 
MySQL on ZFS
Gordan Bobic
 
LinuxCon_2013_NA_Eckermann_Filesystems_btrfs.pdf
degarden
 
PostgreSQL Extensions: A deeper look
Jignesh Shah
 
92 grand prix_2013
PostgreSQL Experts, Inc.
 
PostgreSQL High Availability in a Containerized World
Jignesh Shah
 
MySQL for Large Scale Social Games
Yoshinori Matsunobu
 
Backup, restore and repair database in mongo db linux file
Prem Regmi
 
Live memory forensics
Shekh Md Mehedi Hasan
 
Tuning DB2 in a Solaris Environment
Jignesh Shah
 
PostgreSQL on EXT4, XFS, BTRFS and ZFS
Tomas Vondra
 
MongoDB World 2015 - A Technical Introduction to WiredTiger
WiredTiger
 
Page reclaim
siburu
 
Introduction to PostgreSQL for System Administrators
Jignesh Shah
 
Linux IO internals for database administrators (SCaLE 2017 and PGDay Nordic 2...
PostgreSQL-Consulting
 
Introduction of mesos persistent storage
Zhou Weitao
 
Backing Up Data with MMS
MongoDB
 

Similar to Deployment Strategy (20)

PDF
MongoDB: Advantages of an Open Source NoSQL Database
FITC
 
PDF
Mongo nyc nyt + mongodb
Deep Kapadia
 
PDF
MongoDB at MapMyFitness
MapMyFitness
 
KEY
MongoDB vs Mysql. A devops point of view
Pierre Baillet
 
KEY
Discover MongoDB - Israel
Michael Fiedler
 
PDF
MongoDB at MapMyFitness from a DevOps Perspective
MongoDB
 
PDF
MongoDB and server performance
Alon Horev
 
PPTX
Agility and Scalability with MongoDB
MongoDB
 
PPTX
Ops Jumpstart: MongoDB Administration 101
MongoDB
 
PPTX
Performance Tuning Cheat Sheet for MongoDB
Severalnines
 
PDF
MongoDB Tokyo - Monitoring and Queueing
Boxed Ice
 
KEY
MongoDB Administration 20110922
radiocats
 
PPTX
Back to Basics Webinar 6: Production Deployment
MongoDB
 
PPTX
Deployment Preparedness
MongoDB
 
PPTX
Mongo DB
Karan Kukreja
 
PPTX
Conceptos básicos. Seminario web 6: Despliegue de producción
MongoDB
 
KEY
Scaling with MongoDB
MongoDB
 
PDF
Silicon Valley Code Camp 2015 - Advanced MongoDB - The Sequel
Daniel Coupal
 
PPTX
High Performance, Scalable MongoDB in a Bare Metal Cloud
MongoDB
 
KEY
2011 mongo sf-scaling
MongoDB
 
MongoDB: Advantages of an Open Source NoSQL Database
FITC
 
Mongo nyc nyt + mongodb
Deep Kapadia
 
MongoDB at MapMyFitness
MapMyFitness
 
MongoDB vs Mysql. A devops point of view
Pierre Baillet
 
Discover MongoDB - Israel
Michael Fiedler
 
MongoDB at MapMyFitness from a DevOps Perspective
MongoDB
 
MongoDB and server performance
Alon Horev
 
Agility and Scalability with MongoDB
MongoDB
 
Ops Jumpstart: MongoDB Administration 101
MongoDB
 
Performance Tuning Cheat Sheet for MongoDB
Severalnines
 
MongoDB Tokyo - Monitoring and Queueing
Boxed Ice
 
MongoDB Administration 20110922
radiocats
 
Back to Basics Webinar 6: Production Deployment
MongoDB
 
Deployment Preparedness
MongoDB
 
Mongo DB
Karan Kukreja
 
Conceptos básicos. Seminario web 6: Despliegue de producción
MongoDB
 
Scaling with MongoDB
MongoDB
 
Silicon Valley Code Camp 2015 - Advanced MongoDB - The Sequel
Daniel Coupal
 
High Performance, Scalable MongoDB in a Bare Metal Cloud
MongoDB
 
2011 mongo sf-scaling
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
 
Ad

Recently uploaded (20)

PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PPTX
Simple and concise overview about Quantum computing..pptx
mughal641
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PDF
Per Axbom: The spectacular lies of maps
Nexer Digital
 
PDF
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PDF
TrustArc Webinar - Navigating Data Privacy in LATAM: Laws, Trends, and Compli...
TrustArc
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PDF
Market Insight : ETH Dominance Returns
CIFDAQ
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PPTX
Agentic AI in Healthcare Driving the Next Wave of Digital Transformation
danielle hunter
 
PDF
Generative AI vs Predictive AI-The Ultimate Comparison Guide
Lily Clark
 
PDF
Build with AI and GDG Cloud Bydgoszcz- ADK .pdf
jaroslawgajewski1
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PPTX
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PDF
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
Simple and concise overview about Quantum computing..pptx
mughal641
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
Per Axbom: The spectacular lies of maps
Nexer Digital
 
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
TrustArc Webinar - Navigating Data Privacy in LATAM: Laws, Trends, and Compli...
TrustArc
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
Market Insight : ETH Dominance Returns
CIFDAQ
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Agentic AI in Healthcare Driving the Next Wave of Digital Transformation
danielle hunter
 
Generative AI vs Predictive AI-The Ultimate Comparison Guide
Lily Clark
 
Build with AI and GDG Cloud Bydgoszcz- ADK .pdf
jaroslawgajewski1
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 

Deployment Strategy

  • 2. Congratulations ! Development done ? Great ! Ready to Deploy :-)
  • 3. some points to consider
  • 4. Agenda • A word on performance • Sizing Your Hardware • memory / cpu / disk io • Software • os / filesystem • Installing MongoDB / Upgrades • EC2 Notes • Security • Backup • Durability • Upgrading • Monitoring • Scaling out
  • 5. A Word on Performance • Ensure your queries are being executed correctly • Enable profiling • db.setProfilingLevel(n) • n=1: slow operations, n=2: all operations • Viewing profile information • db.system.profile.find({info: /test.foo/}) •http://www.mongodb.org/display/DOCS/Database+Profiler • Query execution plan: •db.xx.find({..}).explain() •http://www.mongodb.org/display/DOCS/Optimization • Make sure your Queries are properly indexed.
  • 6. Sizing Hardware: Memory • Working set should be as much in memory as possible, but • your whole data set doesn’t have to •Memory Mapped files • Maps Files on Filesystem to Virtual Memory • Not Physical RAM • Page Faults - not in memory - from disk - expensive • Indices • Part of the regular DB files • Consider Warm Starting your Database
  • 7. Sizing Hardware: CPU • MongoDB uses multiple cores • For working-set queries, CPU usage is minimal • Generally, faster CPU are better • Aggregation, Full Tablescans •Makes heavy use of CPU / Disk •Instead of counting / computing: • cache / precompute • Map Reduce • Currently Single threaded •Can be run in parallel across shards. • This restriction may be eliminated, investigating options
  • 8. Sizing Hardware: I/O • Disk I/O determines performance of non-working set queries • More Disks = Better • Improved throughput, Reduced Seek times • Raid 0 - Striping: improved write performance • Raid 1 - Mirroring: survive single disk failure • Raid 10 - both • Consider Flash ? • Expensive, getting cheaper • Significantly reduced seek time, increased IO throughput • Network • It’s easy to saturate your network • (Average doc size * number of document writes, reads) / sec
  • 9. MongoStat • Tool that comes with MongoDB • Shows • counters for I/O, time spent in write lock, ...
  • 10. IOStat iostat
‐x
2 iostat
‐w
1 disk0 disk1 disk2 cpu load average KB/t tps MB/s KB/t tps MB/s KB/t tps MB/s us sy id 1m 5m 15m 12.83 3 0.04 2.01 0 0.00 12.26 2 0.02 11 5 83 0.35 0.26 0.25 11.12 75 0.81 0.00 0 0.00 0.00 0 0.00 60 24 16 0.68 0.34 0.28 4.00 3 0.01 0.00 0 0.00 0.00 0 0.00 60 23 17 0.68 0.34 0.28 avg-cpu: %user %nice %system %iowait %steal %idle 0.00 0.00 7.96 29.85 0.50 61.69 Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util sda1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sda2 0.50 4761.19 6.47 837.31 75.62 43681.59 51.86 38.38 42.33 0.46 38.41 Monitor
disk
transfers
:
 >
200
‐
300
Mb/s
on
XL
EC2,

but
your
mileage
may
vary CPU
usage >
30
%
during
normal
operations

  • 11. OS • For production: Use a 64bit OS • 32bit has 2G limit • Clients can be 32 bit • MongoDB supports (little endian only): • Linux, FreeBSD, OS X • Windows • Solaris (joyent)
  • 12. Filesystem • All data, namespace files stored in data directory • Possible to create links • Better to aggregrate IO across disks •File Allocation
  • 13. Filesystem • Logfiles: • --logpath <file> • Rotate: • db.runCommand(“logRotate”) • kill -SIGUSR1 <mongod pid> •Does not work for ./mongod > <file> • MongoDB is filesystem-neutral: • ext3, ext4 and XFS are most used • ext4 / XFS preferred (posix_allocate()) • improved performance for file allocation • Support for NTFS for windows
  • 14. MongoDB Version Policy • Production: run even numbers • 1.4.x, 1.6.x, 1.8.x •Development •1.5.x, 1.7.x • Critical bugs are back ported to even versions
  • 15. Installing MongoDB • Installing from Source • Requires Scons, C++ compiler, Boost libraries, SpiderMonkey, PCRE • Installing from Binaries (easiest) • curl -O http://downloads.mongodb.org/_os_/_version_ • Upgrading database • Install new version of MongoDB • Stop previous version • Start new version •In case of database file changes, •mongodump / mongorestore
  • 16. EC2 Notes • Default storage instance is EXT3 • For best performance, reformat to EXT4 / XFS • Use recent version of EXT4 • Use Striping (using MDADM or LVM) aggregates I/O •This is a good thing • EC2 can experience spikes in latency • 400-600mS •This is a bad thing
  • 17. More EC2 Notes • EBS snapshots can be used for backups • EBS can disappear • S3 can be used for longer term backups • Use Amazon availability zones • High Availability • Disaster Recovery
  • 18. Security • Mongo supports basic security • We encourage to run mongoDB in a safe environment • Authenticates a User on a per Database basis • Start database with --auth • Admin user stored in the admin database use admin db.addUser("administrator", "password") db.auth(“administrator”, “password”) • Regular users stored in other databases use personnel db.addUser("joe", "password") db.addUser(“fred”, “password”, true)
  • 19. Backup • Typically backups are driven from a slave • Eliminates impact to client / application traffic to master
  • 20. Backup •Two main Strategies • mongodump / mongorestore • Filesystem backup / snapshot • Filelock + fsync
  • 21. mongodump • binary, compact object dump • each consistent object is written • not necessarily consistent from start to finish • unless you lock database: • db.runCommand({fsync:1,lock:1}) • mongorestore to restore database • database does not have to be up to restore
  • 22. Filesystem Backup • MUST • fsync - flushes buffers to disk • lock - blocks writes db.runCommand({fsync:1,lock:1}) • Use file-system / LVM / storage snapshot • unlock db.$cmd.sys.unlock.findOne();
  • 23. Database Maintenance • When doing a lot of updates or deletes • occasional database compaction might be needed • indices and datafiles • db.repair() • With replica sets • Rolling: start up node with --repair param
  • 24. Durability What failures do you need to recover from? • Loss of a single database node? • Loss of a group of nodes?
  • 25. Durability - Master only • Write acknowledged when in memory on master only
  • 26. Durability - Master + Slaves • W=2 • Write acknowledged when in memory on master + slave • Will survive failure of a single node
  • 27. Durability - Master + Slaves + fsync • W=n • Write acknowledged when in memory on master + slaves • Pick a “majority” of nodes • fsync in batches (since it blocking)
  • 28. Slave delay • Protection against app faults • Protection against administration mistakes • Slave runs X amount of time behind
  • 29. Scale out read shard1 shard2 shard3 mongos
/
 rep_a1 rep_a2 rep_a3 config
server mongos
/
 rep_b1 rep_b2 rep_b3 config
server mongos
/
 rep_c2 rep_c2 rep_c3 config
server write
  • 30. Monitoring • We like Munin .. • ... but other frameworks work as well • Primary function: • Measure stats over time • Tells you what is going on with your system
  • 31. Thank You :-) @rogerb
  • 32. download at mongodb.org conferences,
appearances,
and
meetups http://www.10gen.com/events Facebook









|








Twitter








|








LinkedIn http://bit.ly/mongoN
 @mongodb http://linkd.in/joinmongo