Monthly Archives: June 2011

MongoDB versus Riak Datastore: Some Benchmarks

I was doing some google searches, and I found some benchmarks of MongoDB and Riak.

Mr. Howe benchmarked MongoDB. He was able to get 1,750 GET requests per second from Mongo, when the keys could be stored in memory.

In contrast, the folks at Joyeur were able to get 6,650 GET requests per second on a five-node Riak cluster and 13,700 GET requests per second on a 10-node cluster. These are “highly optimized” Riak clusters, using the “protocol buffers” interface.

In reality, most people do not run “highly optimized” Riak clusters with “protocol buffers”; rather, they run non-optimized Riak clusters over HTTP. I did a quick and dirty informal test of my Riak cluster (Erlang: R13B04, Riak: 0.14.2). I have a three node cluster, and I was testing from a remote server over an internal network, using node.js and riak-js client. I have about 200,000 records in Riak, which is well within the memory requirements of the cluster. In my informal tests, I got about 250 GET requests per second.

One interesting thing to note is that Basho, the company that supports Riak, admits that MongoDB is “more peformant.” The entire quote: “Mongo is more performant because it uses memory-mapped files. The tradeoff is that it fsyncs (flushes in-memory data to disk) only every 60 seconds by default, so you run the risk of losing data if your MongoDB server goes down. The solution for increasing durability in MongoDB is to replicate.” See

The advantage of Riak over Mongo is that Riak automatically replicates and rebalances.

The advantage of MongoDB over Riak is that Mongo supports secondary indexes and a more robust query language.

Both Riak and MongoDB support MapReduce via JavaScript, and both use the SpiderMonkey JavaScript engine. However, Riak’s MapReduce framework is more powerful than MongoDB’s framework because Riak allows you to run MapReduce jobs on a filtered set of keys. By contrast, in Mongo, you have to run MapReduce jobs across an entire database.