PyCon 2010: Alex Gaynor on Real Time Python Web Development
By Matthew Sacks
Alex Gaynor is a Python Web developer at Eldarion, co-host of the DjanjgoDose podcast, student at Rensselaer Polytechnic Institute, and a frequent contributor to the Django Project. Gaynor attended a PyCon two years ago and was immediately hooked, and been involved ever since. Last year he moderated a panel on object relational mappings (ORM’s) alongside Guido van Rossum, Mike Bayer, Jacob Kaplan-Moss, Ian Bikcing, and Massimo di Pierro.
Gaynor will be delivering a presentation on developing Real time Web applications. Gaynor’s presentation will feature three Web applications Gaynor has worked on and lessons learned therein: A Real time Web based chat application called LeafyChat, a live stream application developed for DjangoCon called DjangoDose, and the Hurricane Web framework.
Alex Gaynor Interview
What are the characteristics of a real-time Web application?
“Real-time web” is the kind of thing that sounds like the world’s biggest buzzword, but “real-time web” is an umbrella term for Comet/reverse-Ajax/HTTP push, which means instead of the client pulling data from the server, the server pushes data to the client. Of course to go along with the gaggle of names for the technique, there are just as many ways to do it. But the important detail is that you have some sort of persistent connection to the server (although generally this is somewhat faked, as the browser environment doesn’t give you the full tools to have a real persistent connection).
What are the design considerations that must be taken into account when developing a real-time Web application?
Coming from a typical web developer perspective (using some sort of WSGI framework like Django, TurboGears, whatever your favorite is) the biggest difference is that with those types of frameworks the idea is to get a request, computer some sort of response and send it back to the client as quickly as possible. With a comet application the idea is to get a request, and then leave it hanging around the server until you have some data to send back to the server. This is a major architectural change, and to accommodate it the most common thing to do is to use some sort of asynchronous server (like Twisted or Tornado). Asynchronous programming, in Python, is based around either generators or callback functions. This is a pretty different style of programming, and it definitely takes time to get used to.
How does Comet/Orbited benefit Python developers who want to develop real-time Web applications?
Orbited is a server that provides a pure Javascript/HTML socket in the browser, as well as a backend server that can proxy to any kind of backend you want to implement. Having a tool like Orbited, combined with the plethora of network and asynchronous libraries in the Python world means that Python programs don’t
have to do a lot of the low level work to get an environment where they can develop real-time applications.
You mention that the live stream you are launching at PyCon 2010 is based on Redis, a persistent key-value database. Why did you choose this key-value store to support live stream application?
Redis is different from a lot of other key-value stores in that it doesn’t just store binary blobs of data, it can store real data structures (like lists and sets). This means that Redis can be used as a queryable queue, with multiple buckets, which is exactly the tool I needed. The use case I had here is very similar to the one that Github had for their Resque queue, which is also based on Redis.
Why did you want to build a real-time Web application such as LeafyChat?
Honestly, originally I didn’t. LeafyChat was written for the DjangoDash. Originally I wanted to write a hosted ticketing system, but I couldn’t find a team for that. I was lucky enough to be invited to Leah Culver and Chris
Wanstrath’s team, and they were already planning to work on a web based IRC client. A web based IRC client isn’t much use if you’re going to have 30 second delays because you’re just polling the server, so into the world of the
real-time web I went. Similar for the DjangoDose live stream, *live* is the keyword, you need things to be real time. By this point I realized there were no well established frameworks, or great abstractions, and that since real-time
web apps are pretty cool, I wanted to be able to build them better and faster (the same reason anyone uses one of the many Python web frameworks).
Register for PyCon 2010 https://us.pycon.org/2010/register/
About Alex Gaynor
Alex’s PyCon ‘10 Presentation http://us.pycon.org/2010/conference/schedule/event/10/]
Alex Gaynor’s GitHub http://github.com/alex
Alex Gaynor’s Blog http://alexgaynor.net/
Further Reading
Orbited Real Time Communication for the Browser http://orbited.org/
Twisted An event-driven networking engine written in Python and MIT licensed. http://twistedmatrix.com/trac/
Redis An advanced key-value store http://code.google.com/p/redis/
Leave a Reply
You must be logged in to post a comment.

















February 26th, 2010 at 9:36 pm
[...] http://www.thebitsource.com/tech-conferences/pycon-real-time-python-web-development/ [...]