6

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?

4
  • why don't you code it in php if you are using it already? Commented Aug 9, 2011 at 8:35
  • Can not find a out box solution to export Restful API in PHP. Commented Aug 9, 2011 at 8:41
  • 1
    Express has the advantage of asynchronous I/O. For database I/O it's better for performance. Commented Aug 9, 2011 at 18:47
  • I think you can use nodejs because it has more basic advantages like javascript object and json are easily convertible. Sometimes no need to parse result of rest api separately. Commented Aug 10, 2017 at 13:06

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

This result doesn't seem to be realistic. Look at mrjoes.github.com/2011/12/15/sockjs-bench.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.