Yesterday, I wrote about node.js being fast. Here are some numbers. I ran Apache Benchmark on the simplest Hello World program possible, testing 10,000 requests with 100 concurrent connections (ab -n 10000 -c 100
). These are on my Dell E5400, with lots of application running, so take them with a pinch of salt.
PHP5 on Apache 2.2.6<?php echo “Hello world” ?> |
1,550/sec | Base case. But this isn’t too bad |
Tornado/Python See Tornadoweb example |
1,900/sec | Over 20% faster |
Static HTML on Apache 2.2.6Hello world |
2,250/sec | Another 20% faster |
Static HTML on nginx 0.9.0Hello world |
2,400/sec | 6% faster |
node.js 0.4.1 See nodejs.org example |
2,500/sec | Faster than a static file on nginx! |
I was definitely NOT expecting this result… but it looks like serving a static file with node.js could be faster than nginx. This might explain why Markup.io is exposing node.js directly, without an nginx or varnish proxy.
Nginx has to read the file from the disk each time.
Nodejs has the content of the file in memory.
So it’s normal that nodejs is faster than Nginx. Re-test the same thing but setup Nginx so it caches files in RAM and you’ll see the truth.
Please, use “return 200 ‘Hello world’;” for nginx instead of serving file from hard drive.