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

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

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

It only takes seconds for a webpage to appear after pressing Enter but what takes place underneath is so fascinating and I will take you guys through it.

?

We’ll talk about the following topics:

·??????DNS request

·??????TCP/IP

·??????Firewall

·??????HTTPS/SSL

·??????Load-balancer

·??????Web server

·??????Application server

·??????Database

Before we begin, let us first understand what a server is.

What’s a server?

In computing, a?server?is a piece of computer hardware or software (computer program) that provides functionality for other programs or devices, called “clients”. This architecture is called the client-server model. — Wikipedia

The client is whoever is asking for information. It can be you typing a website name or address. Mainly they are devices connected to the web like our computers, laptops, and web-accessing software like Google Chrome or Firefox.

The server is now what responds to your request. Servers store webpages, sites, or apps; where in this case it is the Google server.

When a client device wants to access a webpage, it requests a copy of the webpage from the server which is then downloaded onto the client to be displayed in the user’s web browser.

When you type a website address, technically called a URL, the browser breaks it down into parts. And for this, we’ll need a DNS server.

What is a URL?

In full it is, Uniform Resource Locator, used to access a website.

There are several parts to a URL: the protocol, hostname, port and path-and-file-name, and more. For this blog post, we will look at the protocol and hostname. In the case of?https://www.google.com: https is the?protocol?(more on that later) and?www.google.com?is the?hostname, which can be a domain like in this case or also an IP address.


DNS Server

Think of it as the contact list of the Internet!

They are application servers that convert domain names, easily understood by humans, into machine-readable IP addresses. Each device connected to the internet has a unique IP address that other machines use to find the device.

“When a client needs the address of a system, it sends a DNS request with the name of the desired resource to a DNS server. The DNS server responds with the necessary IP address from its table of names.” —?www.paessler.com

This process called?DNS resolution or DNS lookup?has 4 steps (and servers) involved in loading a webpage:

1.????DNS recursor?is the first stop. It’s a server designed to receive queries from clients through applications such as web browsers. If this server already has the IP address stored in the cache it will simply return it back. Otherwise, it’ll be responsible for making additional requests, by sending a query to the root DNS server.

2.????The?root server?or root nameserver doesn’t have information about the hostname but it has information on where to find it so it will refer the requests to the appropriate TLD server.

3.????The?TLD (Top Level Domain) is the next step in the search for a specific IP address, and it hosts the last portion of a hostname. In google.com, the TLD server is “com”. The request is then sent to the authoritative nameserver.

4.????The Authoritative nameserver?is the last stop in the name server query. If this server has access to the requested record, it will return the IP address for the requested hostname back to the DNS recursor that made the initial request — otherwise, it will send an error saying the record couldn’t be found.

No alt text provided for this image


Diagram illustrating all the steps involved in DNS resolution. Source: https://www.catchpoint.com/blog/domain-name-to-ip-address


Internet Protocol Suite

Finally, the browser knows where to find?www.google.com?and it’s now time to make a connection, to access the website requested. Browsers use internet protocols to build such connections.

Internet Protocol Suite aka TCP/IP (TCP stands for Transmission Control Protocol) is the most common protocol used for many types of HTTP requests. It’s a set of rules governing the format of data sent via the internet or local network, such as sending e-mails, streaming videos, or connecting to a website.

Traffic and Security Control

Once the TCP connection is established, it is time to begin transferring data! But not so fast, first, we need some traffic control — meet the load balancer…

A load balancer, like HAProxy, is a server that helps handle more web traffic and avoid downtime. The load balancer receives traffic from the internet and then distributes it among multiple servers so as to not overload any particular server with too many requests. Load balancers are essential for websites with a lot of traffic such as google.com! But can anyone get in? Let’s ask the firewall…

A firewall is a software or hardware device that blocks unauthorized access to or from private networks. It acts as a barrier between a secured internal network and the most vulnerable network, e.g. the internet. The decision to whether to allow the traffic or not is based on a custom set of security rules, such as restrictions on the IP address of the request, the number, and frequency of the requests made, or the type of content being requested. A load balancer acts as a firewall. However, you can install separate firewalls for extra security and protection and avoid SPOF (single point of failure).

SSL

Security is key in nowadays digital world so we have an extra security measure taken using Secure Socket Layer (SSL).

SSL is a protocol for servers and web browsers that makes sure that data passed between the two are private. This is done using an SSL certificate, a small data file that cryptographically establishes an encrypted link between a web server and a browser. This link ensures that all data passed between the web server and browser remain private. —?blog.hubspot.com

SSL is particularly useful when exchanging credit card information or other private sensitive information as it makes it impossible to decipher them if someone was listening in.

How do you know if a website is using an SSL certificate? Easy, just look at the URL and if you see that padlock and?https:// instead of http, then your privacy is safe. But what’s http/https?

HTTP/HTTPS

What is it?

HTTP stands for HyperText Transfer Protocol and is perhaps the most popular application protocol used by the World Wide Web. It’s used by web browsers and web servers to communicate. It is a stateless, text-based protocol.

Picture illustrating how the client communicates with the server via HTTP requests and responses.

No alt text provided for this image

Source:www3.ntu.edu.sg/home/ehchua/programming/webprogramming/HTTP_Basics.html

It works like this: an HTTP client or web browser sends a request message to an HTTP server or web server. The server, in turn, returns a response message.?Note that HTTP is a pull protocol, the client pulls information from the server rather than the server pushing information to the client.

HTTPS works the same as HTTP, it’s only more secure. The additional letter, S, stands for security, and, as mentioned earlier, it means it’s using an SSL certificate.

HTTP requests and response status code

HTTP requests can have a range of different methods.

·???????GET is used to get data from a web server.

·???????POST is used to send data from a web server.

·???????PUT is used to update data from a web server

·???????DELETE is used to delete data from a web server

An HTTP request will always return a response, at least with the status code indicating if the request has been successful or not. Some of the most popular status codes are:

1.????Informational responses (100–199)

2.????Successful responses (200–299)

3.????Redirection messages (300–399)

4.????Client error responses (400–499)

5.????Server error responses (500–599)


Web and Application Servers

A?web server?is computer software and the underlying hardware that accepts requests via HTTP/HTTPS and serves static content, like simple HTML pages, images, or plain text files, in other words, content that doesn’t change. It’s the web server's job to find content corresponding to the website address requested, and to serve it as an HTTP/HTTPS response. Examples of web servers are Nginx and Apache.

However, most sites don’t only have static content. Quite the opposite most web apps depend on dynamic content, content that changes. That means, for example, it’s possible to interact with the website, save the information on it, log in with a username and password, and so on. For this, we need the application server!

An?application server?is a software program responsible for operating applications, communicating with the database servers, managing user information, and more. It works with web servers and is able to serve a dynamic application using the static content from the web server.

Database

Another crucial component in the client-server computing environment is the database server, which consists of hardware and software that run a database. A?database?is a collection of data, and the database server is the program that interacts with the database and retrieves, adds, and modifies data in it. The two main ones are?relational?databases and?non-relational?databases. PostgreSQL, MySQL, SQLite, and MariaDB are some of the most popular relational databases.

The image below illustrates how the web server, application server, and database work together.

No alt text provided for this image


Image illustrating how the web server, application server, and database work together. Source:https://moreequalanimals.com/posts/blockchain-is-better-application-server-and-database


Conclusion

All of these steps mentioned above happen within milliseconds that we press Enter on our keyboard before we can even notice them. To summarize this process visually, I created this diagram below.

No alt text provided for this image


Diagram was created to summarize the entire process of what happens when you type a URL in the browser and press enter.

I hope you now have a better understanding and appreciation of what happens when you type a URL in the browser and press enter!

Stay happy and keep coding!????? ??

References and other helpful resources

https://www3.ntu.edu.sg/home/ehchua/programming/webprogramming/HTTP_Basics.html

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

社区洞察

其他会员也浏览了