-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why node.js server takes longer for each new set of requests #1179
Comments
Reproducible with this small code, in MAC. Tested in Linux, AIX and Windows, and did not observe this behavior. @ORESoftware - can you confirm you are on Mac to make sure we are attacking the same issue? const h = require('http');
h.createServer((q, s) => {
s.end('g')
}).listen(6969, () => {
const now = Date.now()
let count = 0
function foo() {
if(count++ === 5000) {
process.stdout.write(`time in millis: ${Date.now() - now}\n`)
process.exit(0)
}
h.get('http://localhost:6969', foo)
}
foo()
}) Remarkable difference in the profile is: good (total ticks:7150):
bad (total ticks: 10537):
#find /usr/include/ | xargs grep "___channel_get_opt" 2> /dev/null Looks like this is an opaque darwin kernel routine. No documentation available. None of the TCP system calls seem to carry the burden / reflect the delay - probably the connect and accept being non-blocking, are not spending visible time while The latency increases only if tested back-to-back (lot of pileups in the I don't have an inference or recommendation. /cc @nodejs/performance @bnoordhuis |
Performance benchmarking on macos is a waste of time. If it reproduces on linux or windows, I'd be interested to see it. |
Why (if you'll excuse my curiosity)? |
Apple's kernel team spends very little effort on making things fast. That's at least the impression I get from reading the xnu sources. |
Unfortunate, but also been reported before too |
yeah I am on MacOS...I can try it on my Ubuntu machine and see if I get the same thing, but haven't done that yet. The behavior seems consistent tho..It seemed strange to me that after all requests were done, it would have 0 requests. And then 1 second later, it would get a new set of 5000 requests (no more than 15 at a time), and take longer. |
@ORESoftware - were you able to make any observations in Linux? |
not yet but I will try it in a week |
@ORESoftware - let me know if anything is outstanding on this. |
let me try this on my linux machine right now |
ping @ORESoftware - were you able to validate in Linux? |
oh yes, give me another day, will test this tomorrow, I still haven't got to this but will have time tomorrow |
I don't know if it helps, but I can reproduce the let intervalLimit = 100
let runCount = 0
const intervalId = setInterval(() => {
if (runCount++ > intervalLimit) {
clearInterval(intervalId)
return
}
}, 0) Profile Output
|
Ok, pretty convinced this is just Anyhoot, in a performance run with about ~2000 ticks the two outputs are as follows:
Btw, ran the same script above on Ubuntu 14 and got a similar picture but with No idea what a 'solution' would like.. if any exists. |
@kingnebby - thanks for pitching in. However, I am not convinced on your theory around mine is here (MAC):
Though this is little slower than Linux overall,the values are consistent across runs, and there is no cascading effect of the previous run on the next run - that was the originally reported problem. |
@gireeshpunathil Indeed- I don't know how it would impact the original issue. Stumbled across If it doesn't help solve the original issue then feel free to ignore it :) |
Working on finally replicating the problem on linux...give me 10 mins |
Finally got to this, sorry it took so long. I created a project that can run this test: You can run: npm install -g @oresoftware/node.perf then: $ node_perf_server
$ node_perf_test
$ node_perf_test
$ node_perf_test
# ...
$ node_perf_test etc. On linux, each time the test is run, the time required goes down slightly over time. On MacOS it goes up a ton over time. Weird. |
This regards Node.js versions 9+
I have a simple Node.js Express server running, I issued this command history:
round 1:
round 2:
I am just curious what the explanation is for the server taking more time, even after finishing all requests. For example, I run
perf.test.js
, it finishes all requests. Then I manually run the same command again, about 1 or 2 seconds after the previous finished. Yet the response time still increases. We also see a big increase upon the fourth command.The express server is like so:
the test code is like so:
The text was updated successfully, but these errors were encountered: