RE: Many CLOSE_WAIT when handling lots of URLs
Date: Thu, 20 Feb 2014 09:16:53 +0100 (CET)
On Thu, 20 Feb 2014, Shao, Shuchao wrote:
>> The CLOSE_WAIT connections are mostly (AFAIK) unfortunate side-effects of
>> us keeping connections alive after we're done using them, and while kept
>> like that they get closed from the other end.
> Many CLOSE_WAIT connections will impact the libcurl performance
> significantly. Every system has a limit for maximum number of open socket,
> the more CLOSE_WAIT connection will result in less ESTABLISHED connections.
If you reach the limit of open desrciptors, yes. That's still not a common
scenario and until you do, the CLOSE_WAIT connections will not in any
significant way hamper performance.
What MAXCONNECT value do you have now then, how many easy handles are you
adding and what are all those connections that end up in CLOSE_WAIT?
>> I'm thinking we can change the if() in ConnectionDone() to a while() instead
> Just changing if() to while() seems does not have a lot help.
It would of course only help for the case where you lower MAXCONNECTS in
run-time to a value that is less than the current cache size and you're not
doing that, are you?
> In my setup, Using libcurl-7.24.0, I can have about 20K ESTABLISHED
> connections, no CLOSE_WAIT connections. Using 7.35.0 (after changing if() to
> while()), the number will be 9K for ESTABLISHED and 11K for CLOSE_WAIT.
Are you adding 20K easy handles to the multi handle?
> I am wondering if we need to close the connections for a easy_handle when we
> removing it from a multi_handle?
Then they will be closed and will then avoid CLOSE_WAIT, but they will also
not be possible to re-use and you'll get a serious performance impact. You'll
get that effect if you set FORBID_REUSE on every connection.
I think the key to fixing this problem properly is to figure out why they end
up in that state.
-- / daniel.haxx.se ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.htmlReceived on 2014-02-20