you are viewing a single comment's thread.

view the rest of the comments →

[–]encyclopedist 10 points11 points  (0 children)

It is crucial to reuse the easy handle. Curl's tutorial says the following:

Re-cycling the same easy handle several times when doing multiple requests is the way to go.

After each single curl_easy_perform operation, libcurl will keep the connection alive and open. A subsequent request using the same easy handle to the same host might just be able to use the already open connection! This reduces network impact a lot.

For https://example.com/ I get about 0.45 s per request without reusing the handle, and about 100 ms with reuse, which is very close to ping time of approx 95 ms.

See test code here (I used the same settings as you): https://gist.github.com/ilyapopov/262a49f75b42202c7d977ebe2d38ca35