Skip to content

Commit dd1918d

Browse files
committed
[debug] Better debug messages to try to determine if pool is slowly losing clients to forever busy
1 parent 7c2eb5d commit dd1918d

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/node-http-proxy.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var sys = require('sys'),
3030
pool = require('./../vendor/pool/main'),
3131
eyes = require('eyes'),
3232
min = 0,
33-
max = 100;
33+
max = 10;
3434

3535
// Setup the PoolManager
3636
var manager = pool.createPoolManager();
@@ -146,7 +146,7 @@ HttpProxy.prototype = {
146146

147147
// Open new HTTP request to internal resource with will act as a reverse proxy pass
148148
var p = manager.getPool(port, server);
149-
sys.puts('current pool count for ' + req.headers.host + ":" + port + ' ' +p.clients.length);
149+
sys.puts('Current pool count for ' + req.headers.host + ":" + port + ' ' + p.clients.length + ', Busy: ' + p.getBusy() + ', Free: ' + p.getFree());
150150

151151
p.on('error', function (err) {
152152
// Remark: We should probably do something here

vendor/pool/main.js

+9
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ Pool.prototype.onFree = function (client) {
8484
if (this.pending.length > 0) this.pending.shift()(client);
8585
};
8686

87+
Pool.prototype.getFree = function () {
88+
return this.clients.filter(function (client) { return !client.busy }).length;
89+
};
90+
91+
Pool.prototype.getBusy = function () {
92+
return this.clients.filter(function (client) { return client.busy }).length;
93+
};
94+
8795
Pool.prototype.setMinClients = function (num) {
8896
this.minClients = num;
8997
if (this.clients.length < num) {
@@ -98,6 +106,7 @@ Pool.prototype.setMinClients = function (num) {
98106
Pool.prototype.setMaxClients = function (num) {
99107
this.maxClients = num;
100108
};
109+
101110
Pool.prototype.end = function () {
102111
this.clients.forEach(function (c) {c.end()});
103112
};

0 commit comments

Comments
 (0)