Extra network traffic using HTTPS for multiple REST calls

Jun 27, 2013 at 12:13 AM
I love Casablanca. It made the choice easy for me to decide to code in C++ over C# when the start-up time for a .NET program is not acceptable. Just out of curiosity I wanted to compare Casablanca in C++ to HttpWebRequest in C#.

When comparing the performance of Casablanca in to HttpWebRequest, I noticed about a 5 kilobyte increase in traffic per request call when communicating over HTTPS. I was using ProcessExplorer.exe to monitor the network traffic from each process. When trying to track down the cause, I noticed that I can reproduce the same behavior when calling WinHttp.open() before each REST request instead of calling WinHttp.open() only once for all REST requests. I can only suspect that the cause is the re-negotiation of certificates for https when open is being called instead of caching them for each request. For a single call this isn't much, but if you want to make a lot of them it adds up.

I have tried creating only one instance of web::http::client::http_client and making several REST requests but I still get the overhead.

Is there a proper way of using http_client to avoid the overhead?

Jul 3, 2013 at 10:09 PM
Thank you for reporting this issue.
I cannot think of a solution off the top of my head. We need to investigate this further. I will try to dig into this and get back to you in the next couple of days.

Jul 9, 2013 at 4:33 PM
Hi trollbyte

I tried this scenario, sending multiple POST requests (each with 2KB body) using the same http_client over HTTPS. Other than the initial handshake, I see only ~200 bytes of extra data being sent per request. (I am using Process Monitor here).
Below is the code I tried:
    http_client client(U("https://localhost:60008/"));
    for(int i = 0; i < 10; i++)
        http_response response = client.request(methods::POST, query_str, utility::conversions::to_string_t(body)).get();
        //Verify status code   
And I see that the amount of data sent is comparable with the .NET HttpWebRequest.

Let me understand the setup better:
  1. Is the HTTP server using any authentication scheme?
  2. Does the setup have any proxies?
  3. What is the content length (request body) being sent?
  4. Is the 5KB increase in traffic in the request or response?