Skip to content

Commit 6230e94

Browse files
committed
http: updated http agent documentation
Added scheduling http agent option.
1 parent fd4dd0a commit 6230e94

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

doc/api/http.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ http.get({
110110
### `new Agent([options])`
111111
<!-- YAML
112112
added: v0.3.4
113+
changes:
114+
- version: REPLACEME
115+
pr-url: https://github.com/nodejs/node/pull/33278
116+
description: Add `scheduling` option to specify the free socket
117+
scheduling strategy.
113118
-->
114119

115120
* `options` {Object} Set of configurable options to set on the agent.
@@ -132,6 +137,18 @@ added: v0.3.4
132137
* `maxFreeSockets` {number} Maximum number of sockets to leave open
133138
in a free state. Only relevant if `keepAlive` is set to `true`.
134139
**Default:** `256`.
140+
* `scheduling` {string} Scheduling strategy to apply when picking
141+
the next free socket to use. It can be `'fifo'` or `'lifo'`.
142+
The main difference between the two scheduling strategies is that `'lifo'`
143+
selects the most recently used socket, while `'fifo'` selects
144+
the least recently used socket.
145+
In case of a low rate of request per second, the `'lifo'` scheduling
146+
will lower the risk of picking a socket that might have been closed
147+
by the server due to inactivity.
148+
In case of a high rate of request per second,
149+
the `'fifo'` scheduling will maximize the number of open sockets,
150+
while the `'lifo'` scheduling will keep it as low as possible.
151+
**Default:** `'fifo'`.
135152
* `timeout` {number} Socket timeout in milliseconds.
136153
This will set the timeout when the socket is created.
137154

0 commit comments

Comments
 (0)