https://www.quora.com/What-are-some-advantages-of-using-Node-js-over-a-Flask-API

Flask is a Python web microframework. It needs to be run behind a WSGI compliant web server. The nature of WSGI is synchronous. So you'll usually spawn threads to serve requests. Python 'threads' is also blocking, due to the GIL, they cannot run in parallel. Thus reducing the number of requests you're able to be served. Spawning threads is also expensive.

NodeJS is not a framework, it's a JavaScript binding of libuv. I have a write up about it over here:

Under The Bonnet 1 - NodeJS - YKode

NodeJS is asynchronous by design. Which means that it's not blocking.  When you you do I/O it will return immediately and get notification later on. It's single threaded. It just means that you won't block the event loop when you wait for response, you can do another task including accepting incoming requests.  So even on single thread, you can accept and serve multiple requests. On synchronous environment, this I/O operation will block the thread.

The event driven and concurrent connections model of Node.js makes it one of the best platforms for real time applications like online games, collaboration tools, chat rooms, or anything where what one user (or robot? or sensor?) does with the application needs to be seen by other users immediately, without a page refresh.

As this answer on Stack Overflow says,

My feeling is that Node.js is especially suited for applications where you'd like to maintain a persistent connection from the browser back to the server. Using a technique known as "long-polling", you can write an application that sends updates to the user in real time. Doing long polling on many of the web's giants, like Ruby on Rails or Django, would create immense load on the server, because each active client eats up one server process. This situation amounts to a tarpit attack. When you use something like Node.js, the server has no need of maintaining separate threads for each open connection.

Although, there exist libraries in Python as well for doing this sort of work, Node.js does it really well (powered by cutting edge V8 JavaScript engine). However, if you are performing some heavy server side computation on receiving requests, then you are better off serving it with regular FLASK based server. (subjective comment)

What are some advantages of using Node.js over a Flask API?的更多相关文章

  1. 笔记-Node.js中的核心API之HTTP

    最近正在学习Node,在图书馆借了基本关于Node的书,同时在网上查阅资料,颇有收获,但是整体感觉对Node的理解还是停留在一个很模棱两可的状态.比如Node中的模块,平时练习就接触到那么几个,其他的 ...

  2. node.js学习二---------------------同步API和异步API的区别

    /** * node.js大部分api都有同步的方法,同步方法名后面都会带有Sync,js编译的时候,同步代码会立即执行,异步代码会先存到异步池中,等同步代码执行完后它才会执行异步:不会阻塞线程,没有 ...

  3. Node.js + Express + Knex 开发 API 接口

    安装依赖包 npm i express knex mysql2 这是 Knex 官方文档地址:Knex.js - SQL query builder. 搭建接口 config.js 新建一个 conf ...

  4. node.js调用google翻译api

    源码下载:https://pan.baidu.com/s/1nxoodst 使用:(只支持get) http://39.106.33.56:3001/translate?text=Failure is ...

  5. Node.js 事件循环

    Node.js 是单进程单线程应用程序,但是通过事件和回调支持并发,所以性能非常高. Node.js 的每一个 API 都是异步的,并作为一个独立线程运行,使用异步函数调用,并处理并发. Node.j ...

  6. Node.app – 用于 iOS App 开发的 Node.js 解释器

    Node.app 是用于 iOS 开发的 Node.js 解释器,它允许最大的代码重用和快速创新,占用资源很少,为您的移动应用程序提供 Node.js 兼容的 JavaScript API.你的客户甚 ...

  7. Node.js 学习(五)Node.js 事件循环

    Node.js 是单进程单线程应用程序,但是通过事件和回调支持并发,所以性能非常高. Node.js 的每一个 API 都是异步的,并作为一个独立线程运行,使用异步函数调用,并处理并发. Node.j ...

  8. 【Node.app】Node.js for iOS

    Node.app 是用于 iOS 开发的 Node.js 解释器,它允许最大的代码重用和快速创新,占用资源很少,为您的移动应用程序提供 Node.js 兼容的 JavaScript API.你的客户甚 ...

  9. 使用Node.js作为后台进行爬虫

    看了一遍又一遍Node.js但是没过多久就又忘了,总想找点东西来练练手,就发现B站首页搜索框旁边的GIF图特别有意思,想着是不是可以写一个小Node.js项目把这些图全部扒下来,于是带着复习.预习与探 ...

随机推荐

  1. 2019年,Python工程师必考的6个面试题,Python面试题No5

    第1题:Python里面如何实现tuple和list的转换? 函数tuple(seq)可以把所有可迭代的(iterable)序列转换成一个tuple, 元素不变,排序也不变 list转为tuple: ...

  2. SpringMVC中controller的跳转

    controller中的重定向 (1)不需要传递参数重定向 方式一:使用ModelAndView        return new ModelAndView("redirect:/toLi ...

  3. POJ 3522 Slim Span (Kruskal枚举最小边)

    题意: 求出最小生成树中最大边与最小边差距的最小值. 分析: 排序,枚举最小边, 用最小边构造最小生成树, 没法构造了就退出 #include <stdio.h> #include < ...

  4. Huffman codes

    05-树9 Huffman Codes(30 分) In 1953, David A. Huffman published his paper "A Method for the Const ...

  5. springMVC中处理静态资源的几种方案

    处理静态资源方案一:在web.xml文件中配置如下: <!-- <!–解决静态资源方案–> <servlet-mapping> <servlet-name>d ...

  6. shelve -- 用来持久化任意的Python对象

    这几天接触了Python中的shelve这个module,感觉比pickle用起来更简单一些,它也是一个用来持久化Python对象的简单工具.当我们写程序的时候如果不想用关系数据库那么重量级的东东去存 ...

  7. iframe in ipad safari

    http://developer.apple.com/library/safari/#documentation/appleapplications/reference/safariwebconten ...

  8. idea没有tomcatserver问题解决

    https://www.cnblogs.com/a8457013/p/7795987.html 在配置tomcate时有时候按照网上说的找不到tomcat Server,不知不觉花了很长时间这时我们在 ...

  9. Android滚动页面位置指示器:CircleIndicator

     Android滚动页面位置指示器:CircleIndicator CircleIndicator是github上的一个开源的用于页面滚动时候的位置指示器,指示当前页面在总的页面中的位置和前后位置 ...

  10. [Kubernetes]Volume

    容器技术使用rootfs机制和Mount Namespace,构建出一个同宿主机完全隔离开的文件系统环境 那容器里进程新建的文件,怎么样才能让宿主机获取到?宿主机上的文件和目录,怎么样才能让容器里的进 ...