webinar - approaching 1 billion documents with mongodb
DESCRIPTION
Presentation given via webinar on 5th May 2010 by David Mytton on approaching 1 billion documents in MongoDB. Audio recording at http://bit.ly/mongo1bndocsTRANSCRIPT
![Page 2: Webinar - Approaching 1 billion documents with MongoDB](https://reader034.vdocument.in/reader034/viewer/2022051109/54820ab05806b5fc048b4620/html5/thumbnails/2.jpg)
Server Density Monitoring
Processing Database UI
www.serverdensity.com2/25
![Page 3: Webinar - Approaching 1 billion documents with MongoDB](https://reader034.vdocument.in/reader034/viewer/2022051109/54820ab05806b5fc048b4620/html5/thumbnails/3.jpg)
db.stats()
Documents 981,289,332
Collections 47,962
Indexes 39,684
Data size 369GB
Index size 241GB
As of 25th Apr 2010.3/25
![Page 4: Webinar - Approaching 1 billion documents with MongoDB](https://reader034.vdocument.in/reader034/viewer/2022051109/54820ab05806b5fc048b4620/html5/thumbnails/4.jpg)
10 months
Why we moved: http://bit.ly/mysqltomongo4/25
![Page 5: Webinar - Approaching 1 billion documents with MongoDB](https://reader034.vdocument.in/reader034/viewer/2022051109/54820ab05806b5fc048b4620/html5/thumbnails/5.jpg)
Initial Setup
MasterDC1
8GB RAM
SlaveDC2
8GB RAM
Replication
5/25
![Page 6: Webinar - Approaching 1 billion documents with MongoDB](https://reader034.vdocument.in/reader034/viewer/2022051109/54820ab05806b5fc048b4620/html5/thumbnails/6.jpg)
Vertical Scaling
MasterDC1
72GB RAM
SlaveDC2
8GB RAM
Replication
6/25
![Page 7: Webinar - Approaching 1 billion documents with MongoDB](https://reader034.vdocument.in/reader034/viewer/2022051109/54820ab05806b5fc048b4620/html5/thumbnails/7.jpg)
Tip #1
Keep your indexes in memory at all times.
7/25
db.stats()
![Page 8: Webinar - Approaching 1 billion documents with MongoDB](https://reader034.vdocument.in/reader034/viewer/2022051109/54820ab05806b5fc048b4620/html5/thumbnails/8.jpg)
Manual Partitioning
Master ADC1
16GB RAM
Slave ADC2
16GB RAM
Replication
Master BDC1
16GB RAM
Slave BDC2
16GB RAM
Replication
8/25
![Page 9: Webinar - Approaching 1 billion documents with MongoDB](https://reader034.vdocument.in/reader034/viewer/2022051109/54820ab05806b5fc048b4620/html5/thumbnails/9.jpg)
Database vs collections
• Many databases = many data files (small but quickly get large).
• Many collections = watch namespace limit.
9/25
![Page 10: Webinar - Approaching 1 billion documents with MongoDB](https://reader034.vdocument.in/reader034/viewer/2022051109/54820ab05806b5fc048b4620/html5/thumbnails/10.jpg)
Namespaces = Number of collections + number of indexes
10/25
![Page 11: Webinar - Approaching 1 billion documents with MongoDB](https://reader034.vdocument.in/reader034/viewer/2022051109/54820ab05806b5fc048b4620/html5/thumbnails/11.jpg)
Tip #2
Monitor the 24,000 namespace limit.
11/25
![Page 12: Webinar - Approaching 1 billion documents with MongoDB](https://reader034.vdocument.in/reader034/viewer/2022051109/54820ab05806b5fc048b4620/html5/thumbnails/12.jpg)
Using Server Density
12/25
![Page 13: Webinar - Approaching 1 billion documents with MongoDB](https://reader034.vdocument.in/reader034/viewer/2022051109/54820ab05806b5fc048b4620/html5/thumbnails/13.jpg)
Console
db.system.namespaces.count()
13/25
![Page 14: Webinar - Approaching 1 billion documents with MongoDB](https://reader034.vdocument.in/reader034/viewer/2022051109/54820ab05806b5fc048b4620/html5/thumbnails/14.jpg)
Replica Pairs = Failover
Master ADC1
16GB RAM
Slave ADC2
16GB RAM
Replica Pair
Master BDC1
16GB RAM
Slave BDC2
16GB RAM
Replica Pair
14/25
![Page 15: Webinar - Approaching 1 billion documents with MongoDB](https://reader034.vdocument.in/reader034/viewer/2022051109/54820ab05806b5fc048b4620/html5/thumbnails/15.jpg)
Tip #3
Pre-provision your oplog files.
15/25
![Page 16: Webinar - Approaching 1 billion documents with MongoDB](https://reader034.vdocument.in/reader034/viewer/2022051109/54820ab05806b5fc048b4620/html5/thumbnails/16.jpg)
for i in {0..40} do echo $i head -c 2146435072 /dev/zero > local.$i done
A shell script to generate 75GB oplog files
16/25
![Page 17: Webinar - Approaching 1 billion documents with MongoDB](https://reader034.vdocument.in/reader034/viewer/2022051109/54820ab05806b5fc048b4620/html5/thumbnails/17.jpg)
Tip #4
Expect slower performance during initial replica sync.
17/25
![Page 18: Webinar - Approaching 1 billion documents with MongoDB](https://reader034.vdocument.in/reader034/viewer/2022051109/54820ab05806b5fc048b4620/html5/thumbnails/18.jpg)
Tip #5
You can rotate your log files from the console.
18/25
![Page 19: Webinar - Approaching 1 billion documents with MongoDB](https://reader034.vdocument.in/reader034/viewer/2022051109/54820ab05806b5fc048b4620/html5/thumbnails/19.jpg)
Rotating your log files
db.runCommand("logRotate")
19/25
![Page 20: Webinar - Approaching 1 billion documents with MongoDB](https://reader034.vdocument.in/reader034/viewer/2022051109/54820ab05806b5fc048b4620/html5/thumbnails/20.jpg)
Tip #6
Index creation blocks by default. Use background
indexing if necessary.
MongoDB Manual: http://bit.ly/mongobgindex20/25
![Page 21: Webinar - Approaching 1 billion documents with MongoDB](https://reader034.vdocument.in/reader034/viewer/2022051109/54820ab05806b5fc048b4620/html5/thumbnails/21.jpg)
Tip #7
Increase your OS file descriptor limit + use
persistent connections.
21/25
![Page 22: Webinar - Approaching 1 billion documents with MongoDB](https://reader034.vdocument.in/reader034/viewer/2022051109/54820ab05806b5fc048b4620/html5/thumbnails/22.jpg)
Too many open files!
mongo hard nofile 10000mongo soft nofile 10000
/etc/security/limits.conf
UsePAM yes
/etc/ssh/sshd_config
22/25
user type limit
![Page 23: Webinar - Approaching 1 billion documents with MongoDB](https://reader034.vdocument.in/reader034/viewer/2022051109/54820ab05806b5fc048b4620/html5/thumbnails/23.jpg)
Space is not reused
23/25
![Page 24: Webinar - Approaching 1 billion documents with MongoDB](https://reader034.vdocument.in/reader034/viewer/2022051109/54820ab05806b5fc048b4620/html5/thumbnails/24.jpg)
Tip #8
10gen commercial support is worth paying for.
24/25
![Page 25: Webinar - Approaching 1 billion documents with MongoDB](https://reader034.vdocument.in/reader034/viewer/2022051109/54820ab05806b5fc048b4620/html5/thumbnails/25.jpg)
Summary1. Keep indexes in memory.
2. Monitor the 24k namespace limit.
3. Pre-provision oplog files.
4. Expect slower performance on replica sync.
5. Rotate logs from the console.
6. Index creation blocks by default.
7. OS file descriptor limit + persistent connections.
8. Commercial support is worth it.25/25