MongoDB one server problems/pittfalls

59 views Asked by At

I'm working on a project using MongoDB and therefor asked my server manager to install MongoDB.

I recently read on an old stackoverflow thread that it is not really recommended to run MongoDB on a single server, because of a possibility of data loss. I'm not really an expert and want to avoid such cases. Do these problems still exist and should I look for another solution like remote databases or is it safe to install it?

What are pitfalls that I should make sure my managed server provider takes care of?

1

There are 1 answers

1
mnemosyn On BEST ANSWER

Warning - the article linked to by chridam is dangerously out-of-date.

Simply put, no, there's not much to worry about with single server deployments of MongoDB anymore. By default, MongoDB will write everything to the journal every 100ms. If there are writes with the j (journal) option, that interval is shortened to a third. I have posted a longer answer with the gritty details (two, actually) to a similar question some time ago.

The point is that a write operation with j : true won't return until the write made it to the journal (i.e., expect these calls to take 16ms+, on average), and that's exactly the behavior one would expect and that's also how most other dbs behave.

You should ensure you're using the journalling write concern (j : true) and journalling isn't disabled. Also, since the defaults depend on the server version and there's lots of new features, bugfixes and performance improvements, make sure you're getting a somewhat recent version of MongoDB (might not be the case if the server runs something like debian stable).