Title: High cpu usage for outbound ssl requests after upgrading from v16.15.0 to v18.1.0 · Issue #43128 · nodejs/node · GitHub
Open Graph Title: High cpu usage for outbound ssl requests after upgrading from v16.15.0 to v18.1.0 · Issue #43128 · nodejs/node
X Title: High cpu usage for outbound ssl requests after upgrading from v16.15.0 to v18.1.0 · Issue #43128 · nodejs/node
Description: Version v18.1.0 Platform Linux 5.17.4-arch1-1 #1 SMP PREEMPT Wed, 20 Apr 2022 18:29:28 +0000 x86_64 GNU/Linux Subsystem crypto What steps will reproduce the bug? I have observed this problem in few http clients: axios, got. But looks lik...
Open Graph Description: Version v18.1.0 Platform Linux 5.17.4-arch1-1 #1 SMP PREEMPT Wed, 20 Apr 2022 18:29:28 +0000 x86_64 GNU/Linux Subsystem crypto What steps will reproduce the bug? I have observed this problem in few...
X Description: Version v18.1.0 Platform Linux 5.17.4-arch1-1 #1 SMP PREEMPT Wed, 20 Apr 2022 18:29:28 +0000 x86_64 GNU/Linux Subsystem crypto What steps will reproduce the bug? I have observed this problem in few...
Opengraph URL: https://github.com/nodejs/node/issues/43128
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"High cpu usage for outbound ssl requests after upgrading from v16.15.0 to v18.1.0","articleBody":"### Version\n\nv18.1.0\n\n### Platform\n\nLinux 5.17.4-arch1-1 #1 SMP PREEMPT Wed, 20 Apr 2022 18:29:28 +0000 x86_64 GNU/Linux\n\n### Subsystem\n\ncrypto\n\n### What steps will reproduce the bug?\n\nI have observed this problem in few http clients: axios, got. But looks like a problem is in node.js itself. \r\n\r\n1. Create a basic http server which produces outbound ssl requests and returns in response result of outbound request. Here is a sample\r\n```js\r\nconst http = require(\"http\");\r\nconst https = require(\"https\");\r\n\r\nconst port = 3000;\r\n\r\nconst handler = (req, res) =\u003e {\r\n https.get(\"https://server.local\", (response) =\u003e {\r\n let body = \"\";\r\n\r\n response.on('data', chunk =\u003e {\r\n body += chunk;\r\n });\r\n\r\n response.on(\"end\", () =\u003e {\r\n res.statusCode = response.statusCode;\r\n res.setHeader('Content-Type', 'text/plain');\r\n res.end(body);\r\n });\r\n });\r\n};\r\n\r\nconst server = http.createServer(handler);\r\n\r\nserver.listen(port);\r\n```\r\n2. Start to produce load to server. I'm using `hey`\r\n```\r\nhey -z 1m -c 10 -disable-keepalive \"http://client.local:3000\"\r\n```\r\n3. Observe in CPU profiler for node.js server constantly increasing cpu usage for `SecureContext.init()`. It starts from ~50% and going up to 80%. Amount of requests processed by server, which sends outbound https requests is constantly decreasing.\n\n### How often does it reproduce? Is there a required condition?\n\nAlways reproduces if present outbound ssl requests and node version 18.1.0\n\n### What is the expected behavior?\n\nConstant CPU usage, amount of processed requests is at the same level during time. In node.js v16.15.0 same code in CPU profiler have `SecureContext.init()` with usage of 5-8%. And during load there is no performance degradation.\n\n### What do you see instead?\n\nCPU usage is keeping increasing during time, `SecureContext.init()` starts from ~50% cpu time in profiler and keep growing during time to 80-85%. Amount of requests processed by server is constantly decreasing.\r\n\n\n### Additional information\n\nv18.1.0\r\nBenchmark result - 186 req/s\r\nnode --perf output - https://pastebin.com/wyHPXfMH\r\ncpu profile screenshot\r\n\r\n\r\nv16.15.0\r\nBenchmark result - 1184 req/s\r\nnode --perf output - https://pastebin.com/0L0Z01iq\r\ncpu profile screenshot\r\n\r\n\r\n","author":{"url":"https://github.com/str1ke","@type":"Person","name":"str1ke"},"datePublished":"2022-05-17T17:55:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":18},"url":"https://github.com/43128/node/issues/43128"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c4e827af-1455-9e4b-2181-78bfc314b05a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C520:A06EB:1A4CB27:264ED67:6A4E5990 |
| html-safe-nonce | 36dbbc58ad1d71bf99da6aae691b13aa5ac8409eb3fd1cc338cd39a9019ee207 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNTIwOkEwNkVCOjFBNENCMjc6MjY0RUQ2Nzo2QTRFNTk5MCIsInZpc2l0b3JfaWQiOiI1ODA3MjQ0MDk4OTU2ODQzNDA4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | bb334a6fd14669fd39be125450d27f1d97524a0bf9945f9f8d123eacab6db566 |
| hovercard-subject-tag | issue:1238977726 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/43128/issue_layout |
| twitter:image | https://opengraph.githubassets.com/328a5ba9ad968d3f0fc7799f809e93e45f594a3717a9a8c2d098516d46811256/nodejs/node/issues/43128 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/328a5ba9ad968d3f0fc7799f809e93e45f594a3717a9a8c2d098516d46811256/nodejs/node/issues/43128 |
| og:image:alt | Version v18.1.0 Platform Linux 5.17.4-arch1-1 #1 SMP PREEMPT Wed, 20 Apr 2022 18:29:28 +0000 x86_64 GNU/Linux Subsystem crypto What steps will reproduce the bug? I have observed this problem in few... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | str1ke |
| hostname | github.com |
| expected-hostname | github.com |
| None | 030096ee0db095447bfe77409d33bfac127ca7128299c58deef27c52eaa1b1f0 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 55abf6b50233e48592f2087d3226df604c65feb9 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width