Interview Question

Software Development Engineer Interview Mountain View, CA

What happens when you type www.google.com in your browser?

Answer

Interview Answer

2 Answers

1

A lot, depends how deep down you want to go detailing it:
1. The line gets parsed and the protocol, server, port, query gets retrieved
  1.1. The mouse pointer is switched to hourglass
2. Browser connects to server at the default/specified port
  2.1. If the server's name is in DNS cache then its ip address is retrieved
  2.2. The DNS server (already set up) is queried to resolve the IP address of www.google.com
3. Browser sends a GET request followed a crlf sequence then by the headers all followed by respective crlf-s
  3.1 If this server has already cached cookies, the browser sends them as cookie headers
  3.2 If the browser supports compression it tells the server what compression is using (via headers) as well as what compression it could accept in return
  3.3 Sends a content-length header set to value "0"
  3.4. Sends a header instructing the server how to denote the end of its transmission stream. Connection: Close would be the most common
  3.5 Sends a crlf sequence to mark the end of the headers (after eventual other headers are sent)
4. (Sends no message body)
5. Waits for the response which is composed by response code, status, crlf, headers all marked by separate crlf-s and the message body (same as during the send phase)
  5.1. Parses the response code / status
  5.2. If this response starts with 2 it caches cookies, decompresses (if header is mentioning compression) parses and displays the html content of message body (executing eventual scripts hooked to different DOM elements/events)
  5.3 If the response code starts with 3 redirects t the server mentioned in the response (GOTO 1)
  5.4 If the response code starts with 5 parses the response and displays it to the user
6. Mouse pointer is turned back from hourglass to normal

Andi Mullaraj on Jul 22, 2010
1

I think we can merge the above with this
Step 1: Request a record

You begin by asking your computer to resolve a hostname, such as visiting 'http://www.google.com' in a web browser. The first place your computer looks is its local DNS cache, which stores DNS information that the computer has recently retrieved.
Step 2: Ask the Recursive DNS servers

If the records are not stored locally, your computer queries (or contacts) your ISP's recursive DNS servers. These machines perform the legwork of DNS queries on behalf of their customers. The recursive DNS servers have their own caches, which they check before continuing with the query.
Step 3: Ask the Root DNS servers

If the recursive DNS servers do not have the record cached, they contact the root nameservers. These thirteen nameservers contain pointers for all of the Top-Level Domains (TLDs), such as '.com', '.net' and '.org'. If you are looking for 'www.google.com.', the root nameservers look at the TLD for the domain - 'www.google.com'- and direct the query to the TLD DNS nameservers responsible for all '.com' pointers.
Step 4: Ask the TLD DNS servers

The TLD DNS servers do not store the DNS records for individual domains; instead, they keep track of the authoritative nameservers for all the domains within their TLD. The TLD DNS servers look at the next part of the query from right to left - 'www.google.com' - then direct the query to the authoritative nameservers for 'google.com'.
Step 5: Ask the Authoritative DNS servers

Authoritative nameservers contain all of the DNS records for a given domain, such as host records (which store IP addresses), MX records (which identify nameservers for a domain), and so on. Since you are looking for the IP address of 'www.google.com', the recursive server queries the authoritative nameservers and asks for the host record for 'www.google.com'.
Step 6: Retrieving the record

The recursive DNS server receives the host record for 'www.google.com' from the authoritative nameservers, and stores the record in its local cache. If anyone else requests the host record for 'www.google.com', the recursive servers will already have the answer, and will not need to go through the lookup process again until the record expires from cache.
Step 7: The Answer!

Finally, the recursive server gives the host record back to your computer. Your computer stores the record in its cache, reads the IP address from the record, then passes this information to the web browser. Your browser then opens a connection to the IP address '72.14.207.99' on port 80 (for HTTP), and our webserver passes the web page to your browser, which displays Google.

duke coder on Oct 5, 2010

Add Answers or Comments

To comment on this question, Sign In with Facebook or Sign Up