Tagged with django

Zend Framework vs. Django Performance

This is not a scientific nor rigorious test…  But, here’s some interesting data for people to chew on.  I’ve got a production site built using the Zend Framework and a beta site built using django.  What’s interesting is the “Time spent downloading a page” graphs from Google Webmaster Tools.

The Zend Framwork Graph — average speed is 458 ms with a min of 246 ms

wink_time

The django graph — you can see where I changed from CGI style to FCGI in the speed — average is 531, and a min is 81ms — though my eyeball average for the month of April is 100ms.

zapquiz_time1

The nice part is these graphs have the same scale, so it’s pretty clear that once I switched from CGI to FCGI (under lighttpd) that the django performance is 4x better than the ZF.

Tagged , ,

Cloud Databases are the Future

As I type this I’m sitting here watching MySQL shutdown after a bad up/down sequence and for the last five hours it’s been rebuiding it’s indexes… Fundamentally everything is down at this point, if it wasn’t for the backend services that are not tied to the database things would be ugly.

I’ve been preaching internally about cloud databases for the last few months and I’m totally convinced they’re the future. Why you ask? I only have a few requirements in my cloud database:

  • Distributed and replicated store
    I would like to make sure that I have N copies of any object and can support a read throughput of X across the store.
  • Opaque object identifiers — within a “tablespace”
    Every object should get a unique identifier on storage and the ability to reference it via a “key”, I don’t really care about  the ability to assign it.
  • Indexable fields
    This is where I can spec a primary key, I don’t want auto increment, since that’s just a crutch for uniquness… I’ve been happy to use things like:     base64.urlsafe_b64encode(uuid.uuid1().bytes).rstrip(‘=’)
  • Fast
    Well duh, hopefully this is accomplished with the replication and the ability to tune the replication.

What can do this?  Or, where should I be spending my time evaluating technologies?

  • CouchDB
  • MongoDB
  • Amazon S3
  • Some custom Lucene + Storage mechanism
  • Google Base
  • others?

Though once that is complete, I need to have something like django support.  If you spend any time with django and Google App Engine you see that it works but half the power of django is missing since the nice folks at google ripped the model layer out.  It would be really nice if one could have the benifit of one of the above stores and build a whole django model layer out to support it…

Tagged , ,

Frameworks and sessions

I hate sessions, they’re evil.

PHP is the worst offender since it’s built into the language and you end up with effective scalability limitations and turds in your temp file system. django isn’t much better since all of the cool admin functionality is built using the contrib.auth module which depends on sessions as well. Long ago in a galaxy far away I learned that such assumptions are bad, you should handle your authentication with some cookies that are totally independent of your application. Your sessions state should be passed around via posts or other URL tricks…

Don’t get me started today on the detail that django requires a “username” to authenticate. Half tempted to write the “uber auth” module which allows for both email registration and facebook/google connect, etc. authentication.

Tagged , ,

Set permission_required for your view functions

Working with django 1.0 and google app engine… Wanted to set every view on my admin page to have admin permission.

def _perm_admin(rootfunc)  :
    import sys
    module = sys.modules.get(rootfunc.__module__)
    for key, value in module.__dict__.items() :
        if type(value) is types.FunctionType and key[0] != '_' and rootfunc.__module__ == value.__module__:
            module.__dict__[key] = permission_required('admin')(value)

_perm_admin(main)
Tagged ,