Does Node.js perform badly on Windows, surely it can't be slower than apache for basic I/O

爷,独闯天下 提交于 2019-12-05 09:10:46

I can conclude through testing my own application on a Linux install on the same machine that it was infact VERY slow on Windows. I'm unsure as to whether that's my Windows install or ALL Windows installs.

The same application with no change was able to deal with 3500 request / second on Linux. Which is over 500% faster...

Please feel free to post here if you've had a similar experience to myself, i'd like to know if this is a Windows problem.

Benchmarking on the same machine, first booted into Linux, and then Windows.

Linux   GET             R/s 3534    3494    3568    3580    3528
        CLUSTER GET     R/s 11987   11565   11950   12042   12056
        GET DB INSERT   R/s 2251    2201    2167    2207    2132
        GET DB SELECT   R/s 2436    2512    2407    2457    2496

Windows GET             R/s 725     730     721     760     723
        CLUSTER GET     R/s 3072    3129    3421    2912    3203
        GET DB INSERT   R/s 611     623     605     632     610
        GET DB SELECT   R/s 672     691     701     698     682

I've found that node works really really slowly if you refer to it as "localhost", but very quickly if you refer to it by "127.0.0.1". I think the dns lookup on Windows is really what's slowing the requests down.

Is there anything which could have such an impact in reducing the number of requests per second?

I assume you're thinking that something is slowing down Node in your tests. There isn't. However, in tests to you link to at the end, there's something slowing Apache down.

You say you're testing Apache with a static file, but the benchmarks you link to, use a PHP file for the Apache test. Apache serving an uninterpreted file directly is about as close to metal as you can get. But add PHP, and you're adding a ton of overhead.

So for your test, it's Apache vs. Node and Apache wins, whereas in the one you linked to it's Apache + PHP vs. Node and Node wins.

Neither result surprises me much.

Do you realize that Apache uses multiple processes or threads to serve the requests, whereas there's a single Node.js process? Either configure Apache for a single worker process or thread, or run as many Node.js processes as you have CPU cores, and loadbalance among them.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!