Desinerd : Dipankar's Blog

Django : Optimizations within the platform

Published: in Technical, , , , , , , by .

In my experience with both rails and django, i would have to admit that a lot of things need to be improved at the core of these platforms so that developers can truly deploy a really fast production site. Let talk about what we did at kwippy to make it that much more faster than the default Django setup.

Well there are all i could think of right now. Obviously there are some other optimizations that i keep doing …. and will keep writing about. Till the next time, feel free to contact me about these optimizations at me@dipankar.name.

Comments

  • Hello,

    Nice post.

    Just one comment on the Pagination, ObjectPaginator exists for backwards compatibility and Paginator uses the existing queryset methods when building a page object so it shouldn’t be transfering all objects. Paginator uses slices and the QuerySet __getitem__ generates LIMIT SQL clauses.

  • Hmm, when i last was checking objectpaginator , it was transferring all the stuff … guess they have modifies paginator. In the recent upgrade of django for my site, i was lazy not to use paginator he he ….

  • Although i appreciate DJangos focus on simplicity, I would also second Dipankars point here.
    For any web application to be scalable the DB interface or the ORM has to be strong and simple.

    I cannot resist comparisions with Hibernate – which is a good ORM with easily adaptable, testable features which is something Hibernates ORM could possibly benchmark itself against.

    As far as pagination is concerned also I would raise a small point. Tapestry (another Java technology) has really good features in this sense. Another possible benchmarking tool.

  • @rohitj 😛 at least the database connection is initialized before hand ha ha …. truth is most ORMs are ok at basic stuff, anything non-trivial , bye bye ORM and in comes the SQL

  • I’m setting up an enterprise webhosting env for my company..
    Well my team usually works with j2ee stuff (for scalability & slowness ;-P ), but theres a small pool of webservers that still run on perl, cgi since like 2001… now we are thinking of offering python hosting..upgrading the OS & apache from 1.3 to 2.2X, & start using ldap authentication etc..

    I would love to get inputs from u… 🙂

  • Good advice on SMTP, connection pooling, and memcached sessions.

    It would be nice if you would edit the part about Paginator, since it is wrong and may mislead newer users.

  • about Database structuring, I see that a major improve on queries is to change the proper field type in the bd engine instead using the Django choices.

    For example in Mysql, in an status field that use choices. Faster queries are made if in the the bd change the varchar(140) type for ENUM(‘publish’, ‘spam’, ‘deleted’), even greater optimizations if you use ENUM or SET with an Integer Field, that’s also valid to use Small Integer type fields.

    You can see if you describe and analyze your table, that a lot of optimizations can be made. I recommend for mysql the describe and analize table action in phpmydamin, to know what would be this optimizations.

    Another great optimization, in python code. Is using the mx.DateTime module instead datetime module that is slower and consume a lot of ram on complex date comparing and calculus

    Regards

Leave a Reply

Your email address will not be published. Required fields are marked *