What Happens When You Visit Google

What Happens When You Visit Google

Curiosity is a powerful trait.

It has triggered world-changing inventions, drove man to the moon, and sometimes caused romantic relationships that we’d rather leave in the past.

But have you been curious enough to wonder what happens when you type google.com in your browser?

Understanding this will give you an appreciation of computers and how they work to maintain this infrastructure called the Internet.

What Happens When You Type https://www.google.com in Your Browser and Press Enter

As you press Enter, your browser parses the text you’ve entered and asks: "Is this string a search query or a domain name?"

If it’s a search query, your browser performs the search.

Google.com, of course, is a domain name. Hence, your browser determines which protocol for the connection.

Luckily we've specified the protocol in our text as "https".

Now, google.com is a domain name, not an IP address. Domain names were simply invented because they are easier to remember than IP addresses.

Your browser needs to know the IP address of google.com.

To get the IP address, your browser performs what's called a DNS lookup.

DNS Lookup

Your browser visits a Domain Name System (DNS) server. This server contains a DNS record. Put simply, a DNS record is a list of domain names and their IP addresses.

Your browser performs a DNS lookup and gets the IP address for google.com.

Now, your browser establishes a TCP connection with Google’s IP address.

TCP/IP Connection

TCP stands for Transmission Control Protocol. This TCP/IP connection is the fundamental communication protocol of the internet.

It uses a three-way handshake to establish a connection.

  1. In the 1st handshake, your browser sends what’s called a SYN segment to the server, asking for synchronization (that is, asking for connection).
  2. In the 2nd handshake, the server replies with SYN-ACK, which means synchronization and acknowledgment. That is, the server acknowledges the request and asks the client to open a connection too.
  3. In the 3rd handshake, your browser replies with ACK, which is akin to saying, “Okay. Connection opened.” This way, a connection is established.

Once the connection is established, HTTPS comes in to encrypt any data that will be transmitted between your browser and Google’s web server.

There are 2 commonly used encryption protocols:

  • secure sockets layer (SSL)
  • transport layer security (TLS).

These protocols make sure that any data transferred between your browser and Google web server is protected and can’t be tampered with by bad actors.

For the sake of brevity, we'll only consider SSL encryption.

HTTPS/SSL Encryption

Previously, your browser initiated a TCP connection. Now, it initiates an HTTPS connection to the server.

TCP is a protocol for data transportation, while HTTPS is for data encryption. They do two different things.

Like in the TCP connection, an HTTPS/SSL connection entails what's called an SSL handshake.

Here are the steps of an SSL handshake:

  1. Your browser initiates an HTTPS connection to Google's web server by sending a request to the server.
  2. Google's web server responds by presenting its SSL certificate that contains its public key.
  3. Your browser generates a session key, encrypts it with the public key it received, and sends the session key to the server.
  4. Google's web server receives the session key and decrypts it using its private key.

Voila! Just like that, your browser and Google's web server now have a session key that they can use to encrypt and decrypt data.

This means no one else can understand data that's transferred between your browser and Google's web server because only the two of them have this session key.

Any requests your browser sends to your browser will now be encrypted.

Now, your browser sends a GET request for https://www.google.com. This request is encrypted with the session key and is passed through a firewall.

Firewalls

Firewalls are filters that sieve incoming and outgoing traffic for web servers. They ensure that only authorized connections are allowed to proceed to a server.

Of course, your request for the www.google.com web page is authorized, so it's allowed through the firewall.

There's an issue, however.

Many people visit Google’s web servers per time. To control traffic, Google has taken certain measures.

First, Google has multiple servers to which it splits incoming traffic. Second, Google has load balancers.

Load Balancer

A Load balancer routes any requests sent from your browser to the server with the least traffic.

This controls for high traffic and ensures quick responses to requests sent by your browser.

When a web server finally receives your request for the Google search page, it decrypts it with the aforementioned session key.

Web servers usually contain:

  • An app server
  • A code base (contains HTML files, CSS files, JavaScript files, etc.)
  • A database

So the web server simply goes into its code base, looks for the page you have requested (e.g., search_page.html) along with any associated CSS or JavaScript files, encrypts it with the session key, and sends it as a response to your browser.

Your browser receives this response, decrypts it with the session key, parses the HTML code and any associated CSS or JavaScript code, and displays the parsed code on your screen.


Sometimes, you're sending more complicated requests than retrieving a web page.

For instance, you may be asking for a web page that contains dynamic content like your username for a website.

Such content isn't the same for everybody. This is where your application server comes in.

Application Servers & Databases

Application servers execute the code needed to fulfill your request and prepare the response to be sent back to your browser.

Also, the application server may need to get data from the database.

This means the application server can query the web server's database, manipulate the data it gets, format the data, encrypt it, and include it in the response back to your browser.

This is merely a high-level overview of what happens, but you now have a deeper understanding of how the Internet works.

If you have any corrections to this post, kindly drop them in the comments. Thanks!

要查看或添加评论,请登录

Damilare Ogundahunsi的更多文章

  • Week 2, Episode 1

    Week 2, Episode 1

    Estimated Reading Time: 53 secs My second week at ALX featured me loading up on some soft skills and technical skills:…

  • Week 1, Episode 1 [Pilot]

    Week 1, Episode 1 [Pilot]

    Estimated Reading Time: 35 secs Last week was my first week at ALX-Holberton, and God, was it exciting! I intend to use…

    6 条评论

社区洞察

其他会员也浏览了