What happens when you type holbertonschool.com in your browser and press Enter?
Typing any website domain name into your browser follows a set of rules which are standardized throughout the world. I will go over each step of What happens when you type holbertonschool.com in your browser and press Enter, but first let’s start with a simpler example.
Suppose you were to type google.com
into a browser. This is simpler because in the case of high traffic sites like google.com
, your browser already knows the Internet Protocol (IP) address, of popular sites.
The IP address is like your home address; it is the specific combination of numbers and letters that points to your house. Every website has an IP address, and the domain name is a memorable name for the IP address. For example, typing 188.8.131.52 into your browser is the same as typing google.com
`, but it is easier to remember google.com
than a string of digits.
The domain name is linked to your IP address via an A Record
, which I will cover when I discuss DNS. For now, understanding that 184.108.40.206 is the same thing as google.com
Typically, to query a domain name’s IP Address, your computer must access the internet in order to find a database filled with site’s domain name matched to their IP addresses.
The browser doesn’t really care what the domain name is so long as it has an IP address matched to a given domain.
Given how popular google.com
is, it would not make sense for your browser to query the record of the A Record
IP address. So your browser comes equipped with domain name to IP address matches for all the popular sites such as Google, Facebook, Youtube, NYTimes.com, etc. This record is kept in the browser cache memory. Cache memory is simply the Computer’s method which makes retrieving data from the computer’s memory more efficient.
The browser’s cache memory holds popular sites, as does the computer’s Operating System (OS). If the browser does not have the IP address of the domain name in cache, it will query the OS to see if the IP address is on the OS’s cache memory.
Domain Name System
What happens if neither the OS or the browser holds the IP address of a domain name in cache memory? Enter the Domain Name System.
Let’s use holbertonschool.com
as an example. It is a site used by hundreds of applicants to Holberton School every year, andis probably visited a few thousand times a year. Given this, it is unlikely that your browser or OS will have the IP address that matches holbertonschool.com
in cache memory.
The act of pressing Enter with holbertonschool.com
now begins a complex set of communications that span the globe and involve dozens of stops along the way. This all takes place within the blink of an eye.
The process I am about to explain occurs over the span of a few hundred milliseconds.
Once you’ve pressed Enter on holbertonschool.com
and the IP address is not in the computer’s cache memory, the browser connects to the Domain Name System (DNS) through the internet.
The Domain Name System is, in simple terms, the phonebook of the internet. DNS is not one thing but a system of bookkeeping which allows browsers to match the IP address of any domain name that exists. That’s a lot of domain name to keep track of, so the DNS works in steps.
Step 1: Recursive DNS resolver
Though your OS or your browser may not have the IP address of holbertonschool.com
in it’s cache, the DNS Resolver may have it in it’s database. Put simply, the Recursive DNS resolver is a database run by your Internet Service Provider (ISP). This could be a system run by Comcast or Verizon, but it is only the first stop in the DNS.
Let’s assume that the Recursive DNS resolver does not have the IP address for holbertonschool.com
. We move on to Step two.
Note that some domain names have more than one IP address. Though the IP address may change, the domain never will not. The Domain Name System is an up-to-date index of those IP addresses.
Step 2: DNS Root Name server
The DNS Root Name server is actually step one if the ISP Resolver doesn’t have the IP address in storage. The Root is the .com
for example, but there are actually dozens of Root names that a site can have. holbertonschool.com
uses the most popular Root name, .com
. Root names are also referred to as Top Level Domain (TLD) because it is the first part of the lookup process using DNS.
There are actually 13 Root Name servers in the world. Literally 13 physical locations of servers with databases that connect the domain name of whatever root name is in the domain name to it’s IP address.
Whatever the TLD is, your browser has been directed (or refered) to a TLD Name server. Now in step 3 we move to the Authoritative name server
Step 3: Authoritative Name Server
Once the Root name is known, the browser is directed to the Authoritative Name Server (ANS). This is the last stop.
When the good people at Holberton School created holbertonschool.com
, they registered the name holbertonschool
with a domain hosting company. This essentially took an unused IP address and mapped it to the name holbertonschool
with a Top Level Domain of .com
. This mapping is called an A Record
The A Record
is the main domain name that points to the IP address in use. You can put a www
in front of the TLD, but www
is a convention. Truly, the Third Level Domain can be anything you like.
When the name was registered and given an A Record
it now mapped to the correct IP address and all this was recorded by the hosting company in a database. The Root level name took us to the correct ANS, and the ANS has the ip address for holbertonschool
mapped to its IP address.
Now that IP and domain name are mapped, the results are returned to the browser. The browser substitutes the domain name for the IP address in the browser and we are shown the contents of the static web page. This is the web server which hosts the contents in a server with the IP Address of holbertonschool.com
Now that your browser knows the correct IP address, it puts holbertonschool.com = IP Address
in its cached memory so the next time you type holbertonschool.com
into your browser it checks if it knows the IP address of holbertonschool.com
. Now that it does, typing holbertonschool.com in your browser and pressing Enter simply queries the browser’s cached memory and goes to the affiliated IP address.
Servers, how do they work?
On other end of the internet from the user (often referred to as the Client side) at the IP address for holbertonschool.com
is a physical server. The physical server can be at the physical address of the site’s administrator, but for smaller organizations it is most likely on a server farm along with thousands of other servers.
A server has several components which I will cover one at a time. For an example of the way in which a server is broken down, let’s look at Amazon.com
Amazon sells thousands of products. The template for any product page includes a product description, reviews and an ability to conduct a transaction over the internet.
The parts of the page that never change, such as the header, footer and look and feel of a page are served on the Web Server as the static website.
It is important to understand that the converse of this would be that each Amazon page would literally be drawn out by a developer one at a time. This would be an incredibly inefficient system, as each aspect of the site’s pages would be a copy of the main template with the product specific information and reviews added in manually.
Of course Amazon knows that this wouldn’t be feasible, so they employ a Server model that joins together the static web template with code functionality and database driven content creation.
The web server is a distinct part of a server setup. Often used interchangeable with Server the Web Server is responsible for displaying the markup language, HTML and CSS, as the static website. Since every browser automatically runs HTML and CSS, this part of the server displays the look of the website, but rarely includes any real functionality. That comes with the Application Server.
The codebase is most often PHP, but in the past Java Applets were run through the application server. Technically, any language could be run through the App Server, even C, but in practice most site’s use the newest languages for its codebase.
In our Amazon example, the codebase is seen in the e-commerce functionality, as well as how reviews are handled and pictures are displayed.
That brings us to the Database.
The database (db) is the last component of a server. Simply put, a db is a structured set of data held in a computer, especially one that is accessible in various ways.
Most often, the db holds data needed to make a site functional. For Amazon, the product description,images and reviews are kept in a large database. When a particular product is chosen, the associated information and reviews are queried in the Database by the Application Server.
Together the DNS tells the browser what the IP address is, and the Client is connected to a Server via its IP address. Then the different components of the server works together to present a live, functional website.
So far we have covered the Domain Name System and Servers, but there are additional elements on the server end . These elements include the load balancer, SSL Certificate and Firewall.
Once a site becomes more highly trafficked, it is time to add additional power to your site. This is done by adding more servers to the site. This helps increase the number of visits that the site can accommodate and helps keep downtime to a minimum when updating the Codebase (When one server is done a backup server is still hosting the site).
When a website is scaled up with more servers, additional concerns become balancing the workload between servers. Also, increased traffic means increased chances of infiltration by hackers, so security becomes paramount.
A load balancer is used when one website (domain name or IP address) uses more than one server. The load balancer is the front facing program that acts as a filter between the Client, the internet and the server.
A load balancer acts as the “traffic cop” sitting in front of your servers and routing client requests across all servers capable of fulfilling those requests in a manner that maximizes speed and capacity utilization and ensures that no one server is overworked, which could degrade performance. If a single server goes down, the load balancer redirects traffic to the remaining online servers. When a new server is added to the server group, the load balancer automatically starts to send requests to it.
Load balancers use special algorithms to direct traffic between servers. These are some of the algorithm designs used in load balancing:
- Round Robin (sometimes called “Next in Loop”).
- Weighted Round Robin — as Round Robin, but some servers get a larger share of the overall traffic.
- Source IP hash. Connections are distributed to backend servers based on the source IP address. If a webnode fails and is taken out of service the distribution changes. As long as all servers are running a given client IP address will always go to the same web server.
- URL hash. Much like source IP hash, except hashing is done on the URL of the request. Useful when load balancing in front of proxy caches, as requests for a given object will always go to just one backend cache. This avoids cache duplication, having the same object stored in several / all caches, and increases effective capacity of the backend caches.
- Least connections, weighted least connections. The load balancer monitors the number of open connections for each server, and sends to the least busy server.
- Least traffic, weighted least traffic. The load balancer monitors the bitrate from each server, and sends to the server that has the least outgoing traffic.
- Least latency. Perlbal makes a quick HTTP OPTIONS request to backend servers, and sends the request to the first server to answer.
Whichever algorithm is used, the load balancer’s job is the same: schedule the workload of servers.