Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB database architecture [closed]

I want to understand more about the system and DB architecture of MongoDB.

I am trying to understand how MongoDB stores and retrieves the documents. If it's all in memory etc.

A comparative analysis between MongoDB and Oracle will be a bonus but, I am mostly focusing on understanding the MongoDB architecture per se.

Any pointers will be helpful.

like image 541
Ayusman Avatar asked Mar 30 '12 18:03

Ayusman


1 Answers

MongoDB memory maps the database files. It allows the OS to control this and allocate the maximum amount of RAM to the memory mapping. As MongoDB updates and reads from the DB it is reading and writing to RAM. All indexes on the documents in the database are held in RAM also. The files in RAM are flushed to disk every 60 seconds. To prevent data loss in the event of power failure, the default is to run with journaling switched on. The journal file is flushed to disk every 100ms and if there is power loss is used to bring the database back to a consistent state. An important design decision with mongo is on the amount of RAM. You need to figure out your working set size - i.e if you are going to be reading and writing to only the most recent 10% of your data in the database then this 10% is your working set and should be held in memory for maximum performance. So if your working set is 10GB you are going to neen 10GB for max performance - otherwise your queries/updates will run slower as pages of memory are paged from disk into memory. Other important aspects of mongoDB are replication for backups and sharding for scaling. There are a lot of great online resources for learning. MongoDB is free and opensource.

EDIT: It's a good idea to check out the tutorial http://www.mongodb.org/display/DOCS/Tutorial and manual http://www.mongodb.org/display/DOCS/Manual and the Admin Zone is useful too http://www.mongodb.org/display/DOCS/Admin+Zone and if you get bored of reading then the presentations are worth checking out. http://www.10gen.com/presentations

like image 153
geakie Avatar answered Oct 22 '22 23:10

geakie