node-modules / agentkeepalive

Support keepalive http agent.
MIT License
579 stars 57 forks source link

Timeout issue #13

Open cthackers opened 9 years ago

cthackers commented 9 years ago

Hi, I have some issues with this library and the number of connections it creates. I don't know exactly if the library is the problem or my configs but I was doing a simple test with

{
    maxSockets: 5,
    maxFreeSockets: 5, 
    keepAliveMsecs: 100
    .....
} 

then do 100 requests with some small random time intervals between them. The result i get is something like this and doesn't seem to add up

{
    .....
    keepAliveMsecs: 100,
    keepAlive: true,
    maxSockets: 5,
    maxFreeSockets: 5,
    maxKeepAliveRequests: 0,
    createSocketCount: 18,
    timeoutSocketCount: 4,
    requestFinishedCount: 100 
}

If only 4 sockets timed out why did it create 18 ? Shouldn't have been 9 there ? The initial 5 sockets and the additional 4 that were replaced because they timed out. Btw, the numbers vary on every run. What am I missing here ?

fengmk2 commented 9 years ago

keepAliveMsecs:100 meaning a free socket not active for 100ms it will close.

cthackers commented 9 years ago

Yes, unless there is activity on it so it doesn't time out. So only 4 sockets timed out, and if they needed to be recreated, a maxim of 9 sockets should have been created in total, or anywhere between 5 and 9 if some of those 4 timed out sockets expired and the end of the test and had nothing left in queue. So why 18 ?

fengmk2 commented 9 years ago

can you show me the closeSocketCount and requestCount values?

cthackers commented 9 years ago

I don't have such values in the result. I use version 0.2.3.

cthackers commented 9 years ago

also i get an error like this (node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit. the stack trace indicates _http_agent.js:214:10 and agent.js:107:20

cthackers commented 9 years ago

and for HTTPS connections, it uses the certificate files as keys in the getName function. The application i use this in, has one 50KB certificate file with all the certificates. The log increased to 1.5 GB in less than a minute. Why in the world you would use the content of the certificates and keys as the key to the map ?

fengmk2 commented 9 years ago

can you show me your demo codes, node version and agentkeepalive version, I want to repeat what your meaning.

DesignByOnyx commented 9 years ago

I too would like to run this library through some perf tests. I know this thread is a little stale, but @fengmk2 can you post the scripts, versions, etc you used for testing?