GetHostByAddress runs slow

Discussion in 'ASP .Net' started by =?Utf-8?B?SmVk?=, Dec 15, 2004.

  1. I have a class for logging information about user activity on a web site, but
    it suddenly became really slow. I was wondering what factors may have
    caused the slow down.

    Initially, I used the following code:
    ul.HostName = context.Request.UserHostName;

    Since the UserHostName is not always resolved, I opted for the following
    more effective code:
    IPAddress hostIPAddress = IPAddress.Parse(context.Request.UserHostAddress);
    IPHostEntry hostInfo = Dns.GetHostByAddress(hostIPAddress);
    ul.HostName = hostInfo.HostName;
    hostInfo = null;
    hostIPAddress = null;

    This worked fine for months, but now it is seriously dragging down
    performance. Is there something my web host could do to fix this problem?

    Thanks.
    =?Utf-8?B?SmVk?=, Dec 15, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?SmVk?=

    bruce barker Guest

    GetHostByAddress can be really slow if the address is not managed by the
    local DNS server. if it is not a local address the dns server ask the same
    question of any other DNS authority it knows about, which in turn does the
    same, until the ipaddress is found, or the timeout occurs.


    -- bruce (sqlwork.com)



    "Jed" <> wrote in message
    news:...
    | I have a class for logging information about user activity on a web site,
    but
    | it suddenly became really slow. I was wondering what factors may have
    | caused the slow down.
    |
    | Initially, I used the following code:
    | ul.HostName = context.Request.UserHostName;
    |
    | Since the UserHostName is not always resolved, I opted for the following
    | more effective code:
    | IPAddress hostIPAddress =
    IPAddress.Parse(context.Request.UserHostAddress);
    | IPHostEntry hostInfo = Dns.GetHostByAddress(hostIPAddress);
    | ul.HostName = hostInfo.HostName;
    | hostInfo = null;
    | hostIPAddress = null;
    |
    | This worked fine for months, but now it is seriously dragging down
    | performance. Is there something my web host could do to fix this problem?
    |
    | Thanks.
    |
    bruce barker, Dec 15, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sven
    Replies:
    5
    Views:
    3,239
    Rutger Smit
    Sep 3, 2004
  2. Mikey
    Replies:
    7
    Views:
    799
    Mikey
    Dec 12, 2003
  3. Beemer Biker
    Replies:
    2
    Views:
    384
    Beemer Biker
    Nov 8, 2006
  4. Joe Stateson
    Replies:
    2
    Views:
    449
    Joe Stateson
    Sep 10, 2007
  5. Nicopilami
    Replies:
    1
    Views:
    2,528
    bruce barker
    Apr 2, 2008
Loading...

Share This Page