

Web Application Development with Tornado - crad
http://crad.tumblr.com/post/351142148/web-application-development-with-tornado

======
enneff
> Because your tornado app runs as a stand-alone HTTP server that is directly
> coupled to your application classes, you need to run multiple processes to
> serve multiple requests.

Really? My understanding is that an async http server like Tornado should
service many requests with the same process. (This is the case with Twisted
and nginx, at least.) It should be a matter of writing your application in the
same async, callback-driven style. Or am I misunderstanding something?

~~~
crad
If your app is fully async, yes. Any blocking and you'll need another backend
to service a simultaneous request.

~~~
enneff
So why are you even using Tornado if you fork a separate process for each
simultaneous request? Doesn't that negate the benefits of an asynchronous http
server?

~~~
frognibble
Brett Taylor discusses this issue in his tech talk on Tornado
(<http://bret.appspot.com/entry/tornado-tech-talk>). He uses a hybrid
approach: Use synchronous programming when requests block for a short time
(fetching data from local db or memcache) and async programming when something
blocks for a long time (calling out to third party services, long polling
requests).

He does not go all async because programming with callbacks or deferreds is
more complicated than straight line synchronous programming.

Brett also mentions that the instances of the server are created once and
reused. He does not fork an instance of the server per request.

~~~
enneff
Twisted has a nice asynchronous db api
([http://twistedmatrix.com/documents/current/core/howto/rdbms....](http://twistedmatrix.com/documents/current/core/howto/rdbms.html))
that mitigates these concerns at the database level. More generally, I'd think
the cleanest approach is to write async wrappers for your synchronous code,
rather than forking an async server to service multiple requests. Otherwise
you miss out on a lot of benefits of an async architecture, IMO.

------
z8000
"There are changes in the master branch of Tornado on github to make Tornado
multi-threaded, spawning a thread per CPU core, but this will not change the
scaling concern and will complicate the equation a bit more"

Wrong. It forks.

[http://github.com/facebook/tornado/commit/6fb90ae694190fcedc...](http://github.com/facebook/tornado/commit/6fb90ae694190fcedc48d9fb98b02325826d783e)

~~~
crad
My bad.. I should have double checked my rusty memory of the commit.

------
martythemaniak
A pretty good overview of Tornado. I've been using it as a backend for a real-
time web game and from what I've seen so far, its pretty good. I especially
like how small and light-weight it is (which kinda lets them get away with
non-existent documentation)

------
japherwocky
Much love for tornado, though I ditched their templating for genshi. It also
works pretty good as a Cron sort of engine for polling/scraping.

