Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I implement reverse AJAX in a Django application?

How should I implement reverse AJAX when building a chat application in Django? I've looked at Django-Orbited, and from my understanding, this puts a comet server in front of the HTTP server. This seems fine if I'm just running the Django development server, but how does this work when I start running the application from mod_wsgi? How does having the orbited server handling every request scale? Is this the correct approach?

I've looked at another approach (long polling) that seems like it would work, although I'm not sure what all would be involved. Would the client request a page that would live in its own thread, so as not to block the rest of the application? Would it even block? Wouldn't the script requested by the client have to continuously poll for information?

Which of the approaches is more proper? Which is more portable, scalable, sane, etc? Are there other good approaches to this (aside from the client polling for messages) that I have overlooked?

like image 329
Carson Myers Avatar asked May 13 '10 01:05

Carson Myers


2 Answers

How about using the awesome nginx push module?

like image 110
Steve Jalim Avatar answered Oct 08 '22 14:10

Steve Jalim


Have take a look at Tornado?

Using WSGI for comet/long-polling apps is not a good choice because don't support non-blocking requests.

like image 27
byterussian Avatar answered Oct 08 '22 14:10

byterussian