Differences between node.js and Tornado

Question:

Besides the fact that node.js is written in JS and Tornado in Python, what are some of the differences between the two? They’re both non-blocking asynchronous web servers, right? Why choose one over the other besides the language?

Asked By: coffee-grinder

||

Answers:

node.js uses V8 which compiles into assembly code, tornado doesn’t do that yet.

Other than that (which doesn’t actually seem to make much difference to the speed), it’s the ecosystem. Do you prefer the event model of JS, or the way Python works? Are you happier using Python or JS libraries?

Answered By: Rich Bradshaw

The main advantage of node.js is that all its libraries are async so you don’t have to worry much about blocking. There are async libraries for mysql, postgres, redis, etc. All is async by default.

Python have a library for anything – but most of these libraries are not asynchronous. In order to take advantage of tornado (and not to block the process) special libraries for are necessary (e.g. you can’t just ‘pip install redis’ and use it, you’ll need something like brukva), and there are much less tornado libraries than node.js libraries. There is no async mysql tornado driver available at the moment, for example (or at least I’m not aware of it).

But you can still use many python libraries with tornado (ones that doesn’t do i/o), and tornado community is raising and filling the gaps.

It is easier to write an app using node.js than using tornado in my experience. I personally switched to tornado from node.js because it fits into existing infrastructure of my python project better (integration between django site serving html pages and tornado server providing realtime features was quite painless).

Answered By: Mikhail Korobov

Nodejs also has a seamless integration / implementation of websockets called Socket.io. It handles browsers supporting sockets – events and also has backward polling compatibility for older browsers. It is quite quick on development requiring a notification framework or some similar event based programming.

Answered By: Sushant Khurana

As Rich Bradshaw points out Node.js is written in JS, which means you can keep the front end and the back end in the same language and possibly share some codebase. To me that is a huge potential benefit of Node.js.
Node also comes with more asynchronous libraries out of the box it seems.

V8 should make JS faster than Python at least that’s what benchmarks seem to suggest, but it may not matter much, because both Node.js and Tornado (and most other web frameworks for that matter) use wrappers for native libraries. A lot of the Python standard library is written in C or can be replaced by a faster alternative, which mitigates potential differences even more.

Web services are usually I/O bound, so that means we’re spending the time waiting for the data store and not processing the data. That makes the synthetic speed difference between JS and Python irrelevant in many applications.

Answered By: Morten Jensen

I would suggested you go with NodeJS, if there is no personal pref to python. I like Python a lot, but for async I choose Tornado over node, and later had to struggle finding way to do a thing, or libraries with async support (like Cassandra has async in tests, but nowhere could I find way to use cqlengine with async. Had to choose Mongo since I already surpassed the deadline).
In terms of performance and async, Node far better than tornado.

Answered By: Ravi Kumar