none
HttpWebRequest keepalive and dns load balancing RRS feed

  • Question

  • Good Afternoon.

    One of our primary ecommerce systems consists of an asp.net application which connects to several APIs.  As part of a blue-green deployment stategy,  we would like to use weighted dns load-balancing to route traffic to those apis.  Having set up a weighted dns record set in Amazon's Route 53 with a short ttl, repeated querying using nslookup shows that address switching between the supplied ip addresses. When using HTTPWebRequest to access those apis, if the keepalive flag is set, the presentation layer continues connecting to the same ip address, rather than re-looking the api's ip address up after the TTL for the dns record expires.  

    Setting HttpWebRequest.KeepAlive to false results in the desired behaviour (subsequent connections are re-resolved and change to a different endpoint once the dns ttl expires).  However this results in higher CPU usage on the clients and the server (assumedly as a result of the tcp re-negotiation).

    Is there a middle ground between the two extremes, where the duration of the keepalive can be specified on either the client or server to force a re-lookup and reconnection after a certain period of time?

    Monday, June 30, 2014 12:17 PM

Answers

All replies

  • Hi Tony,

    I assume you have many assets on the page need to be downloaded. It’s recommend to use browser cache to reduce requests. See more from http://www.mobify.com/blog/beginners-guide-to-http-cache-headers/.

    By the way, here is a book talking about web site performance. Maybe you will interest in it. http://www.apress.com/9781430243380.

    Hope useful.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, July 1, 2014 3:34 AM
    Moderator
  • Good Afternoon, Herro.

    As we're using HTTPWebRequest  to access a set of apis, the browser cache isn't relevant to this topic.  The calls are single http calls to the There are no additional resources to retrieve, as these are simple HTTPWebRequest calls.

    Example code to demonstrate what we're doing here:


        

        var request = WebRequest.Create(url) as HttpWebRequest;
        request.KeepAlive = false;


          using (var response = WebRequest.Create(url).GetResponse())
          {

    // logic to use the response here.

          }


    Tuesday, July 1, 2014 3:59 PM
  • Hi Tony,

    When I am working about this problem, I find an article about HttpWebRequest performance. Someone found that set proxy property of HttpWebRequest object to null will make it works faster. See more information from http://stackoverflow.com/questions/2519655/httpwebrequest-is-extremely-slow. You can have a try.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, July 3, 2014 8:49 AM
    Moderator