Twisted(asynch server) vs Django(or any other framework)

fanar picture fanar · Sep 11, 2009 · Viewed 11.5k times · Source

I need help understanding what the advantage of using an asynch framework is. Suppose I want to develop a simple chat web app. Why cant I write python code in the Django framework that does long polling where I dont send a response back the server until someone enters a new msg. What does Twisted provide that gives it an advantage for real-time apps like the chat app?

Sorry I am obviously little confused about the need for an asynchronous framework.

Answer

stonemetal picture stonemetal · Sep 11, 2009

First off Django is a framework for writing web apps so it provides ORM, html templating, it requires running an http server etc. Twisted helps to write much lower level code than that. You could use twisted to write the http server Django runs on. If you use Django you are limited to http model, with twisted it could be communicating in any protocol you like including push protocols. So for your chat example you get a server that scales better since it can push comments to people who have logged in VS with django every client having to poll repeatedly.

edited to reflect comments by: sos-skyl