Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Twisted.web vs Tornado, a Performance test (apparatusproject.org)
73 points by roder on Sept 11, 2009 | hide | past | favorite | 30 comments


ironically an article about web server performance just got hosed by HN.


Google Cache got it right before it melt down: http://74.125.77.132/search?q=cache%3Awww.apparatusproject.o...


It's back up.


up again sorry :)


So my first thought on this Tornado stuff was: why not glue twisted and tornado together? A quick look at the code suggests it is doable, and could help fix the "web mess" in twisted.

My second thought was: Why didn't they build this on libevent, and pyevent, which has a built-in non-blocking webserver which is pretty darned fast.


what 'web mess in twisted' are you referring to?


There are two web implementations, and neither are complete(eg, twisted.web does not support even http 1.1). Even the twisted developers will tell you they are not happy with the web code in twisted. twisted.web2 was the future and twisted.web was to be depreciated, now twisted.web is the future and twisted.web2 is to be depreciated... the mess is still being cleaned up.

Link to the twisted web page describing the situation and the plan: http://twistedmatrix.com/trac/wiki/TwistedWebPlan


that's just not true. i use web1 extensively, and it works very well, and although it's performance is not as good as apache or lighttpd when serving raw files, it's more than adequate for most web application development.

web2 was never a formally released product, and most of the stuff that was only available in web2 (such as wsgi support) have now been backported. there was some confusion about this for awhile, but that was only ever a community issue, not a code-related one.

i primarily took issue with you calling it a "mess", i still think that's a rather inaccurate statement.


Specifically, from the outside looking in, exactly what you described is(was?) a mess. Last I looked it was confusing as to what I should use, what would be supported in the future, who (web or web2) had what feature, and what even worked. That was quite a while a go (like over a year). More recently, talk at pycon suggested things had not improved much, but I haven't verified that. I am open to the possibility that things have improved since I last looked, particularly given the overall quality of twisted stuff.

I still wonder tho, if this would be good to graft into twisted?


there is one implementation of twisted.web... twisted.web2 is merged, and what is not in twisted.web and is in twisted.web2 will not be used or will be merged in the future, there is no mess, you should just use twisted.web.


As someone who tried using twisted.web just a few days ago I can add that yes, twisted.web seems reasonably complete but no, it is not a reasonable choice at this point for many reasons (mostly the common twisted reasons: callback hell and insufficient documentation).

Imho the most interesting part about Tornado is not Tornado itself but the question it rubs into the face of the twisted evangelists: "Why didn't they just use the real twisted instead of re-inventing it?".

This post suggests that they have at least heard the question and, ofcourse, immediately snapped into their long-practiced denial position ("Thou shalt not question the twisted way, we haz performance!").

Only this time twisted does not outperform the newcomer, which should give them food for thought.


Would be interesting to see mochiweb and a few other things thrown in there (maybe nginx for raw throughput).



I think Tornado is awesome since the applications you write can be read by normal people.

While Twisted is powerful (and as the poster said, in the same magnitude of performance), it has a tough learning curve.

Even if Tornado isn't successful, I think it just pushed the bar on how an async web framework can be written. I look forward to seeing other frameworks evolve as a response (I'm looking at you sinatra!).


I am shocked, SHOCKED I say, that nobody has brought up FapWS3 -> http://github.com/william-os4y/fapws3 , which runs about twice as fast for a "hello world" bench as Tornado, and wraps libevent for the async socket handling. As an added bonus, fapws3 can handle wsgi apps, django, etc...


I find twisted relatively easy to work with. There's no particular reason tornado can't sit atop twisted. Hopefully I'll get some time to do that this weekend.

The whole tornado vs. twisted thing is unfortunate, though. It exists in its current state because tornado is two different things: 1) a web framework 2) an async network stack.

#2 exists in core python and in twisted. If we transplant #1 to twisted, then it should be just as easy to develop web apps on twisted, except you get a whole lot of stuff for free.


If we transplant #1 to twisted, then it should be just as easy to develop web apps on twisted, except you get a whole lot of stuff for free.

That would be... beyond awesome.


FYI, I've pushed up some code. Unfortunately, tornado has no tests, so I'm absolutely certain it's not completely functional, but it works as far as I'm able to test a few things on localhost.

http://github.com/dustin/tornado

I'd love some help, of course. :)


Glad you kicked this off.

I'm not deep enough in twisted myself to contribute but I see others have already joined in - awesome!


You don't have to be deep into twisted. You can just try to make an app with it, or run a demo or something and let me know what works/fails.

As Tornado has no unit tests, it's difficult to see what's right or wrong without a human actually doing the work.


The results are missing latency numbers for the concurrent requests, and there's no indication of the amount of work being done to handle a request, which will have a significant impact on load performance.

That said, performance testing Python web server implementations seems bit like racing snails. If speed is why you're using Python, you're probably using the wrong tool.


I wonder where standard Python's SimpleHttp server stands in there. I don't code Python much, but to me it seems that all these guys sit on top of Python's asyncore package, no?


Tornado has its own C wrapper around epoll ( http://github.com/facebook/tornado/blob/9e24ae162d024e4049b8... ), but falls back to select() if the wrapper can't be compiled.


It will also use Python 2.6's native epoll (see line 326 of http://github.com/facebook/tornado/blob/9a8bd2fb6fd6279be16d...)


Does this mean Python's own HTTPServer uses epoll starting v2.6?


No, not that I'm aware of. It simply means that Python 2.6 makes the epoll system call available directly without need for a custom module.


Both twisted and Tornado are very fun to work on and I think it is great they are focused on performance. This is nothing but good for web frameworks in Python.


I see He test Tornado in MacBookPro, i think mac os dont have epoll, and tornado use select(). so i think he will test it in linux (2.6).


The Deep Blue analogy is strained, now that Rybka 3 on a notebook computer will easily trounce the best human player in the world.


I've noticed some strange behavior with ab. Suggest testing with httperf as well.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: