Friday, May 25, 2012

MongoDB pain points

Recently I was contacted by 10gen's account manager soliciting a feedback on our use of MongoDB at the company I'm working at. I wrote a lengthy reply on what we do with MongoDB and the problems we see with it and never heard back. It was a shame to all these feedback to go to waste so I decided to repost it with minor edits in my blog. So here it comes ...

We are using MongoDB at IPONWEB for quite long time - for ~2 years already for a number of high loaded projects. Our company specializes at creating products for display advertising and mostly we are using MongoDB to keep track of user data in our adservers. The main reason we are using MongoDB is raw performance. We are using MongoDB mostly as dumb NoSQL key-value database where we try to keep data fully cached in RAM. With rare exceptions we are not using any fancy features like complex queries, map-reduce and so on but rather limit ourselves to queries by a primary key. We do use sharding because as I mentioned above we have to put whole database to RAM so we often have to split database across multiple servers. Generally we are very price sensitive about costs of the installation so we are always looking at reducing hardware costs for our databases. Giving this background the following limitations in MongoDB implementation cause us the most grief:

a) lack of online database defragmentation in MongoDB. Currently the only way to compact MongoDB database is to stop the database and run compact or repair. On our datasets this process runs for considerable time. We do have to defragment  database pretty often to keep RAM usage under control. Fragmented vs non-fragmented database can be easily be two times bigger what in our case means two time higher hardware costs.

b) realistically for our use case we can do MongoDB resharding only offline. Adserving is extremely sensitive to any latencies and if we add more shards to existing cluster we more or less forced to take the application offline until resharding finishes.

c) lack of good support of SSD. The way MongoDB works now switching from using more RAM with HDD as backing storage in favor of using less RAM with SSD backing storage doesn't seem to be cost effective. SSD if priced per 1GB is roughly two times cheaper then RAM but if we place our data on SSD we have to reserve at least two more time space on SSD if we want to be able to run repair on the data (this is because running repair requires two times more space). Other reason we considered using SSD as backing storage instead of HDD is write performance in some applications where it was a limitation. But from our limited benchmarking we found small performance difference because it looks like single thread write lock in MongoDB becomes a bottleneck rather then underlying storage.

d) minor point: underlying networking protocol could be more efficient with some optimizations. If you send many small queries and get small documents as result MongoDB creates separate TCP packets for each request/response. Under high load especially in case of virtualized hardware (i.e. EC2) this introduces additional high overhead. We have our own client driver which tries to pack multiple requests in single TCP packets and it makes noticeable difference in performance on EC2. But this is a partial solution because responses from MongoDB and communications between mongos and mongod are still inefficient.

e) another minor point: BSON format is very wasteful in terms of memory usage. Giving that we try to minimize our database sizes to reduce hardware costs the recent trend in our use of MongoDB is instead of representing data as BSON document do serialization to some more compact format and instead store our data as big binary blobs (i.e. to simplify our documents look like { _id = '....', data = '... serialized data ...'}

By the way at some point we evaluated switching to CitrusLeaf. This product supposedly addresses some of the above issues (mostly a, b and c) but it seems that expected savings in hardware costs would be offset by licensing costs so at least for now we are not going to.


Salocin.TEN ( said...

Thank you for the pointers.

I am currently starting out with MongoDB and so will take into account the points mentioned. :-)

Ac Jitu said...

After study a number of the websites with your site now, and that i genuinely appreciate your method of blogging. I bookmarked it to my bookmark site list and are checking back soon. Pls have a look at my web page likewise and let me know if you agree.

Kent Hu said...

Nice post, keep it up.
Hope you are well in the current situation.
b2b marketing service
seo package

Bryan said...

Good content, hope you well and keep it up.
property management company malaysia

Ahmad Fakruden said...

That's interesting, thanks for sharing.
eddy current testing service

maxis wireless broadband said...

Let’s read all these articles

Great Assignment Helper said...

Assignment is a new norm of every modern education system thus creating a need of Do my statistics assignment online websites. We are one of those who have been providing such help to students for years. A main reason behind our success is our trustworthiness. Trust us once with the most important part of your academic life and see how we make it shine.

Emma keth said...

Download Cricut Design Space from | Cricut com setup windows | setup windows and install it to set up your Cricut machine. With the installation, you can easily move on to designing, cutting, and crafting. An account is essential to create that allows you to select multiple projects and keeps you updated.

Marry James said...

Marry James is a writing Expert with 15+ years of experience. Marry is also associated with, where she regularly helps students write their essays/assignments. In addition, Marry also likes to read and has read more than 100 books now. Students prefer his services as a tutor and as a counsellor and guides students on academic issues. She offers HTML assignment help to students who need help with their papers. Marry is a programmer too, so she has detailed knowledge about the subject.

Other Service
write my essay for me
Top Essay Writing Service
English Essay Writing Help
Physics homework help
college essays help
Essay Editing Service
Fraction Calculator
Persuasive Essay Help
write my research paper
plagiarism checker
Book Review Writing
Title Generator
plagiarism checker
Nursing Resume
free tools
Harvard referencing generator
Summary Generator
fnsacc311 assessment answers
hltaid004 assessment answers

maxis wireless broadband said...

Good article! Check out
event management company, online payroll system malaysia, and payroll

CoinCog - Best Crypto Blogs in 2022 said...

Users can connect with dApps (decentralised applications) on the Ethereum network and manage their Ethereum wallets using the browser extension MetaMask. It is readily downloaded and installed from the Chrome Web Store as a Metamask Chrome Extension. Once installed, users can use a seed phrase to create a new wallet or import an existing one. With MetaMask, users can use their browser to interact with decentralised applications, send and receive Ethereum and ERC-20 tokens, and view their account balances. Users can connect to numerous Ethereum networks, including the main Ethereum network, testnets, and private networks, and it offers increased security features including password protection. For anyone interested in using Ethereum and other blockchain technologies, MetaMask is a strong tool.

maxis wireless broadband said...

We should always go for new knowledge, and here it is one of the great article
pocket spring manufacturer malaysia, and laptop rental malaysia

maxis wireless broadband said...

Nice article that you shared. Would like to read more great article.
foam mattress malaysia, latex mattress malaysia, and plastic packaging singapore

maxis wireless broadband said...

Good article! Check out how to pay off debt, dermal filler malaysia,
and service fire extinguisher malaysia

maxis wireless broadband said...

Nice article you shared. Thanks for sharing.
chemical supplier malaysia and fragrance ingredients supplier malaysia

maxis wireless broadband said...

Nice article you shared. Thanks for sharing.
metal deck roof malaysia
metal roof malaysia