News for hackers. Stuff that matters.
Re:Understanding the code inside Tornado, the asynchronous w... by cdavid on Saturday May 07, 2011 @04:31PM (#2524485)
Another issue with evented frameworks in python is that you have to ensure nothing is blocking anywhere in your code, which becomes harder the more complex your application becomes. People will often mention IO, database, etc... forgetting that it is also an issue if your request handler takes CPU for N ms (e.g. encoding a relatively large payload in json, etc...). everything needs to be written with async in mind.

Languages/frameworks where async IO is an implementation detail (like some web frameworks in haskell) don't have this issue.

Re:Understanding the code inside Tornado, the asynchronous w... by ankrgyl on Sunday May 08, 2011 @06:54PM (#2526906)
I don't think of this as a problem. Tornado is just a small and lightweight non-blocking HTTP server with a couple of convenient libraries. There are some pretty awesome, elegant solutions to the problem you point out, and I like to think of these as extensions to the small Tornado framework.

One really cool one is http://thomas.pelletier.im/2010/08/websocket-tornado-redis/, which demonstrates how to use threading to support Redis pub/sub.

For heavy computational tasks that aren't time-critical, you could have an accessory worker thread that chugs queued computations (yay first-class functions) in computational downtime.

Re:Understanding the code inside Tornado, the asynchronous w... by ntoshev on Sunday May 08, 2011 @02:32AM (#2525383)
Tornado devs recommend using blocking mysql drivers and disk I/O. These operations have relatively low and predictable latencies. You can run more Tornado processes than the number of cores is if CPU is underutilized.