I understand that DNS resolves a URL name into an IP address, but I don’t understand how DNS comes up with ONE specific server’s IP address when some websites like Google have some data centers with more than 200,000 servers?
2 Answers
What you are describing is called Load Balancing DNS. There are different types of load balancers, the simplest is Round Robin load balancing. This link has a good explanation of Round Robin DNS. This method is often used when you have large loads and/or heavy traffic that one server and/or network cannot handle on its own.
Round-robin load balancing is one of the simplest methods for distributing client requests across a group of servers. Going down the list of servers in the group, the round-robin load balancer forwards a client request to each server in turn. When it reaches the end of the list, the load balancer loops back and goes down the list again (sends the next request to the first listed server, the one after that to the second server, and so on).
The main benefit of round-robin load balancing is that it is extremely simple to implement. However, it does not always result in the most accurate or efficient distribution of traffic, because many round-robin load balancers assume that all servers are the same: currently up, currently handling the same load, and with the same storage and computing capacity. The following variants to the round-robin algorithm take additional factors into account and can result in better load balancing:
Weighted round robin — A weight is assigned to each server based on criteria chosen by the site administrator; the most commonly used criterion is the server’s traffic-handling capacity. The higher the weight, the larger the proportion of client requests the server receives. If, for example, server A is assigned a weight of 3 and server B a weight of 1, the load balancer forwards 3 requests to server A for each 1 it sends to server B.
Dynamic round robin — A weight is assigned to each server dynamically, based on real-time data about the server’s current load and idle capacity.
There are other methods, but I think this should give you a decent understanding of what is going on under the hood.
It doesn't.
While our web browser might send multiple requests to an IP address, there's no guarantee that you're talking to the same server on each connection. In face, it is likely that you aren't. A single IP address can be routed to different hosts depending on where you are in the network topology. Anycasting is a popular way to advertise one IP address that routes to a multitude of servers depending on which server is "closer" on the network. Much simplified, border routers scattered over the network advertise that they can reach IP address A.B.C.D and your ISP routes your request to the closest router which then forward the request on to the host. The host behind that IP address will probably be a load balancer that hands out incoming requests to a farm of servers. Through network address translation the answers come back from the servers looking like they came from that same single IP address.