Friday, 18 September 2009

Tornado ... first thoughts

It's quite amusing to see the furore that's surrounded Tornado's release, especially how it compares to Twisted.

I like Twisted a lot although I'm far from a fan boy. Deferreds are not ideal but without proper coroutines (stackless, greenlet, etc) or message dispatch (see Erlang) in the core language they're a reasonable way to model async processes.

Anyway, a colleague asked me about my opinion on Tornado the day it was released. I'd only looked at it very briefly by then (scanned the docs and scanned the code) but I'm never short on opinion ;-).

So, mostly for posterity (there are far more in-depth posts elsewhere), below is my response almost verbatim. I'm sure to be wrong about some points, and I have no problem admitting that, but I've since seen comments that confirm at least some.

Only had a quick look at Tornado yesterday; I intend to look more
closely sometime. However, a few thoughts did spring to mind ...

Simple web page looks nice and simple ... as it should.

Can't get too excited about the url dispatch and request handler.
Nothing new to see, afaict.

Performance is quite impressive but I was surprised that 4 cores
wasn't even close to 4x the performance of a single core. Probably
something else limiting it but not very clear from the chart.

No Twisted performance comparison? I suspect Tornado is a little
faster but then it's much more focussed on what it's trying to
support.

Tornado's a callback-style framework. However, they don't seem to
bother handling errors (at least not in any consistent way). I think
that's a really bad idea. Sure, Twisted's Deferred is not ideal but I
think it's necessary. Sure, they could add an errback to every
function too ... but they don't seem to have bothered yet so they're
going to end up with an inconsistent way of reporting errors at best.
(The iostream module, for instance, appears to silently dump errors).

Their database module sucks big time. As far as I can see it blocks.
What good is that in an async framework!? It's MySQL only. Also ...
autocommit(True) ... argh!!!!

There's absolutely nothing in the docs about how to call those pesky
blocking libraries, you know like the entire Python stdlib or MySQL,
and there's no threading support afaict.

template library ... hohum.

locale support ... "Loads translations from CSV files in a directory"
... enough said.

OK, too many negatives so far ...

auth module looks very cool. i'd love to be able to support all those
out-of-the-box.

web "UI modules". looks interesting, need to take a closer look.

XSRF. nice, and now I know how to handle it without sessions ... use a
cookie instead, duh!

static file serving ... i like the automatic far-future expires + file
version. i've been meaning to write something to do that for a while
now only I was going to use the file's timestamp instead of the
content hash (much better).

2 comments:

Anonymous said...

typo: s/Torndao/Tornado/;

Matt Goodall said...

Oops, fixed. Thanks Anonymous.