Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

agentkeepalive

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

agentkeepalive - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

65

benchmark/proxy.js

@@ -17,2 +17,3 @@ /*!

var maxSockets = parseInt(process.argv[2], 10) || 10;
var SERVER = process.argv[3] || '127.0.0.1';

@@ -34,6 +35,25 @@ var agentKeepalive = new Agent({

var count = 0;
var rtKeepalives = {
'10ms': 0,
'15ms': 0,
'20ms': 0,
'30ms': 0,
'40ms': 0,
'50ms': 0,
'50ms+': 0
};
var rtNormals = {
'10ms': 0,
'15ms': 0,
'20ms': 0,
'30ms': 0,
'40ms': 0,
'50ms': 0,
'50ms+': 0
};
setInterval(function () {
var name = 'localhost:1984';
console.log('[proxy.js:%d] keepalive, %d created, %s requests, %s sockets, %s unusedSockets, %d timeout',
console.log('[proxy.js:%d] keepalive, %d created, %s requests, %s sockets, %s unusedSockets, %d timeout\n%j',
count,

@@ -44,9 +64,11 @@ agentKeepalive.createSocketCount,

agentKeepalive.unusedSockets[name] && agentKeepalive.unusedSockets[name].length || 0,
agentKeepalive.timeoutSocketCount
agentKeepalive.timeoutSocketCount,
rtKeepalives
);
console.log('[proxy.js:%d] normal , %d created, %s requests, %s sockets',
console.log('[proxy.js:%d] normal , %d created, %s requests, %s sockets\n%j',
count,
agentHttp.createSocketCount,
agentHttp.requests[name] && agentHttp.requests[name].length || 0,
agentHttp.sockets[name] && agentHttp.sockets[name].length || 0
agentHttp.sockets[name] && agentHttp.sockets[name].length || 0,
rtNormals
);

@@ -58,17 +80,43 @@ }, 2000);

var agent = agentHttp;
var method = 'GET';
var postData = null;
var rts = rtNormals;
if (path.indexOf('/post') === 0) {
path = path.substring(5);
method = 'POST';
postData = '{"sql":"select id from keepalive where age between 1 and 1000 and count between 1 and 100 order by id desc limit 2","data":null}';
}
if (path.indexOf('/k') === 0) {
path = path.substring(2);
agent = agentKeepalive;
agent = agentKeepalive;
rts = rtKeepalives;
}
var options = {
host: 'localhost',
host: SERVER,
port: 1984,
path: path,
method: 'GET',
method: method,
agent: agent
};
var timer = null;
var client = http.get(options, function (response) {
var start = Date.now();
var client = http.request(options, function (response) {
response.pipe(res);
response.once('end', function () {
var use = Date.now() - start;
if (use < 10) {
rts['10ms']++;
} else if (use < 15) {
rts['15ms']++;
} else if (use < 20) {
rts['20ms']++;
} else if (use < 30) {
rts['30ms']++;
} else if (use < 40) {
rts['40ms']++;
} else if (use < 50) {
rts['50ms']++;
} else {
rts['50ms+']++;
}
if (timer) {

@@ -91,2 +139,3 @@ clearTimeout(timer);

}, 2000);
client.end(postData);

@@ -93,0 +142,0 @@ }).listen(1985);

28

benchmark/sleep_server.js

@@ -17,14 +17,22 @@ /*!

http.createServer(function (req, res) {
var timeout = parseInt(req.url.substring(1), 10) || 1; // default 1ms
setTimeout(function () {
var result = {
timeout: timeout,
headers: req.headers
};
// count++;
// console.log(count + ' ' + req.url);
res.end(JSON.stringify(result));
}, timeout);
var size = 0;
var data = '';
req.on('data', function (chunk) {
size += chunk.length;
data += chunk;
});
req.on('end', function () {
var timeout = parseInt(req.url.substring(1), 10) || 1; // default 1ms
setTimeout(function () {
var result = {
timeout: timeout,
headers: req.headers,
size: size,
data: data
};
res.end(JSON.stringify(result));
}, timeout);
});
}).listen(1984);
console.log('sleep server start, listen on 1984');

@@ -102,2 +102,4 @@ /*!

});
// Disable Nagle's algorithm: http://blog.caustik.com/2012/04/08/scaling-node-js-to-100k-concurrent-connections/
s.setNoDelay(true);
}

@@ -104,0 +106,0 @@ this.createSocketCount++;

{
"name": "agentkeepalive",
"version": "0.1.0",
"version": "0.1.1",
"description": "Missing keepalive http.Agent",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc