REST API: nodejs vs python
I want to make Restful API for current PHP application with mongodb backend database.
NodeJ开发者_如何学运维S (express) vs Python (web.py), which is better for performance?
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.
精彩评论