cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: SO_REUSEADDR and multi-threaded environment

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 2 Jul 2014 23:21:37 +0200 (CEST)

On Tue, 1 Jul 2014, Sachin Nikumbh wrote:

> I have a client application that's using libcurl to communicate with a
> proprietary server. I am testing the application in multi-threaded
> environment and how it scales with the number of threads.

I don't think this is really related to multi threading though, more like how
many parallell connections you try to use in how short time period.

> At around 30000 number of threads, some of the requests started failing
> with "Couldn't connect the server error" which I am assuming is happening
> because my application is failing to find any more ports to bind to.

That seems reasonable, yes. strace would of course tell you exactly which
syscall that fails.

> I decided to set the SO_REUSEADDR socket option in a hope to reuse the
> sockets in the TIME_WAIT state. Following is a snippet of my code that I
> wrote to set SO_REUSEADDR socket option:

...

> But the behavior of my application is not changing.

I'm not an expert on SO_REUSEADDR, but perhaps that's too late to set that
option?

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2014-07-02