It has officially been months since I’ve last updated this blog – and it’s a damn shame. In the past few months I’ve been very busy putting together Jively, and one of the first things that happened when we launched was that our servers borked and everything went black – thank you TechCrunch, thank you Digg.

The upshot though was that the site was fixed, and fixed fast – there’s nothing quite like an emergency to get things moving.

Here’s a few tips and pointers on how we managed to speed up load time / lower latency and increase overall efficiency of the code, most of these have little to do with coding itself, but utilising django’s inherent abilities better:

  1. Use memcached – I can’t stress this enough, get it up and running, get the daemon working and set it up as your cache back end in settings.py.
  2. Get rid of unnecessary look ups, cache as much as you can – Jively is a live site, however even the slightest cache delay can speed up your site tremendously – our public feed is delayed by only a few seconds, but for a very memory/resource intensive process this can ork out very well
  3. Don’t serve your media through the same server as your django app – if you can avoid it put your media onto a different system – I can suggest Google AppEngine (free) or Amazon S3 (paid for but negligible), this takes a massive load from apache, and will also allow the browser to open multiple connections to download your site in parallel instead of trying to open multiple connections to the same server
  4. Use gzip compression – there is a middleware module for this, it will ensure you send compressed data to the browser (for those that support it)
  5. Optimize your ugly code – if you have a lot of for loops and nesting going on with a lot of DB requests – get rid of them! Mind – this isn’t the place for code optimisation, but it definitely is best practice to avoiding crashes.

Happy coding!
M.