cURL / Mailing Lists / curl-library / Single Mail

curl-library

How to scale libcurl to several thousand https connections without blocking select ()

From: Jimish Shah <jimishrshah_at_gmail.com>
Date: Mon, 6 Jun 2011 11:30:10 -0700

Hi,

I am trying to use libcurl to scale to several thousand https connections to
an external web server. I have downloaded and investigated the source code,
so i have a fair understanding of the function calls.

If i use multi-handle and add say 1000 easy handles to it. If each of the
thousand easy handles need to connect simultaneously , i noticed that there
is a blocking "select ()" during the connect phase as explained below.

Curl_multi_perform() --> multi_runsingle() --> Curl_connect() ....... -->
Singleipconnect --> waitconnect() --> Curl_socket_ready()* --> select ()* every
one second until error or success or timeout

In other words, although the socket itself is non-blocking, this function
call waits (multi_runsingle() loops until error or success) until the single
connect on one easy handle either succeeds or fails completely or times-out,
which makes it somewhat pipelined if the responding web-server is slow (in
which case we will repeatedly get EINPROGRESS on the socket). Also the other
999 easy handle connect are waiting till this one is done. Hence its
serialized in some manner.

Is there a way wherein libcurl allows to open all the 1000 connections using
some type of a event driven mechanism or some alternate to change the
connection state as and when they are successfull / fail.

Pls correct me if any of my understanding is incorrect. Also i went through
the mailer, but couldnt find something that answered my questions.

Pls let me know if i can clarify further. Thanks in advance for helping me
out.

~ Jimish

“Perseverance is not a long race; it is many short races one after the
other” - Walter Elliot

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