1.I just want to know which name server will be chosen to handle DNS query, Randomly or Orderly?
That depends on both how the authoritative name server for your domain is configured to respond, as well as on how your resolver deals with equivalent records.
In Bind DNS that is governed by means of the
rrset-order which defaults to cyclic/round-robin. Round-robin seems to be the default for other name-servers as well.
Rounnd-Robin is not actually random, with each subsequent request the name server will move the top record to the bottom of the stack:
- request #01 will be ordered NS1, NS2 , NS3, NS4
- request #02 will be ordered NS2 ,NS3, NS4, NS1
- request #03 will be ordered NS3, NS4, NS1, NS2
- request #04 will be ordered NS4, NS1, NS2 , NS3
- request #05 will again be ordered NS1, NS2 , NS3, NS4
- request #06 will be ordered the same as request #2 : NS2 ,NS3, NS4, NS1
- request #07 will be ordered the same request #3 etc. etc.
Since you don't know how many requests the name server has responded to between two subsequent requests by yourself the effect of round-robin may appear non-deterministic to you.
2.Is it possible that the name server is chosen based on the location of the client IP address?
Fairly typical for the better DNS hosting providers is to have the ip-addresses of authoritative name servers configured with anycast which simplified allows the same ip-address to be hosted in multiple geographic locations.
Routing protocols will then direct the DNS request from the client to the "nearest" name server, but that distance is measured in network routes, not actual geographic distance...
Once the client request has reached the nearest name server by means of anycast, then the name server may be configured with a geo-ip database and return different results (a different ip-address for for instance www.example.com.) based on the actual geographic location associated with the client ip-address.
3.If a DNS query was sent to ns3.example.com, but this name server did not respond within a certain period, what to do next? Will this DNS query be sent to another name server?