cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Delay of 180ms seen between requests when using HTTPS

From: Andre Guibert de Bruet <andy_at_siliconlandmark.com>
Date: Tue, 24 Jul 2007 15:04:51 -0400

On Jul 24, 2007, at 2:42 PM, David Lobron wrote:

> I've written an application that does many HTTPS downloads in
> succession. I am finding that the application takes about 180ms to
> perform one of the operations, even over a very well-connected
> local network. I looked at the logs on the server side, and found
> that it takes only 2 or 3 ms to fulfill the GET, which makes me
> suspect that the delay is on the client end when it connects to the
> server.
>
> I call curl_easy_init() once on startup, and then set most of my
> options. The only option that I set when preparing the next call
> to curl_easy_perform is curl_easy_setopt for CURLOPT_URL. My
> question is whether the call to curl_easy_setopt to set CURLOPT_URL
> could be causing a delay, such as another HTTPS handshake (I
> suspect that curl re-uses the same connection and thus only one
> handshake is performed, but I wasn't completely sure). Please let
> me know if there are any other factors that could be causing the
> delay.

cURL tries to use the same connection, if possible. Running a network
trace (Using Wireshark or a similar utility) will give you the answer
for your particular case.

There are a lot of things going on in the HTTPS case: Besides the
initial SSL handshake and cypher negotiation, there are at least two
DNS requests occurring for each connection that is made. The
following options will reduce the initial connection latency at the
expense of a little bit of security:

     curl_easy_setopt ( (CURL*)www, CURLOPT_SSL_VERIFYHOST, 0);
     curl_easy_setopt ( (CURL*)www, CURLOPT_SSL_VERIFYPEER, 0);

Cheers,
Andy

/* Andre Guibert de Bruet * 436f 6465 2070 6f65 742e 2042 6974 206a */
/* Code poet / Sysadmin * 6f63 6b65 792e 2053 7973 4164 6d69 6e2e */
/* GSM: +1 734 846 8758 * 2055 4e49 5820 736c 6575 7468 2e00 0000 */
/* WWW: siliconlandmark.com * C/C++, Java, Perl, PHP, SQL, XHTML, XML */
Received on 2007-07-24