NoSQL Zone is brought to you in partnership with:

I have been in the Software business for close to 30 years now, and I have 25+ years with SQL-based relational databases. Although I have used Unix even longer than that, I am pretty much an operating system agnostic. Over the years, I have work in many positions, from support engineer to sales engineer and consultant. Anders is a DZone MVB and is not an employee of DZone and has posted 50 posts at DZone. You can read more from them at their website. View Full User Profile

MySQL as a KVS vs. MongoDB: MySQL Beats Mongo by 62K Rows/Sec.

  • submit to reddit

The first 8 articles:

A few days ago, I wrote a bit on my first results of comparing MySQL with MongoDB as a Key-Value Store, something that has been going on for way to long, but I am not finished yet. The last time I used MySQL Embedded Library to bypass the MySQL Client Server protocol to see what the overhead was, and the result was that it is big (and again, note that the same networking was used with MongoDB and I was also using Unix Domain Sockets, as well as plain TCP/IP, so don't ask me to fix any network issues I might have). Using Embedded Server with InnoDB was actually faster than using MongoDB, some 3 times faster compared to using the client / server protocol.

That one out of the way, I now wanted to see what I could get if I used the storage engine that was fastest in Client / Server mode, MEMORY. That took a while to fix, as to have an Embedded Server application, like my test application here, use the MEMORY engine, I have to load the data into the MEMORY table somehow each time I run the application. No big deal but a slight update to my benchmarking application was needed, as well as some debugging as embedded server is pretty picky with you doing things the right way and in exactly the right order, and is much less forgiving than the MySQL Client library. Anyway, I now have it fixed, and the result. Fast. Real fast and furious: 172 k rows read per second! Compared to 110k rows read per second with MongoDB (but that is MongoDB in Client Server mode of course). Using the MySQL Client, the MEMORY engine achieved 43 k row reads per second, which means that libmysqld is 400% faster! How is that for a performance improvement.

Which is not to say that we all should start building libmysqld applications right now. But what I want to say is that if you want to improve the performance of MySQL, looking into the Client / Server protocol would be a good starting point, there is a lot of performance to get there. The results noted could be interpreted as at least 75% of the time that MySQL processes a query, excluding disk I/O (this is the MEMORY engine after all), is spent in the Client / Server protocol. And looking at it differently: A key value store such as MongoDB might not be as fast as we think, but MongoDB sure does have a more efficient C/S protocol!


Published at DZone with permission of Anders Karlsson, 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.)


Andrei Sfat replied on Wed, 2012/08/29 - 6:44am

Interesting article. I did myself some performance tests on MySQL and some NoSQL dbs (MongoDB, HBase, Neo4j) and I want to know details about this test. What I mean by this is:


  1.  Configuration of the machine on which the tests were made
  2.  What data is being stored in the db (the model that you are using, possibly specifying how big is one row which is inserted in Kb)
  3.  Did you do only read operations or insert operations?
  4. What was the whole amount of data you were doing your tests on? 100k? 1mil? 10, maybe?


Brice Laurencin replied on Wed, 2012/08/29 - 10:32am

I would have added Redis to the showdown, because that one is blazing fast

Will Soprano replied on Wed, 2012/08/29 - 12:09pm

Hey Brice,

Would you like to take this test and test it against Redis??  email me: 

Octavian Covalschi replied on Wed, 2012/08/29 - 3:02pm

If both MongoDB and MySQL would crash, what will happen with all that data? MongoDB has journaling enabled, so it should be safer. What about MySQL and it's MEMORY engine?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.