When you (or a program) want to make an HTTP request to say google.com, what IP address does your request go to and how is that determined? Do all requests to google.com go to the same IP address?

DNS Lookup

When you make a request to google.com, this is first sent to your ISP’s DNS server. If there isn’t an IP cached for google.com, it will forward the request to one of many root DNS servers, usually the one closest to it.

The root DNS server will look at the ending of the domain (e.g. .com) and forward it to one of many TLD (top-level domain) DNS servers for that ending.

The TLD DNS server will then forward the request to one of many authoritative DNS servers for google.com.

The authoritative DNS server will then return the IP address of one of many load-balancers for google.com.

This IP will get cached by your ISP and subsequent DNS lookups for google.com will just return it.

Why are there so many of each?

Why are there so many root DNS servers, TLD DNS servers, authoritative DNS servers, and load-balancers for each domain? The answer is load-balancing and redundancy. If there was only one of each, they would be a single point of failure. If one of them (besides the final load balancer) went down, the entire internet would be affected. If the final load balancer went down, accessing the site would be affected. Furthermore, having multiple of each allows for load-balancing, so that no single server is overwhelmed with requests.

Session Persistence

So, essentially, each of your requests to google.com will go to a different IP address (because the load balancer may return a different IP each time you hit it with a request). But often, we need several requests to go to the same IP, for session reasons (think shopping cart, login state, etc).

This is achieved by using a sessionId cookie. When a session is started, the server will return a sessionId cookie to the client. The client will then send this sessionId cookie with each subsequent request, and the load balancer will use this sessionId to route all requests to the associated server.

So in essense, you are putting some information in each of your requests that tells the load balancer to send all of your requests to a specific server. This is called session persistence.


Here is the process of translating a domain name (say google.com) to an IP address:

  • ISP’s DNS server, if not cached, sends a request to the root DNS server closest to it
  • Root DNS server, finds out the TLD DNS servers (yes plural, for load-balancing/redundancy) for .com and sends a request to one of em
  • TLD DNS server, finds the authoritative DNS servers for google.com and sends a request to one of em (yes there are multiple for load-balancing/redundancy)
  • Authoritative DNS server, returns the IP of one of many load-balancers for google.com

And here is how session persistence is achieved:

  • A sessionId cookie is returned to the client when a session is started
  • The client sends this sessionId cookie with each subsequent request
  • The load balancer uses this sessionId to route all requests to the same corresponding server

Thanks for stoppin by man, hope it was a fun read!