Node.js response time >= 200ms?
-
28-10-2019 - |
문제
I am working on a Node.js workload test and I have just encountered an interesting behavior. The minimum response time of an HTTP server is 200 ms, even for simplest logic:
var http = require("http");
http.createServer(function(request, response) {
response.write("Hello World");
response.end();
}).listen(8080);
Ran on Windows Server 2003:
> node main.js
I searched the web, but have not found any information about this. The test is done on local network, furthermore with the use of other webserver (namely IIS) I can achieve instant response time. Don't get me wrong, I see rational explanation behind this behavior, so this is my question:
Is this the default behavior coming with node.js, or could it be the result of something else?
Clarification on demand:
- Node js version: 0.6.11
- OS: Windows Server 2003 R2 SP2
- Server environment: VMWare Workstation 8.0.0
- Workload utility: jMeter 2.6 (1 thread workload)
Update
The delay behavior only appear during remote requests. If a local workload test is executed, the latency will be close to zero. However, it cannot be a network latency issue, because a remote request against IIS on the same server does not give latency. I am going to try this out on other OSes.
해결책
It is Nagle algorithm set by default on Windows (reproducible also on Windows 2008 R2 on Azure).
Workaround - disable it on response socket, like this:
response.connection.setNoDelay(true);
다른 팁
Getting 5ms latency, 3ms download for a total of 8ms here. It varies but the highest I've seen is about 14ms total.
Ran on OS X 10.7.3 though. I will have to try on Windows and see.
I'm running Ubuntu 64bit and node version 0.6.10 and at most I get a 20ms delay. I believe it is a windows problem, since Node is still not perfect on windows, have to wait for some more stability. I suggest you to post your problems to the mailing list.