node.js和Tornado之间的区别 [英] Differences between node.js and Tornado

查看:339
本文介绍了node.js和Tornado之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除了node.js是用Python编写的JS和Tornado的事实,两者之间有什么区别呢?他们都是非阻塞异步Web服务器,对吧?为什么选择一个除了语言之外的另一个?

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?

推荐答案

node.js的主要优点是是非同步,因此您不必担心阻塞。有mysql,postgres,redis等异步库。默认情况下都是async。

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有一个库,但大多数库不是异步的。为了利用tornado(而不是阻止进程)特殊的库是必要的(例如,你不能只是'pip安装redis'并使用它,你将需要一些像brukva ),而且比node.js库少得多的龙卷风库。目前没有async mysql tornado驱动程序可用,例如(或至少我不知道它)。

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).

但你仍然可以使用许多python库与龙卷风(不执行i / o),龙卷风社区正在提高和填补空白。

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.

在我的经验中,使用node.js编写应用程序比使用tornado更容易。我个人从node.js切换到tornado,因为它适合我的python项目的现有基础设施(django站点提供html页面和提供实时功能的龙卷风服务器之间的集成是相当无痛)。

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).

这篇关于node.js和Tornado之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆