[Django]-Mongo DB or Couch DB with django for building an app that is similar to top coder?

3👍

General Differences

Django Specific

All my research points me towards the idea that Mongo and Couch are similar enough that your choice would probably boil down to personal (subjective) preference even over the use-case. Personally, I’ve developed a CouchDB fetish and am looking for a reason to use it.

The key factor influencing your decision should probably be which noSQL solution has the most mature ORM framework for Django?

3👍

I’ve used mongo-engine with Django but you need to create a file specifically for Mongo documents eg. Mongo_models.py. In that file you define your Mongo documents. You then create forms to match each Mongo document. Each form has a save method which inserts or updates whats stored in Mongo. Django forms are designed to plug into any data back end ( with a bit of craft ).

If you go this route you can dodge Django non-rel which is still not part of Django 1.4. In addition I believe django-nonrel is on hiatus right now.

I’ve used both CouchDB and Mongo extensively. CouchDB has a lovely interface. My colleague is working on something similar for Mongo. Mongo’s map and reduce are far faster than CouchDB. Mongo is more responsive loading and retrieving data. The python libraries for Mongo are easier to get working with ( both pymongo and mongo-engine are excellent )

Be sure you read the Mongo production recommendations! Do not run one instance on the same node as Django or prepare to be savagely burned when traffic peaks. Mondo works great with Memcache/Redis where one can store reduced data for rapid lookups.

BEWARE: If you have very well defined and structured data that can be described in documents or models then don’t use Mongo. Its not designed for that and something like PostGreSQL will work much better.

  • I use PostGreSQL for relational or well structured data because its good for that. Small memory footprint and good response.
  • I use Redis to cache or operate in memory queues/lists because its very good for that. great performance providing you have the memory to cope with it.
  • I use Mongo to store large JSON documents and to perform Map and reduce on them ( if needed ) because its very good for that. Be sure to use indexing on certain columns if you can to speed up lookups.

Don’t use a circle to fill a square hole. It won’t fill it.

2👍

I’ve used CouchDB with Django for a production application. Couch is fine and has some great ideas, but I’m moving that app over to MongoDB. Why? There is support for Mongo in the Django community. Django-nonrel has a MongoDB backend. Using Django-toolbox I can embed models in models and have some basic admin support.

If I remember correctly, Django-nonrel will eventually be rolled into Django core. In five years time I see much more support for Mongo in Django than Couch. Of course that can change, but I see Mongo a better fit.

Leave a comment