NoSQL Zone is brought to you in partnership with:

' ! Moshe Kaplan constantly helps successful firms getting to the next level and he is thrilled to uncover some of his secrets. Mr. Kaplan is a seasoned project management and cloud technologies lecturer. He is also known to be a cloud and SCRUM evangelist Moshe is a dSero.com Co-Founder. He was a R&D Director at Essence Security, led RockeTier and served as a board member in the IGT and as a department head at a top IDF IT unit. Moshe holds M.Sc and B.Sc from TAU. Moshe is a DZone MVB and is not an employee of DZone and has posted 59 posts at DZone. You can read more from them at their website. View Full User Profile

MongoDB Insider Tips

03.07.2013
| 3010 views |
  • submit to reddit

This time I would like to share with you several insider tips that can be used to better understand mongoDB and its internals.

Memory Limitation: No, mongoDB does not support it (very similar to SQL Server before adjusting the memory limitations): Virtual memory and resident sizes may appear to be very large for the mongod process. This is  by design: virtual memory space should be just larger than the size of the data files open and mapped. Resident size will vary depending on the amount of memory not used by other processes on the machine. Yes, if you allocate more memory to the machine, mongoDB will happily consume it, mongoDB defines its storage size. You can compact it. Mongo tends to preallocate a significant size of disk. If your data store is too large you may use the following commands to reduce it:
Use ext4 file system When ext3 is used and mongoDB allocates new data files, these files have to be filled with zeroes that are written back to the underlying disk (yes, extra unneeded writes to disk). When ext4 or xfs are used, mongoDB uses the falloc syscall that marks the file as allocated and zeroed, without actually writing anything back to the underlying storage. The result is a better insert performance on ext4 than ext3. Quorum is for voting, data replication is async by default. Unlike Cassandra, mongoDB uses Quorum only for primary server selection. Write is done only to primary server and answer is returned to the client immediately. The secondary servers (or some will say the slaves) copy the data in async way. Synchronous replication is possible but not recommended: Query response to user can be delayed to ensure that data was replicated to slaves. However it may result with 2 orders of magnitude performance decrease:  mongoDB stores data as BSON and communicates in JSON BSON or JSON? This is not a question anymore, as mongoDB these days automatically serialize the JSONs into BSONs to save space on disk. Bottom Line Now that you better understand the mongoDB architecture, it is time to make more out of it,
Published at DZone with permission of Moshe Kaplan, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)