Skip to content

Commit

Permalink
http: set lifo as the default scheduling strategy in Agent
Browse files Browse the repository at this point in the history
PR-URL: #36685
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Daijiro Wachi <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
mcollina authored and targos committed Apr 14, 2021
1 parent 866e324 commit f70aee0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ http.get({
<!-- YAML
added: v0.3.4
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/36685
description: Change the default scheduling from 'fifo' to 'lifo'.
- version: v14.5.0
pr-url: https://github.com/nodejs/node/pull/33617
description: Add `maxTotalSockets` option to agent constructor.
Expand Down Expand Up @@ -157,7 +160,7 @@ changes:
In case of a high rate of request per second,
the `'fifo'` scheduling will maximize the number of open sockets,
while the `'lifo'` scheduling will keep it as low as possible.
**Default:** `'fifo'`.
**Default:** `'lifo'`.
* `timeout` {number} Socket timeout in milliseconds.
This will set the timeout when the socket is created.

Expand Down
2 changes: 1 addition & 1 deletion lib/_http_agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function Agent(options) {
this.keepAlive = this.options.keepAlive || false;
this.maxSockets = this.options.maxSockets || Agent.defaultMaxSockets;
this.maxFreeSockets = this.options.maxFreeSockets || 256;
this.scheduling = this.options.scheduling || 'fifo';
this.scheduling = this.options.scheduling || 'lifo';
this.maxTotalSockets = this.options.maxTotalSockets;
this.totalSocketCount = 0;

Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-http-agent-scheduling.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ function defaultTest() {

bulkRequest(url, agent, (ports) => {
makeRequest(url, agent, (port) => {
assert.strictEqual(ports[0], port);
assert.strictEqual(ports[ports.length - 1], port);
makeRequest(url, agent, (port) => {
assert.strictEqual(ports[1], port);
assert.strictEqual(ports[ports.length - 1], port);
makeRequest(url, agent, (port) => {
assert.strictEqual(ports[2], port);
assert.strictEqual(ports[ports.length - 1], port);
server.close();
agent.destroy();
});
Expand Down

0 comments on commit f70aee0

Please sign in to comment.