cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: How to limit Persistent Physical connctions via curl( easy handles are shared by multiple threads)

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 27 Dec 2011 23:10:05 +0100 (CET)

On Mon, 26 Dec 2011, $ag_at_r Takawane wrote:

> In my C application, there are 400 threads, I have kept global pool of easy
> handles to send requests to multiple servers, lets say 10 easy handles for
> requesting one server

...

> I am using these 10 handles to send requests to a single server from all 400
> threads (after adding it to multi handle, doing multi_perform) Each thread
> has its own multi handle.

Wait. What? Since you cannot share easy nor multi handles between threads
(running in parallel), and as you have 400 multi handles you cannot use less
than 400 easy handles if you want them all to do something at all times.

> but in netsta i am seeing around 400(less than 400) physical connection
> established with the server whereas i am expect 10 connection at max.

Are you adding easy handles to 400 multi handles and yet expect only 10 of
them to do anything?

> Are the threads are keeping a local context of physical connections..

Multi handles can limit the amount of physical connections, but first and
formost you should not add more easy handles to the multi handles than you're
prepared to see used as physical connections. Then, setting MAXCONNECT will
help you keep the number of idle connections low when they're not actively
used by a handle.

Quite possibly I've misunderstood what you meant...

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2011-12-27