From 3d1bdc254c5a8edd081e2186f3ae2fb1211b7c2e Mon Sep 17 00:00:00 2001 From: rickyes Date: Thu, 28 May 2020 23:15:55 +0800 Subject: [PATCH] http: add maxTotalSockets to agent class Add maxTotalSockets to determine how many sockets an agent can open. Unlike maxSockets, The maxTotalSockets does not count by per origin. PR-URL: https://github.com/nodejs/node/pull/33617 Backport-PR-URL: https://github.com/nodejs/node/pull/35396 Fixes: https://github.com/nodejs/node/issues/31942 Reviewed-By: Robert Nagy Reviewed-By: Matteo Collina Reviewed-By: James M Snell --- doc/api/http.md | 10 ++ lib/_http_agent.js | 58 ++++++++- .../test-http-agent-maxtotalsockets.js | 113 ++++++++++++++++++ 3 files changed, 177 insertions(+), 4 deletions(-) create mode 100644 test/parallel/test-http-agent-maxtotalsockets.js diff --git a/doc/api/http.md b/doc/api/http.md index d7e8c4caa852f1..88949e697f7b83 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -285,6 +285,16 @@ added: v0.3.6 By default set to `Infinity`. Determines how many concurrent sockets the agent can have open per origin. Origin is the returned value of [`agent.getName()`][]. +### `agent.maxTotalSockets` + + +* {number} + +By default set to `Infinity`. Determines how many concurrent sockets the agent +can have open. Unlike `maxSockets`, this parameter applies across all origins. + ### `agent.requests`