SlideShare una empresa de Scribd logo
1 de 30
Descargar para leer sin conexión
Deployment
Thoughts on Deployment


   roger@10Gen.com
        @rogerb
Congratulations !

  Development done ?

Toll ! Ready to Deploy :-)
some points to consider
Agenda
• Sizing Your Hardware
   • memory   / cpu / disk io
• Software
   • os / filesystem
• Installing MongoDB
• EC2 Notes
• Security
• Backup
• Durability
• Upgrading
• Monitoring
• Scaling out
Sizing Hardware: Memory
• Memory Mapped files
   • Maps DB on Filesystem to Memory
   • Minor Page Faults - in memory - cheap
   • Major Page Faults - not in memory - from disk -
   expensive

• Indices
   • Part of the regular DB files
   • Can be completely in memory ..
   • Or partially
• Working set should be as much in memory as possible, but
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
       •Parallel in sharded environments.
   • 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
• Flash
    •Expensive, getting cheaper
    •Significantly reduced seek time, increased IO throughput
• Network
   •It’s easy to saturate your network
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
   • 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


• MongoDB is filesystem-neutral:
   • ext3, ext4 and XFS are most used
   • ext4 / XFS preferred (posix_fileallocate())
      • 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, ...

• 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
EC2 Notes

• Default storage instance is EXT3
   • For best performance, reformat to EXT4 / XFS

• 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
   • Filelock + fsync
mongodump


• binary, compact object dump
• each consistent object is written
• not necessarily consistent from start to finish
• 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();
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
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

Más contenido relacionado

La actualidad más candente

Page reclaim
Page reclaimPage reclaim
Page reclaimsiburu
 
What every data programmer needs to know about disks
What every data programmer needs to know about disksWhat every data programmer needs to know about disks
What every data programmer needs to know about disksiammutex
 
SSD Deployment Strategies for MySQL
SSD Deployment Strategies for MySQLSSD Deployment Strategies for MySQL
SSD Deployment Strategies for MySQLYoshinori Matsunobu
 
Gc and-pagescan-attacks-by-linux
Gc and-pagescan-attacks-by-linuxGc and-pagescan-attacks-by-linux
Gc and-pagescan-attacks-by-linuxCuong Tran
 
Strategies for Backing Up MongoDB
Strategies for Backing Up MongoDBStrategies for Backing Up MongoDB
Strategies for Backing Up MongoDBMongoDB
 
Redis persistence in practice
Redis persistence in practiceRedis persistence in practice
Redis persistence in practiceEugene Fidelin
 
MySQL for Large Scale Social Games
MySQL for Large Scale Social GamesMySQL for Large Scale Social Games
MySQL for Large Scale Social GamesYoshinori Matsunobu
 
Hdlogger project 2014.Aug
Hdlogger project 2014.AugHdlogger project 2014.Aug
Hdlogger project 2014.Aug捷恩 蔡
 
Comparison of foss distributed storage
Comparison of foss distributed storageComparison of foss distributed storage
Comparison of foss distributed storageMarian Marinov
 
Exadata and OLTP
Exadata and OLTPExadata and OLTP
Exadata and OLTPEnkitec
 
Backup, restore and repair database in mongo db linux file
Backup, restore and repair database in mongo db linux fileBackup, restore and repair database in mongo db linux file
Backup, restore and repair database in mongo db linux filePrem Regmi
 
LizardFS-WhitePaper-Eng-v3.9.2-web
LizardFS-WhitePaper-Eng-v3.9.2-webLizardFS-WhitePaper-Eng-v3.9.2-web
LizardFS-WhitePaper-Eng-v3.9.2-webSzymon Haly
 
Perfect Linux Desktop - OpenSuSE 12.2
Perfect Linux Desktop - OpenSuSE 12.2Perfect Linux Desktop - OpenSuSE 12.2
Perfect Linux Desktop - OpenSuSE 12.2Davor Guttierrez
 
Setting up mongo replica set
Setting up mongo replica setSetting up mongo replica set
Setting up mongo replica setSudheer Kondla
 
Control your service resources with systemd
 Control your service resources with systemd  Control your service resources with systemd
Control your service resources with systemd Marian Marinov
 
TritonSort: A Balanced Large-Scale Sorting System (NSDI 2011)
TritonSort: A Balanced Large-Scale Sorting System (NSDI 2011)TritonSort: A Balanced Large-Scale Sorting System (NSDI 2011)
TritonSort: A Balanced Large-Scale Sorting System (NSDI 2011)Alex Rasmussen
 
Performance comparison of Distributed File Systems on 1Gbit networks
Performance comparison of Distributed File Systems on 1Gbit networksPerformance comparison of Distributed File Systems on 1Gbit networks
Performance comparison of Distributed File Systems on 1Gbit networksMarian Marinov
 

La actualidad más candente (20)

Page reclaim
Page reclaimPage reclaim
Page reclaim
 
What every data programmer needs to know about disks
What every data programmer needs to know about disksWhat every data programmer needs to know about disks
What every data programmer needs to know about disks
 
SSD Deployment Strategies for MySQL
SSD Deployment Strategies for MySQLSSD Deployment Strategies for MySQL
SSD Deployment Strategies for MySQL
 
Gc and-pagescan-attacks-by-linux
Gc and-pagescan-attacks-by-linuxGc and-pagescan-attacks-by-linux
Gc and-pagescan-attacks-by-linux
 
Strategies for Backing Up MongoDB
Strategies for Backing Up MongoDBStrategies for Backing Up MongoDB
Strategies for Backing Up MongoDB
 
Redis persistence in practice
Redis persistence in practiceRedis persistence in practice
Redis persistence in practice
 
Mongodb backup
Mongodb backupMongodb backup
Mongodb backup
 
MySQL for Large Scale Social Games
MySQL for Large Scale Social GamesMySQL for Large Scale Social Games
MySQL for Large Scale Social Games
 
Hdlogger project 2014.Aug
Hdlogger project 2014.AugHdlogger project 2014.Aug
Hdlogger project 2014.Aug
 
Comparison of foss distributed storage
Comparison of foss distributed storageComparison of foss distributed storage
Comparison of foss distributed storage
 
Exadata and OLTP
Exadata and OLTPExadata and OLTP
Exadata and OLTP
 
ceph-barcelona-v-1.2
ceph-barcelona-v-1.2ceph-barcelona-v-1.2
ceph-barcelona-v-1.2
 
Backup, restore and repair database in mongo db linux file
Backup, restore and repair database in mongo db linux fileBackup, restore and repair database in mongo db linux file
Backup, restore and repair database in mongo db linux file
 
LizardFS-WhitePaper-Eng-v3.9.2-web
LizardFS-WhitePaper-Eng-v3.9.2-webLizardFS-WhitePaper-Eng-v3.9.2-web
LizardFS-WhitePaper-Eng-v3.9.2-web
 
Perfect Linux Desktop - OpenSuSE 12.2
Perfect Linux Desktop - OpenSuSE 12.2Perfect Linux Desktop - OpenSuSE 12.2
Perfect Linux Desktop - OpenSuSE 12.2
 
Setting up mongo replica set
Setting up mongo replica setSetting up mongo replica set
Setting up mongo replica set
 
Control your service resources with systemd
 Control your service resources with systemd  Control your service resources with systemd
Control your service resources with systemd
 
TritonSort: A Balanced Large-Scale Sorting System (NSDI 2011)
TritonSort: A Balanced Large-Scale Sorting System (NSDI 2011)TritonSort: A Balanced Large-Scale Sorting System (NSDI 2011)
TritonSort: A Balanced Large-Scale Sorting System (NSDI 2011)
 
Redis Persistence
Redis  PersistenceRedis  Persistence
Redis Persistence
 
Performance comparison of Distributed File Systems on 1Gbit networks
Performance comparison of Distributed File Systems on 1Gbit networksPerformance comparison of Distributed File Systems on 1Gbit networks
Performance comparison of Distributed File Systems on 1Gbit networks
 

Destacado

Schema Design with MongoDB
Schema Design with MongoDBSchema Design with MongoDB
Schema Design with MongoDBrogerbodamer
 
Product catalog using MongoDB
Product catalog using MongoDBProduct catalog using MongoDB
Product catalog using MongoDBVishwas Bhagath
 
MongoDB Schema Design by Examples
MongoDB Schema Design by ExamplesMongoDB Schema Design by Examples
MongoDB Schema Design by ExamplesHadi Ariawan
 
Mongoose and MongoDB 101
Mongoose and MongoDB 101Mongoose and MongoDB 101
Mongoose and MongoDB 101Will Button
 
Mongoose: MongoDB object modelling for Node.js
Mongoose: MongoDB object modelling for Node.jsMongoose: MongoDB object modelling for Node.js
Mongoose: MongoDB object modelling for Node.jsYuriy Bogomolov
 
MongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World ExamplesMongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World ExamplesMike Friedman
 

Destacado (6)

Schema Design with MongoDB
Schema Design with MongoDBSchema Design with MongoDB
Schema Design with MongoDB
 
Product catalog using MongoDB
Product catalog using MongoDBProduct catalog using MongoDB
Product catalog using MongoDB
 
MongoDB Schema Design by Examples
MongoDB Schema Design by ExamplesMongoDB Schema Design by Examples
MongoDB Schema Design by Examples
 
Mongoose and MongoDB 101
Mongoose and MongoDB 101Mongoose and MongoDB 101
Mongoose and MongoDB 101
 
Mongoose: MongoDB object modelling for Node.js
Mongoose: MongoDB object modelling for Node.jsMongoose: MongoDB object modelling for Node.js
Mongoose: MongoDB object modelling for Node.js
 
MongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World ExamplesMongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World Examples
 

Similar a Deployment

Oracle Performance On Linux X86 systems
Oracle  Performance On Linux  X86 systems Oracle  Performance On Linux  X86 systems
Oracle Performance On Linux X86 systems Baruch Osoveskiy
 
The Care + Feeding of a Mongodb Cluster
The Care + Feeding of a Mongodb ClusterThe Care + Feeding of a Mongodb Cluster
The Care + Feeding of a Mongodb ClusterChris Henry
 
Ops Jumpstart: MongoDB Administration 101
Ops Jumpstart: MongoDB Administration 101Ops Jumpstart: MongoDB Administration 101
Ops Jumpstart: MongoDB Administration 101MongoDB
 
Tuning Linux Windows and Firebird for Heavy Workload
Tuning Linux Windows and Firebird for Heavy WorkloadTuning Linux Windows and Firebird for Heavy Workload
Tuning Linux Windows and Firebird for Heavy WorkloadMarius Adrian Popa
 
MeetBSD2014 Performance Analysis
MeetBSD2014 Performance AnalysisMeetBSD2014 Performance Analysis
MeetBSD2014 Performance AnalysisBrendan Gregg
 
Application Profiling for Memory and Performance
Application Profiling for Memory and PerformanceApplication Profiling for Memory and Performance
Application Profiling for Memory and PerformanceWSO2
 
Back to Basics Webinar 6: Production Deployment
Back to Basics Webinar 6: Production DeploymentBack to Basics Webinar 6: Production Deployment
Back to Basics Webinar 6: Production DeploymentMongoDB
 
Application Profiling for Memory and Performance
Application Profiling for Memory and PerformanceApplication Profiling for Memory and Performance
Application Profiling for Memory and Performancepradeepfn
 
Oracle Open World 2014: Lies, Damned Lies, and I/O Statistics [ CON3671]
Oracle Open World 2014: Lies, Damned Lies, and I/O Statistics [ CON3671]Oracle Open World 2014: Lies, Damned Lies, and I/O Statistics [ CON3671]
Oracle Open World 2014: Lies, Damned Lies, and I/O Statistics [ CON3671]Kyle Hailey
 
Operating MongoDB in the Cloud
Operating MongoDB in the CloudOperating MongoDB in the Cloud
Operating MongoDB in the CloudMongoDB
 
5 Pitfalls to Avoid with MongoDB
5 Pitfalls to Avoid with MongoDB5 Pitfalls to Avoid with MongoDB
5 Pitfalls to Avoid with MongoDBTim Callaghan
 
Hadoop World 2011: Hadoop and Performance - Todd Lipcon & Yanpei Chen, Cloudera
Hadoop World 2011: Hadoop and Performance - Todd Lipcon & Yanpei Chen, ClouderaHadoop World 2011: Hadoop and Performance - Todd Lipcon & Yanpei Chen, Cloudera
Hadoop World 2011: Hadoop and Performance - Todd Lipcon & Yanpei Chen, ClouderaCloudera, Inc.
 
Run MongoDB with Confidence: Backing up and Monitoring with MMS
Run MongoDB with Confidence: Backing up and Monitoring with MMSRun MongoDB with Confidence: Backing up and Monitoring with MMS
Run MongoDB with Confidence: Backing up and Monitoring with MMSMongoDB
 
Silicon Valley Code Camp 2015 - Advanced MongoDB - The Sequel
Silicon Valley Code Camp 2015 - Advanced MongoDB - The SequelSilicon Valley Code Camp 2015 - Advanced MongoDB - The Sequel
Silicon Valley Code Camp 2015 - Advanced MongoDB - The SequelDaniel Coupal
 
Best Practices with PostgreSQL on Solaris
Best Practices with PostgreSQL on SolarisBest Practices with PostgreSQL on Solaris
Best Practices with PostgreSQL on SolarisJignesh Shah
 
MySQL Performance Tuning London Meetup June 2017
MySQL Performance Tuning London Meetup June 2017MySQL Performance Tuning London Meetup June 2017
MySQL Performance Tuning London Meetup June 2017Ivan Zoratti
 
Improving Hadoop Performance via Linux
Improving Hadoop Performance via LinuxImproving Hadoop Performance via Linux
Improving Hadoop Performance via LinuxAlex Moundalexis
 

Similar a Deployment (20)

Mongo DB
Mongo DBMongo DB
Mongo DB
 
Tuning Linux for MongoDB
Tuning Linux for MongoDBTuning Linux for MongoDB
Tuning Linux for MongoDB
 
Oracle Performance On Linux X86 systems
Oracle  Performance On Linux  X86 systems Oracle  Performance On Linux  X86 systems
Oracle Performance On Linux X86 systems
 
The Care + Feeding of a Mongodb Cluster
The Care + Feeding of a Mongodb ClusterThe Care + Feeding of a Mongodb Cluster
The Care + Feeding of a Mongodb Cluster
 
Ops Jumpstart: MongoDB Administration 101
Ops Jumpstart: MongoDB Administration 101Ops Jumpstart: MongoDB Administration 101
Ops Jumpstart: MongoDB Administration 101
 
Tuning Linux Windows and Firebird for Heavy Workload
Tuning Linux Windows and Firebird for Heavy WorkloadTuning Linux Windows and Firebird for Heavy Workload
Tuning Linux Windows and Firebird for Heavy Workload
 
MeetBSD2014 Performance Analysis
MeetBSD2014 Performance AnalysisMeetBSD2014 Performance Analysis
MeetBSD2014 Performance Analysis
 
Application Profiling for Memory and Performance
Application Profiling for Memory and PerformanceApplication Profiling for Memory and Performance
Application Profiling for Memory and Performance
 
Back to Basics Webinar 6: Production Deployment
Back to Basics Webinar 6: Production DeploymentBack to Basics Webinar 6: Production Deployment
Back to Basics Webinar 6: Production Deployment
 
Tuning linux for mongo db
Tuning linux for mongo dbTuning linux for mongo db
Tuning linux for mongo db
 
Application Profiling for Memory and Performance
Application Profiling for Memory and PerformanceApplication Profiling for Memory and Performance
Application Profiling for Memory and Performance
 
Oracle Open World 2014: Lies, Damned Lies, and I/O Statistics [ CON3671]
Oracle Open World 2014: Lies, Damned Lies, and I/O Statistics [ CON3671]Oracle Open World 2014: Lies, Damned Lies, and I/O Statistics [ CON3671]
Oracle Open World 2014: Lies, Damned Lies, and I/O Statistics [ CON3671]
 
Operating MongoDB in the Cloud
Operating MongoDB in the CloudOperating MongoDB in the Cloud
Operating MongoDB in the Cloud
 
5 Pitfalls to Avoid with MongoDB
5 Pitfalls to Avoid with MongoDB5 Pitfalls to Avoid with MongoDB
5 Pitfalls to Avoid with MongoDB
 
Hadoop World 2011: Hadoop and Performance - Todd Lipcon & Yanpei Chen, Cloudera
Hadoop World 2011: Hadoop and Performance - Todd Lipcon & Yanpei Chen, ClouderaHadoop World 2011: Hadoop and Performance - Todd Lipcon & Yanpei Chen, Cloudera
Hadoop World 2011: Hadoop and Performance - Todd Lipcon & Yanpei Chen, Cloudera
 
Run MongoDB with Confidence: Backing up and Monitoring with MMS
Run MongoDB with Confidence: Backing up and Monitoring with MMSRun MongoDB with Confidence: Backing up and Monitoring with MMS
Run MongoDB with Confidence: Backing up and Monitoring with MMS
 
Silicon Valley Code Camp 2015 - Advanced MongoDB - The Sequel
Silicon Valley Code Camp 2015 - Advanced MongoDB - The SequelSilicon Valley Code Camp 2015 - Advanced MongoDB - The Sequel
Silicon Valley Code Camp 2015 - Advanced MongoDB - The Sequel
 
Best Practices with PostgreSQL on Solaris
Best Practices with PostgreSQL on SolarisBest Practices with PostgreSQL on Solaris
Best Practices with PostgreSQL on Solaris
 
MySQL Performance Tuning London Meetup June 2017
MySQL Performance Tuning London Meetup June 2017MySQL Performance Tuning London Meetup June 2017
MySQL Performance Tuning London Meetup June 2017
 
Improving Hadoop Performance via Linux
Improving Hadoop Performance via LinuxImproving Hadoop Performance via Linux
Improving Hadoop Performance via Linux
 

Deployment

  • 2. Thoughts on Deployment roger@10Gen.com @rogerb
  • 3. Congratulations ! Development done ? Toll ! Ready to Deploy :-)
  • 4. some points to consider
  • 5. Agenda • Sizing Your Hardware • memory / cpu / disk io • Software • os / filesystem • Installing MongoDB • EC2 Notes • Security • Backup • Durability • Upgrading • Monitoring • Scaling out
  • 6. Sizing Hardware: Memory • Memory Mapped files • Maps DB on Filesystem to Memory • Minor Page Faults - in memory - cheap • Major Page Faults - not in memory - from disk - expensive • Indices • Part of the regular DB files • Can be completely in memory .. • Or partially • Working set should be as much in memory as possible, but
  • 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 •Parallel in sharded environments. • 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 • Flash •Expensive, getting cheaper •Significantly reduced seek time, increased IO throughput • Network •It’s easy to saturate your network
  • 9. 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  
  • 10. OS • For production: Use a 64bit OS • 32bit has 2G limit • Clients can be 32 bit • MongoDB supports (little endian only): • Linux • Windows • Solaris (joyent)
  • 11. Filesystem • All data, namespace files stored in data directory • Possible to create links • Better to aggregrate IO across disks •File Allocation
  • 12. Filesystem • MongoDB is filesystem-neutral: • ext3, ext4 and XFS are most used • ext4 / XFS preferred (posix_fileallocate()) • improved performance for file allocation • Support for NTFS for windows
  • 13. 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
  • 14. Installing MongoDB • Installing from Source • Requires Scons, C++ compiler, Boost libraries, ... • 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
  • 15. EC2 Notes • Default storage instance is EXT3 • For best performance, reformat to EXT4 / XFS • 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
  • 16. 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
  • 17. 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)
  • 18. Backup • Typically backups are driven from a slave • Eliminates impact to client / application traffic to master
  • 19. Backup •Two main Strategies • mongodump / mongorestore • Filesystem • Filelock + fsync
  • 20. mongodump • binary, compact object dump • each consistent object is written • not necessarily consistent from start to finish • mongorestore to restore database • database does not have to be up to restore
  • 21. 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();
  • 22. Durability What failures do you need to recover from? • Loss of a single database node? • Loss of a group of nodes?
  • 23. Durability - Master only • Write acknowledged when in memory on master only
  • 24. Durability - Master + Slaves • W=2 •Write acknowledged when in memory on master + slave • Will survive failure of a single node
  • 25. 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)
  • 26. Slave delay • Protection against app faults • Protection against administration mistakes • Slave runs X amount of time behind
  • 27. 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
  • 28. Monitoring • We like Munin .. • ... but other frameworks work as well • Primary function: • Measure stats over time
  • 29. Thank You :-) @rogerb
  • 30. 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