Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable NAGLE for lower latency sockets. #114

Merged
merged 4 commits into from
May 12, 2017
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var Promise = require('bluebird')
var request = require('request')
var os = require('os')
var https = require('https')
var net = require('net')

var system = (process.platform === 'linux') ? require('./src/system.js') : require('./src/mockSystem.js')
var getCollectorUrl = require('./src/collector.js')
Expand All @@ -17,6 +18,17 @@ const httpsAgent = new https.Agent({
maxCachedSessions: 1,
keepAlive: true
});
httpsAgent.createConnection = function(options, callback) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading the Node source, this doesn't seem to be a solid replacement, at minimum parameter-wise, for createConnection: https://github.com/nodejs/node/blob/98e54b0bd4854bdb3e2949d1b6b20d6777fb7cde/lib/https.js#L75

/* noDelay is documented as defaulting to true, but docs lie.
this sacrifices throughput for latency and should be faster
for how we submit data. */
var socket = net.createConnection(options).noDelay(true)
if (callback) {
callback(undefined, socket)
return
}
return socket
}

// Default on module load; changed to false on first handler invocation.
var COLDSTART = true
Expand Down