Django and database replication

18 Mar 2009

Out of interest on how well you can scale with Django, I look a little time today to understand MySQL replication and how that might work with Django.

Doing this I found a nice Django database layer that works with a MySQL master and a MySQL replica – reads will go to the replica, and writes to the master. They’ve got a nice set of interfaces so you can either let a middleware layer guess which database to use (e.g., GETs go to the replica, and POSTs go to the master, assuming a typical REST style system), there are decorators if you want to tag specific views, or you can mark individual blocks of code if you want. Seemed very painless to set up, and seems to work rather well – as a test I deployed a version of our main Django app at work using this within a few minutes of having configured my MySQL system.