Twisted.web vs Tornado Performance, part deux
apparatusproject.org
apparatusproject.org
If you have any kind of long-running task to perform during a web request, you have to roll your own way of dealing with that task.
To make it worse, the demos included with tornado that make use of a relational database do all their queries in blocking fashion, which would render the server completely unusable during the runtime of every single query.
Given the fact that Twisted provides a robust API for dealing with long-running algorithms, as well as support for a huge number of other protocols, you're paying an awful lot for only slightly better performance.
In fact, in a real-world application, the performance benefit of Tornado is directly impacted by how good you are at dealing with asynchronicity.
Glyph made a really good point, tornado comes with zero automated tests... Ultimately after conducting these tests and listening to the discussion that has taken place, I am personally glad that we're writing our code with twisted.web
* Mean response time -- Twisted.Web better than Tornado
Average performances for Concurrent request: * @100 -- TW:Tor::0.50s:0.70s . TW better than Tor
* @500 -- TW:TOr:: 3s:3.5s . TW slightly better than Tor
* @1000 -- TW:Tor:: 5s:6.5s . TW better than Tor* Where are you getting your estimates from? The numbers on the spreadsheet in the article do not match your rounded summaries.
* Twisted is faster at the same proportions for all the concurrent request numbers. Your summary makes it sounds like it's only slightly better at 500, but significantly better at all other request numbers. In fact, it's about 120% faster across the board.
Since yours is the top rated comment, I think you should ensure that it's accurate.
Ignore this "benchmark", the author simply doesn't have a remote clue what he is doing.
500ms Mean Response Time at 100 concurrent requests, are you kidding? Did you run the "benchmark" over a 56k modem?
For the record, one would expect sub-100ms response times under that load, even on modest hardware.
The test was run on two VMs on the Rackspace cloud using the public IP addresses.
Big deal -- there are now two ways (at least) to accomplish the same outcome in Python. Competition is good. I'm guessing that this will be a call to arms for the Twisted community and we'll see development accelerate.
At the same time, it is likely that a development community will form around Tornado. Great!
It's like people saying, when the Mac OS first launched, "Why didn't they just use DOS --it's there and it works." And yet the Mac OS has had a positive impact on operating systems produced by Microsoft. And Microsoft has impacted the Mac OS. It's all good.
And why is it that this same argument doesn't occur every time a non-async framework appears for python or other languages? What is it about the async nature that polarizes people? Maybe it's the fact that the both also start with the letter "T" and the name "Tornado" is a better named than "Twisted" (which implies increased complexity even if it isn't there...of course Tornados ultimately make a mess of things, so that's not it).
I, personally, am excited about Tornado. I think there's room for more than one player -- especially given the 'real time' direction the web is heading. And if this negatively impacts Twisted, then it'll be because Tornado has come up with an easier to understand approach and they'll benefit from being new and easy to grok -- in the same way Rails was once an easy-to-grok framework and that's what made it easy to understand.
The biggest winner, in my opinion, is the Python community and who doesn't want that?
They still use virtual machines, which give you all kinds of invisible overhead.
Even if that were not the case you should definitely split the machine that does the tests off from the machine that is being tested otherwise you get contention between the test program and the programs being tested (and java being quite cpu intensive running both tests on the same physical box is not a good idea).
For instance, in the graphs that are in the report you can see a bunch of drops to '0' traffic, these suggest serious problems with the software under test. But knowing that the tests were done in a VM environment it is possible that the cause of these drops is not in the software under test but with the VM, or alternatively, with other software running on the host the VM is running on.
That makes it very difficult to assign meaning to all this.
If you test software you do it in an environment that controls all the variables as much as possible otherwise the results will not help you in making decisions.
If people run software 'in the cloud' then that's a different story altogether, then you test the same software side-by-side on your bare machine vs your 'in the cloud' setup and you benchmark those.
This test is labelled 'twister vs tornado', not 'twister in the cloud' vs 'tornado in the cloud'.
Do you honestly expect anyone to believe that when test after test is run on a VM, and one framework consistently outperforms another, that this is due to the VM, and not the frameworks themselves?
I mean, I think I get your point, in that this benchmark doesn't apply to those running bare metal... but isn't the obvious counterpoint that this is an especially useful benchmark for those running in a VM?
Or are you sure that the machines these virtual machines were running on were otherwise completely idle ?
And if they were idle then why bother with the virtual machines, then you could have just run your tests directly bypassing the whole VM overhead.
#1. because it's what Bret from Friendfeed used in his testing #2. it tests the core framework code, anything more is testing code I write.
As I understand, you can run web.py apps behind lighttpd, and the web server handles the processes. E.g. in lighttpd.cfg you can set {"max-procs" => 4} and I would see 4 instances of my web.py script running. But how is this done for a web-server done 100% in python? Python uses a GIL that only allows one thread to interpret bytecode at a time, so despite the amazing performance of Twisted and Tornado, wouldn't we see this seriously degrade when the server had to anything more than 'hello world'? My worry is having a Twisted/Tornado app and only using 1/4th of my availble processing power: am I wrong to do so?
Twisted and Tornado are epoll/kqueue/etc-based and do not use threads.
Here's a good article on the differences between strategies: http://www.kegel.com/c10k.html
The sweet spot to measure is between a response time of 0s to 1s. After that, you need to be looking at getting more servers, anyways.
A better benchmark would start by swapping the axes of the graph and asking the question: "how many users can I support while keeping response time acceptably low?"