what happens when you type google.com in your browser and press Enter

·

11 min read

what happens when you type google.com in your browser and press Enter

Introduction:

In a world where information is just a click away, whether you want to access your favourite social media, news, or e-commerce sites. All you need to do is type in a URL or click on a link to the page and the magic happens, you get what you were looking for within seconds. But what really happens in that split second between your keystroke and the webpage appearing? How do your Twitter feed and the tweet data show up in your browser securely? How does the link you clicked bring you to this blog post?

In this post, we’ll look at what happens when you type a URL into your browser and press enter, taking https://www.google.com as our study case.

1.DNS Request: The Internet's Phonebook

When you point your browser at a URL like https://www.google.com your browser has to figure out which server on the Internet is hosting the site. It does this by looking up the domain,(www.google.com), to find the address.

Each device on the Internet — servers, cell phones, your smart laptop — all have a unique address called an IP address. An IP address contains four numbered parts:

203.0.113.2

But numbers like this are hard to remember! That’s where domain names come in. (www.google.com) is much easier to remember than 203.0.113.2, right? Imagine having to remember all the phone numbers of your contacts without having the Contacts app on your phone. Your Contacts app lets you look up phone numbers by name. DNS works the same.

We’ll go over the DNS lookup process at a high level, but it is a complex topic beyond the scope of this post. You can read more about how DNS works here

Because DNS is complex and has to be blazingly fast, DNS data is cached at different layers between your browser and at various places across the Internet. Your browser checks its own cache, the operating system cache, a local network cache at your router, and a DNS server cache on your corporate network or at your internet service provider (ISP). If the browser cannot find the IP address at any of those cache layers, the DNS server on your corporate network or at your ISP does a recursive DNS lookup. A recursive DNS lookup asks multiple DNS servers around the Internet, which in turn asks more DNS servers for the DNS record until it is found.

Once the browser gets the DNS record with the IP address, it’s time for it to find the server on the Internet and establish a connection.

2. TCP/IP: Establishing the Connection

Once the browser knows the IP address of the server, it needs to establish a connection. Here, TCP/IP (Transmission Control Protocol/Internet Protocol) comes into play.

A protocol is an agreed-upon set of rules. TCP and IP are two separate computer network protocols.

IP is the part that obtains the address to which data is sent. TCP is responsible for data delivery once that IP address has been found.

Think of it this way: The IP address is like the phone number assigned to your smartphone. TCP is all the technology that makes the phone ring, and that enables you to talk to someone on another phone

Any given interaction may be between two computer systems, or it may involve hundreds of systems. But, These computers may be from different companies, or even located in different parts of the world – and the people and programs using them may use different human and computer languages. In order for them to communicate we need a set of rules(protocols). The two computers need to know, ahead of time, how they are expected to communicate.

  • How do they start the conversation?

  • Whose turn is it to communicate?

  • How does each computer know its message was transmitted correctly?

  • How do they end the conversation?

Here’s one way it does that. If the system were to send the whole message in one piece, and if it were to encounter a problem, the whole message would have to be re-sent. Instead, TCP/IP breaks each message into packets, and those packets are then reassembled on the other end. In fact, each packet could take a different route to the other computer, if the first route is unavailable or congested.

3.Firewall: The Security Check

Google takes its security measures very seriously so before so before your computer establishes a connection with the Google server, it is definitely going to encounter a firewall.

A firewall is a digital security system that checks all incoming and outgoing traffic on a network according to a defined set of rules. It filters data entering a network. It analyzes that data by checking the sender’s address, the application the data is meant for, and the contents of the data. By combining these defined data points, a firewall can tell what’s harmful and what isn’t. Then the firewall opens or closes the network gate accordingly

4.HTTPS/SSL: Ensuring Secure Communication

With the connection established and the firewall's approval, the next step is to secure the communication. This is done through HTTPS (Hypertext Transfer Protocol Secure) and SSL (Secure Sockets Layer). Let's see how it works.

HTTPS, or Hypertext Transfer Protocol Secure, is an internet communication protocol that protects the integrity and confidentiality of data between the user's computer and the site. It uses encryption to ensure that the data transferred between the user and the site is secure and cannot be intercepted by attackers.

SSL, or Secure Sockets Layer, is a standard security technology for establishing an encrypted link between a server and a client. It ensures that all data passed between the web server and browsers remain private and integral.

Here's how they work together:

  1. When you enter a URL starting with "https://", such as https://www.google.com, your browser initiates a secure session with the website.

  2. The website sends a copy of its SSL certificate, including the public key, to your browser.

  3. Your browser checks the certificate against a list of trusted Certificate Authorities and ensures the certificate is valid, has not expired, and has been issued by a trusted party.

  4. If the certificate passes the checks, your browser generates a symmetric session key, encrypts it with the website's public key, and sends it back to the server.

  5. The server decrypts the symmetric session key using its private key and sends back an acknowledgement encrypted with the session key to start the encrypted session.

  6. Now, the server and browser encrypt all transmitted data with the session key. This ensures that the user's interactions with the website are secure and private.

Do check for the padlock icon the next time you browse to ensure your data is secure.

5.Load Balancer: Distributing the Load

Google servers receive a massive amount of traffic every day. Millions of people around the world are constantly searching, watching videos, sending emails, and using other Google services. To handle this huge volume of requests, Google uses a system of servers distributed around the world. However, even with this distributed system, individual servers could become overwhelmed if too many requests are directed to them at once. This is where load balancers come into play.

A load balancer acts like a traffic cop, distributing incoming network traffic across a group of backend servers, also known as a server farm or server pool. This process ensures that no single server bears too much load, which can help prevent slowdowns and outages.

Here's a simplified explanation of how a load balancer works:

  1. When a user makes a request to a website (like www.google.com), that request is sent to the load balancer.

  2. The load balancer has a list of all the servers that it can distribute requests to. It uses an algorithm to determine which server should handle the incoming request. This algorithm might be as simple as round-robin (where each server is chosen in turn) or as complex as a custom method that takes into account the current load on each server, its response time, its uptime, and other factors.

  3. The load balancer forwards the request to the chosen server.

  4. The server processes the request and sends the response back to the load balancer.

  5. The load balancer then forwards the response to the user.

By distributing the load, load balancers ensure that all users get served as quickly as possible. They also provide redundancy; if one server goes down, the load balancer can simply redirect incoming requests to other servers. This ensures high availability and reliability of applications and websites.

6.Web Server: Serving and Generating the Webpage

Web servers are the backbone of any web-based service, including Google. They are responsible for processing user requests and delivering web pages to users' browsers. When a user types a URL like https://www.google.com into their browser, the browser sends a request to the server associated with that URL, and the server sends back the requested page.

Google, given its scale, uses a vast number of web servers distributed globally. These servers are grouped into clusters, and each cluster is located in a data centre. Google's web servers are responsible for handling all sorts of requests, from search queries to YouTube video streaming.

Here's a simplified explanation of how Google's web servers work:

  1. User Request: When you type a search query into Google and hit enter, your browser sends a request to Google's servers.

  2. Load Balancing: This request first hits a load balancer, which distributes the incoming requests to ensure no single server is overwhelmed.

  3. Processing the Request: The chosen server processes the request. For a search query, this involves accessing the index (a database of all web pages that Google has crawled and catalogued) and finding the most relevant results.

  4. Generating a Response: The server then generates a response. This is the search results page that you see, which includes links to relevant websites, snippets of information, and potential ads.

  5. Sending the Response: The server sends this response back to your browser through the load balancer.

  6. Displaying the Results: Your browser receives the response from the server and displays the results on your screen.

Google's web servers are also designed to be highly reliable and available. They use redundancy (having multiple copies of data and functionality) to ensure that if one server or data centre goes down, others can take over. This is part of why Google's services are generally very reliable, even under high load.

Some of the most popular web servers include the following:

  • NGINX

  • Internet Information Services (IIS) from Microsoft

  • Lighthttpd

  • Apache Tomcat

  • Apache HTTP Server

7.Application Server: Dynamic Content

An application server is a server that hosts applications. It's a type of middleware (software that connects two or more software applications) that provides both facilities to create web applications and a server environment to run them.

Application servers are used for complex transaction-based applications. To differentiate them from web servers, they expose business logic to the client applications through various protocols, possibly including HTTP. While a web server mainly deals with sending HTML for display in a web browser, an application server provides access to business logic for use by client application programs. The application program can use this logic just as it would call a method on an object (or a function in the procedural world).

For example, let's consider a shopping cart application

on a website. When you click "Add to Cart," the request goes to a web server first. The web server, seeing that the request is for a dynamic page, forwards the request to an application server. The application server executes the business logic (add an item to the cart) and returns the result to the web server. The web server then sends the result to the client's web browser.

In the context of Google, an application server might handle tasks like processing search queries, managing ads, or running the algorithms that determine what search results to display. These servers would work in conjunction with web servers (which handle the HTTP protocol and deliver the HTML content to the user's browser) and database servers (which store and retrieve the data needed by the application servers).

8.Database: The Storehouse of Data

In the context of web services and application servers, a database is a structured set of data. It's like a giant, highly organized virtual filing cabinet where a service like Google stores all its data, including user information, website details, search queries, and more.

Databases are crucial for storing, managing, and retrieving data. When you perform a search on Google, the search query interacts with the database to find relevant results. Similarly, when you watch a video on YouTube (a Google service), the video details, comments, likes, and other related data are stored and managed in a database.

There are different types of databases, such as relational databases (like MySQL or PostgreSQL) and NoSQL databases (like MongoDB or Cassandra). Google has developed its own database systems, like Bigtable and Spanner, to handle its specific needs.

In summary, a database in this context is the backbone that stores all the data necessary for a web service to function. It works closely with application servers (which handle the business logic) and web servers (which deliver the content to the user)

Conclusion:

Less than a second, all these happen in less than a second. The programming world is simply magical. So, the next time you type a URL and the webpage appears almost instantly, take a moment to marvel at the intricacies behind the scenes. It's the digital symphony that ensures your smooth and secure journey through the web. Happy surfing, and enjoy the magic of technology!

resources:

  1. https://sophiaintech.hashnode.dev/what-happens-when-you-type-googlecom-and-press-enter#heading-tl-dr

  2. https://www.avast.com/c-what-is-a-reverse-proxy

  3. GPT

  4. Phind