Wednesday, 30 September 2009

Build CouchDB on Ubuntu 9.10 (Karmic Koala)

Ubuntu 9.10 includes CouchDB in the standard desktop installation ... perhaps that's all you need?

Personally, I like to track CouchDB trunk but building on the latest Ubuntu is not quite as easy as it used to be. The following is mostly from memory so may not be quite right ...

The list of packages in the CouchDB README to compile from source does not work (at least, not for me). Instead, ensure your apt sources are up to date and install the following packages:

$ sudo apt-get install build-essential erlang-nox erlang-dev libicu-dev xulrunner-dev libcurl4-openssl-dev

Next, configure CouchDB to use xulrunner's headers and libraries, using a custom LD_RUN_PATH:

$ LD_RUN_PATH=/usr/lib/xulrunner- ./configure --with-js-lib=/usr/lib/xulrunner-devel- --with-js-include=/usr/lib/xulrunner-devel-

And then make with the same LD_RUN_PATH:

$ LD_RUN_PATH=/usr/lib/xulrunner- make

Finally, make install CouchDB as usual and you're ok to start the CouchDB server.

Note that if Ubuntu's standard CouchDB package is also installed you may need to avoid your install clashing with it. Edit your install's etc/couchdb/local.ini and set port in the httpd section to something different. I use 15984 but it doesn't really matter as long as it's unique.

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

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

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).