{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/help/issues/1179","repository_url":"https://api.github.com/repos/nodejs/help","labels_url":"https://api.github.com/repos/nodejs/help/issues/1179/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/help/issues/1179/comments","events_url":"https://api.github.com/repos/nodejs/help/issues/1179/events","html_url":"https://github.com/nodejs/help/issues/1179","id":307817277,"node_id":"MDU6SXNzdWUzMDc4MTcyNzc=","number":1179,"title":"Why node.js server takes longer for each new set of requests","user":{"login":"ORESoftware","id":11139560,"node_id":"MDQ6VXNlcjExMTM5NTYw","avatar_url":"https://avatars1.githubusercontent.com/u/11139560?v=4","gravatar_id":"","url":"https://api.github.com/users/ORESoftware","html_url":"https://github.com/ORESoftware","followers_url":"https://api.github.com/users/ORESoftware/followers","following_url":"https://api.github.com/users/ORESoftware/following{/other_user}","gists_url":"https://api.github.com/users/ORESoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/ORESoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ORESoftware/subscriptions","organizations_url":"https://api.github.com/users/ORESoftware/orgs","repos_url":"https://api.github.com/users/ORESoftware/repos","events_url":"https://api.github.com/users/ORESoftware/events{/privacy}","received_events_url":"https://api.github.com/users/ORESoftware/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":15,"created_at":"2018-03-22T21:14:35Z","updated_at":"2018-06-23T08:53:52Z","closed_at":null,"author_association":"NONE","body":"This regards Node.js versions 9+\r\n\r\nI have a simple Node.js Express server running, I issued this command history:\r\n\r\nround 1:\r\n\r\n    $ node server.js\r\n\r\n    $ node /Users/alexamil/perf.test.js\r\n    passed in these millis: 3405\r\n    $ node /Users/alexamil/perf.test.js\r\n    passed in these millis: 4010\r\n    $ node /Users/alexamil/perf.test.js\r\n    passed in these millis: 5290\r\n    $ node /Users/alexamil/perf.test.js\r\n    passed in these millis: 21170\r\n\r\n\r\nround 2:\r\n   \r\n    $ node server.js\r\n\r\n    $ node /Users/alexamil/perf.test.js\r\n    passed in these millis: 4407\r\n    $ node /Users/alexamil/perf.test.js\r\n    passed in these millis: 4865\r\n    $ node /Users/alexamil/perf.test.js\r\n    passed in these millis: 4874\r\n    $ node /Users/alexamil/perf.test.js\r\n    passed in these millis: 20808\r\n\r\nI 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.\r\n\r\nThe express server is like so:\r\n\r\n```js\r\n'use strict';\r\n\r\nimport {ErrorRequestHandler} from \"express\";\r\nimport * as express from 'express';\r\nimport haven from 'domain-haven';\r\n\r\nconst app = express();\r\n\r\napp.use(function (req, res, next) {\r\n  req.havenData = JSON.parse(req.query.haven || '{}');\r\n  next();\r\n});\r\n\r\nif (process.env.use_haven === 'yes') {\r\n  console.log('using haven');\r\n  app.use(haven());\r\n}\r\n\r\n\r\napp.use(function(req,res,next){\r\n  res.json({success: true});\r\n});\r\n\r\napp.use(function (err, req, res, next) {\r\n  err && console.error(err.message || err);\r\n  if (!res.headersSent) {\r\n    setTimeout(function () {\r\n      if (!res.headersSent) {\r\n        res.json({error: 'hit final error middleware', value: err && err.stack || err || null})\r\n      }\r\n    }, 10);\r\n  }\r\n  \r\n});\r\n\r\napp.listen(6969, function () {\r\n  console.log('app is listening.');\r\n});\r\n\r\n```\r\n\r\nthe test code is like so:\r\n\r\n```js\r\nimport http = require('http');\r\nimport async = require('async');\r\nimport request = require('request');\r\nimport {HavenData} from \"./simple-server\";\r\nimport assert = require('assert');\r\nimport util = require('util');\r\n\r\nconst tasks = Array.apply(null, Array(5000)).map(function () {\r\n  return function (cb: Function) {\r\n    \r\n    const opts = {\r\n      json: true,\r\n      qs: {haven: null as any}\r\n    };\r\n    \r\n    request.get('http://localhost:6969', opts, function (err, resp, v) {\r\n      \r\n      if (err) {\r\n        return cb(err);\r\n      }\r\n      \r\n      cb(null);\r\n    });\r\n    \r\n  }\r\n});\r\n\r\nconst now = Date.now();\r\n\r\nasync.parallelLimit(tasks, 15, function (err) {\r\n  if (err) throw err;\r\n  console.log('passed in these millis:', Date.now() - now);\r\n});\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/nodejs/help/issues/comments/399654257","html_url":"https://github.com/nodejs/help/issues/1179#issuecomment-399654257","issue_url":"https://api.github.com/repos/nodejs/help/issues/1179","id":399654257,"node_id":"MDEyOklzc3VlQ29tbWVudDM5OTY1NDI1Nw==","user":{"login":"kingnebby","id":4193348,"node_id":"MDQ6VXNlcjQxOTMzNDg=","avatar_url":"https://avatars1.githubusercontent.com/u/4193348?v=4","gravatar_id":"","url":"https://api.github.com/users/kingnebby","html_url":"https://github.com/kingnebby","followers_url":"https://api.github.com/users/kingnebby/followers","following_url":"https://api.github.com/users/kingnebby/following{/other_user}","gists_url":"https://api.github.com/users/kingnebby/gists{/gist_id}","starred_url":"https://api.github.com/users/kingnebby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kingnebby/subscriptions","organizations_url":"https://api.github.com/users/kingnebby/orgs","repos_url":"https://api.github.com/users/kingnebby/repos","events_url":"https://api.github.com/users/kingnebby/events{/privacy}","received_events_url":"https://api.github.com/users/kingnebby/received_events","type":"User","site_admin":false},"created_at":"2018-06-23T08:53:52Z","updated_at":"2018-06-23T08:53:52Z","author_association":"NONE","body":"Indeed- I don't know how it would impact the *original* issue. Stumbled across `channel_get_opt` in my own performance tests and was just trying to understand what that business is and whether or not it would impact our different issues.\r\n\r\nIf it doesn't help solve the original issue then feel free to ignore it :)\r\n"}}
{"actor":{"display_login":"kingnebby"}}