19 comments

[ 3.6 ms ] story [ 63.7 ms ] thread
Congrats!

I've been using Tornado for over a year now and am impressed with how active Ben has been in improving it. I'm especially happy with the addition of this simple but important feature: "Template errors now generate better stack traces."

Tornado has definitely taught me to keep my templates as dumb as possible. Most of the time my errors are me trying to access values that doesnt exist
Can anyone here speak to Tornado.websocket? What's the performance like? How could you load balance with torando.websocket? Is it production ready?

Congrats on the release!

Few people seem to use it directly. Most people are writing production systems with the Tornadio2 wrapper (https://github.com/MrJoes/tornadio2) or sockjs-tornado (https://github.com/MrJoes/sockjs-tornado)

Load balancing is usually done with HAProxy I hear.

I will second this. I originally deployed chatfor.us with tornadio and then moved to sockjs-tornado and found both extremely easy to implement. I use ha proxy for that app. Unscatter.com doesn't use web sockets and I use nginx as the proxy load balancer for it.
I'm currently creating a product using the Tornadio2 wrapper. The developer Serge is actively developing, and is very helpful.

HAProxy is often used for load balancing websockets as it supports tcp proxies.

There is a tcp module for nginx that can be compiled in at https://github.com/yaoweibin/nginx_tcp_proxy_module

SockJS-tornado can be hosted via HAProxy. If you don't need native websockets, sockjs will work behind any sticky-sessions-aware loadbalancer using comet fallbacks.
Once I wrote a server that speaks the Redis protocol using Tornado's TCP networking tools. It was probably the nicest API for asynchronous networking without coroutines that I have ever seen.
For the folks out there using Tornado in production, what database (if any) are you using it with? Are you using an async interface to your database (assuming one is available)?
I use MongoDB and to do that I use MongoKit. Works really well. I also use Redis for the caching (note: not as a database)

For both Mongo and Redis I use the sync libraries. So far, I don't have any slow queries that would require me to async them.

MongoDB with asyncmongo
I use mongodb with bit.ly's asyncmongo.

I honestly was a bit frustrated with it from a development standpoint because of all the callbacks. Just felt like spaghetti code. Since I have started applying tornado.gen its been pretty effective.

Asyncmongo may not fit all use cases though. As I understand it it can be difficult to deal with paging potentially based off of what I have read in the issues on the github repo. Also last I checked it doesn't support tailable cursors.

One thing to note is that with friendfeed they did synchronous requests to MySQL and their thought was you should make sure the requests responses are quick enough that blocking is not an issue. After working hard to do asynchronous requests I'm now of the opinion I should have taken their word for it.

Before the Twisted/Tornado bridge existed, I made a rest-api for my DB in Twisted. There are a bunch of good async DB clients implemented for Twisted Python. It also made for good MVC separation.
I benchmarked pymongo vs. asyncmongo and found no performance gain (or even negative gain) with the latter unless making relatively heavy/slow queries. So, the asynch spaghetti is not worth of it in most cases, just like the authors experienced with MySQL.
Wow, I'm really impressed with Tornado. I'm learning node.js at the moment, but I've been working with Python/Django as well, so I will definitely consider this for my project.

Any benchmarks between node.js and Tornado btw ?