Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

REST API: nodejs vs python

Tags:

node.js

I want to make Restful API for current PHP application with mongodb backend database.

NodeJS (express) vs Python (web.py), which is better for performance?

like image 499
Bruce Dou Avatar asked Aug 09 '11 08:08

Bruce Dou


1 Answers

So I found some speed test article. It's written in Russian so you may not able to read this. But you can look at the code for examples.

Here simple test results and short translation of explanation:

Python, Tornado

ab -n 10 -c 10 http://127.0.0.1:8888/
Time taken for tests:   20.078 seconds

Node.js

ab -n 10 -c 10 http://127.0.0.1:8000/
Time taken for tests:   2.007 seconds

There is no description of testing computer but it's not so matter.

The reason why Node.js is faster is that it uses nonblocking event loop while Python's time.sleep is blocking.

Update 2021

Since Python has received asyncio, the benchmarks from the article aren't complete without tests of asyncio.

like image 142
Paul Rumkin Avatar answered Nov 10 '22 09:11

Paul Rumkin