Gevent: the Good, the Bad, the Ugly
code.mixpanel.com
code.mixpanel.com
If you want to use non-blocking in Python then using something like Twisted is an option since Twisted implements most things in an non-blocking way, but Twisted hasn't really gained that much traction in the many years of its existence.
So yes if you do a hello world benchmark then you get a 4x speed improvement, but if you do any library calls (such as doing a MySQL query) you will get decreased perfomance since the MySQL Python library is blocking (and most other libraries are blocking as well)...
There's also a mysql driver for gevent implemented as an extension: http://github.com/mthurlin/gevent-MySQL
A while back we avoided gevent because of this but used eventlet instead because they had a native MySQL patched driver.
Performance on the pure connector was just too bad.
Have you tried gevent-MySQL? It's written in Cython and as far as I know is fast.
Because it's using event's it has not blocking IO. But is limited when the tasks are CPU bound
If database database access is taking more than a second, then I recommend fixing that problem first.
Things like rate limiting (gevent can monkey patch time.sleep), error handling, and scaling to a large number of concurrent connections (see gevent.pool.Pool) have been added to my app with surprisingly little increase in code complexity. The fact that you write your code as if it was synchronous makes it so much easier to maintain. I don't have to find my way through callback spaghetti. I also find asynchronous much easier to grok than threading (and it's also more lightweight)
Paste is generally not recommended outside of development purposes.
"There are lots of ways of deploying an application, one of which is to use the paster serve command which takes the configuration file that has already been used to setup the application and serves it on a local HTTP server for production use."
Gevent uses the http server built into libevent, which is written in C, so it's no surprise that it is fast.
Eventlet (the project that Gevent forked from) allows you to write hubs while gevent only supports the libevent hub. So I made http://github.com/vishnevskiy/greentornado to allow Eventlet to run on Tornado's IOLoop. Been working for a while in production with no issues.
Would have made it for gevent though if I could since after reading the code of gevent and Eventlet I found that gevent's code base was much cleaner.
The Tornado people recommend running more instances of the application than CPUs to handle the short blocking requests to local databases and what not.
Although it depends on what your app does, my guess is that typical applications written with this philosophy are mostly synchronous code.
That being said we still use synchronous calls to our databases.