.Net network layer have DNS caching flaw?

  • Thread starter Thread starter Chichi Paparucci
  • Start date Start date
C

Chichi Paparucci

We have an asp.net app that makes an http request call to
a server by dns name (there are 3 vips associated with
this dns name). For some reason, all our calls are
resolving to only one of the VIPs. Running an nslookup
command shows all 3 IP address of the 3 VIPs (in
different orders on each call); this confirms that DNS is
not favoring any of these addresses; it was clearly doing
a round-robin. We tried setting the TTL value to 1/0 but
this did not work; most calls were still going to the one
vip. Running "ipconfig/dnsflush" did not work either.
If dns is not the problem, then can .net be the issue?

The code leaves the dns resolution to the .NET Framework
network layer (the ServicePoint class). We don't
explicitly do anything to those objects. Is it possible
that this resolves the IP address and caches it?
 
As a test, set the TTL on all the records in your set to 0. Then clear the
cache on the server (dnscmd /clearcache) and on the client (ipconfig
/flushdns). Now rerun your test and see it that shows it using Round robin.
The issue is the client resolver cache. Round robin only works when you
make a query to the dns server, if the records are cached locally (for their
TTL period) then your not hitting the DNS server each time and the .NET DNS
method is just returning the IPs from cache in the order they where placed
there. Your client should, however, get a new order after the cache expires
for the records. This does not mean they *will get a different order. Your
client could get the same order back depending on how many people hit the
DNS server before you. This is one reason why round robin is not a load
balancer, but can only "help" spread the load given many clients from
*different locations (i.e. not the same network or ISP.) If you want to
manually change the order in your asp app, get the IPs using .net's DNS
class and order the IPAddress[] however you want. I would not cache that
array, but reload it each time an IP is needed as IPs do change. Can your
http request method take an IP instead of a name?
 
The request method can take an IP, but we don't want to
code to an IP (for obvious reasons). Since 80% of our
requests are hitting this one IP, it sounds like our only
choice is to manually rotate the order in code?

Is there a way to validate where each request's getting
the IP from - the dns server or cache? Even with TTL set
to 0, it still hung on the one IP.

I'll follow up with you on our findings from your
suggestion.

ChiChi
-----Original Message-----
As a test, set the TTL on all the records in your set to 0. Then clear the
cache on the server (dnscmd /clearcache) and on the client (ipconfig
/flushdns). Now rerun your test and see it that shows it using Round robin.
The issue is the client resolver cache. Round robin only works when you
make a query to the dns server, if the records are cached locally (for their
TTL period) then your not hitting the DNS server each time and the .NET DNS
method is just returning the IPs from cache in the order they where placed
there. Your client should, however, get a new order after the cache expires
for the records. This does not mean they *will get a different order. Your
client could get the same order back depending on how many people hit the
DNS server before you. This is one reason why round robin is not a load
balancer, but can only "help" spread the load given many clients from
*different locations (i.e. not the same network or ISP.) If you want to
manually change the order in your asp app, get the IPs using .net's DNS
class and order the IPAddress[] however you want. I would not cache that
array, but reload it each time an IP is needed as IPs do change. Can your
http request method take an IP instead of a name?

--
William Stacey, DNS MVP

Chichi Paparucci said:
We have an asp.net app that makes an http request call to
a server by dns name (there are 3 vips associated with
this dns name). For some reason, all our calls are
resolving to only one of the VIPs. Running an nslookup
command shows all 3 IP address of the 3 VIPs (in
different orders on each call); this confirms that DNS is
not favoring any of these addresses; it was clearly doing
a round-robin. We tried setting the TTL value to 1/0 but
this did not work; most calls were still going to the one
vip. Running "ipconfig/dnsflush" did not work either.
If dns is not the problem, then can .net be the issue?

The code leaves the dns resolution to the .NET Framework
network layer (the ServicePoint class). We don't
explicitly do anything to those objects. Is it possible
that this resolves the IP address and caches it?


.
 
Back
Top