Monday, November 08, 2010

Summary on MongoDB, CouchDB and Redis

A few days ago I've read up on MongoDB, CouchDB and Redis just to get the idea and understand the difference between them. Here is my summary:

MongoDB – a great, very fast and scalable document-oriented storage written in C++. Queries are similar to SQL queries, grouping and aggregation are supported by MapReduce functions written in JavaScript. It supports atomic in-place updates, which means that revisions of documents are not stored. MongoDB provides native drivers for different languages that use a special protocol over TCP/IP. MongoDB uses BSON (binary JSON) to store the data. It doesn't support transactions and it's recommended to have at least two servers to unsure durability (however, the v1.8 release will have single server durability.) MongoDB handles horizontal scalability via auto-sharding across multiple nodes. The only thing is that it's recommended to have a replica of each node for failover. In my opinion, MongoDB is a great replacement for relational databases, except for the cases where transactions are essential.

CouchDB – a similar to MongoDB document-oriented storage written in Erlang, but according to some tests is a bit slower, probably due to using JSON to store the data (MongoDB uses BSON), and because all requests go throw HTTP. CouchDB works according to the non-in-place updates model – it always stores all revisions of documents. CouchDB doesn't support traditional dynamic queries, all queries must be prepared as views using MapReduce in JavaScript. The good thing about this is that the results of all views are precomputed and are automatically updated in case of any changes in the data with logarithmic complexity. CouchDB can store JavaScript functions, which can be called in queries. All this makes it possible to work with the database directly from a frontend (for example web interface) using HTTP without implementing a backend, which is probably a very nice feature for some use cases. It supports horizontal scaling using the Master-Master model and doesn't require a double-server setup for durability.

Redis – an in-memory key-value storage (the values can be lists, sets, sorted sets and hashes) written in ANSI C. Redis supports the ability to save the data to a disk from time to time. A good easily scalable replacement for memcached with comparable performance and advanced features. Interesting, that some tests showed that MongoDB can even beat Redis in terms of performance. And the authors of MongoDB say that normally you wouldn't need an additional in-memory cache when using MongoDB :)

I'm looking forward to trying MongoDB in some application :)

Read more →

Solutions to the first 5 Project Euler problems in Clojure

Recently, I've started learning the Clojure programming language. After reading a great book, Programming Clojure by Stuart Halloway, I decided to get my hands dirty and try something real :) There is a nice site that does precisely what you need in such cases: gives you tasks to solve. In this post I just want to list my solutions to the first five problems written in Clojure and probably make somebody interested in this amazing language.

Let's get started! :)

Read more →