News for hackers. Stuff that matters.
Re:MongoDB Performance & Durability by alexpopescu on Wednesday July 07, 2010 @06:33PM (#1495751)
Posted about this months ago: http://nosql.mypopescu.com/post/392868405/mongodb-durability...

I do agree durability is important, but as long as you are aware of this behavior and you consider it in your design, you may still find scenarios where the gained speed is a good trade off.

Another aspect that tends to be forgot when speaking about MongoDB is its fire-and-forget API. Combined with the behavior of automatic collection creation, innexistent data validation this may lead to "interesting" results.

Re:MongoDB Performance & Durability by jamwt on Wednesday July 07, 2010 @07:14PM (#1495859)
I'm a big fan of MongoDB, and I think its replicated durability characteristics are good enough for many classes of applications. If you could lose a minute of data and have it just be "bad" instead of "customer enraging and business threatening", then it's a very nice database system.

However--I do think the decision to make writes "fire and forget" is just a mistake. If you use abstractions like a connection pool under heavy concurrency, you can get unpredictable behavior in terms of when the data is "actually there."

For example, all in one thread:

with connection pool: do_write operation A

do other things...

with connection pool: read something, assuming A has been applied

Specifically, the fact that you get an arbitrary connection out of the pool means you cannot be sure that the database has completely processed operation A before executing your new query.

MongoDB has a "safe=" flag in their Python bindings that implements the project's official (http://www.mongodb.org/display/DOCS/Last+Error+Commands#Last...) recommendation for "it is written" consistency. It's a bit of a hack, but it calls "getLastError()" on the connection that does the write before returning from the update()/save()/insert()/delete() call. I think it's astonishing this behavior isn't the default.

In fact, I recently updated diesel's bindings to be safe=True, so getLastError() is always executed on write operations to make sure they succeeded before the call returns:

http://github.com/jamwt/diesel/commit/95cd71d82ffc5c308060b6...

Re:MongoDB Performance & Durability by ericflo on Wednesday July 07, 2010 @07:30PM (#1495901)
It's not really about losing a minute of data though--the whole thing could become corrupted, and repairing it will be extremely difficult.
Re:MongoDB Performance & Durability by kristina on Wednesday July 07, 2010 @08:06PM (#1496000)
...which is why you have a slave. Master corrupt? Promote the slave to master, get it its own slave.

Repairing a corrupted database, even a relational database, often takes too long for a production app.

Re:MongoDB Performance & Durability by janl on Wednesday July 07, 2010 @08:12PM (#1496012)
So you run naked during the time of the master rebuild? — The only sensible solution is to run two slaves at least, IMHO. — I haven't looked, but do you promote that?
Re:MongoDB Performance & Durability by mathias_10gen on Wednesday July 07, 2010 @08:57PM (#1496090)
Actually, that will be a recommended config for replica sets. Most of our slides already show 3 replicas per set.

Also, most people have backups so its not really "running naked". See http://www.mongodb.org/display/DOCS/Backups for a few ways to backup mongodb. With LVM/EBS/ZFS or any other snapshotable filesystem, backups can be done almost instantly. With EBS you can even get an insta-slave from the snapshot.

Re:MongoDB Performance & Durability by mikealrogers on Wednesday July 07, 2010 @11:30PM (#1496388)
wait, seriously?

the suggested default step 1 for MongoDB is to acquire 3 servers?

i mean, no other database suggests such a huge default configuration. even knowing that their datacenter can get hit by lightening and all a lot of large production sites don't even run with this kind of redundancy.

this seems like a pretty taxing workaround for not keeping an append-only transaction log.

Re:MongoDB Performance & Durability by mathias_10gen on Thursday July 08, 2010 @12:22AM (#1496479)
No, it is a suggested configuration, not the suggested one. And recommending three nodes is not that uncommon for distributed systems, because you cant have a quorum with only two nodes. Some users are more concerned with handling 10s or 100s of servers than having single-server durability.

That said, for most users two servers are fine. Other users don't need any replicas at all since they do a nightly dump from a stored source into mongodb, or they just take regular backups. There are many ways to achieve system-wide durability, not all of them require the database to be durable.

Re:MongoDB Performance & Durability by ekidd on Thursday July 08, 2010 @07:49AM (#1497060)
"the suggested default step 1 for MongoDB is to acquire 3 servers?"

At my previous job, we suffered a catastrophic RAID failure. The controller died while trying repair a degraded array. At this point, we valued the data enough that we weren't going to screw around with replacing the controller and restarting the recovery. The whole RAID array went out to DriveSavers, at the cost of several thousand dollars. Now, DriveSavers are really awesome folks, but my goal is to never do business with them again. :-)

After this incident, our policy was simple: If our data mattered, it had to be replicated.

A 3 server configuration is, admittedly, pretty high end: Even if one node is down, you still have redundancy. You can keep the remaining 2 nodes live while rebuilding the failed node.

I know lots of people who care _deeply_ about data integrity, but who keep their databases on a single server. I find this a bit mystifying: Even the most expensive hardware can die in ugly and unrecoverable ways. And RAID arrays are some of the biggest culprits: Their striping formats are usually undocumented and proprietary.

Re:MongoDB Performance & Durability by didip on Thursday July 08, 2010 @02:05AM (#1496620)
I believe Cassandra also suggest 3 nodes configuration.