GetHostByAddress runs slow

G

Guest

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.
 
B

bruce barker

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)



| 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.
|
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top