When you visit any website, its as simple as typing the URL into your preferred browser and pressing enter. Once you’ve done that, the page just opens up nearly instantly (most of the time anyway), and that’s it. Right? Well actually, there is more than a dozen processes and events that need to occur before the website even reaches your computer.
Lets start back at the beginning, you type a website URL (like holbertonschool.com) into your browser and press enter.
DNS (Domain Name System):
The second you press enter, your computer sends that URL to the DNS service and asks for the corresponding IP address. The reason it does this, is because servers cant communicate directly with a URL, servers can only communicate with IP addresses. It’s like if you told your post man to deliver your mail to “Jeff’s house”, your post man will have no clue who Jeff is and your mail wont get delivered. However if you got Jeff’s home address, and told that to your post man, he would know exactly where your package needs to go.
Once DNS finds the IP address that corresponds to the requested URL, it sends the IP to your browser so it can start talking to the server hosting the website.
Talking to the server:
Once the browser has the IP is needs, it makes something called a GET request (because we want to GET the web content) over the internet using TCP or Transmission Control Protocol. The reason we use TCP over UDP is because even though TCP is slower than UDP, TCP is significantly more reliable than UDP so we don’t risk losing any data along the way.
Finally we’ve connected to the server, the first thing that happens after establishing a connection to the server is called the “SSL Handshake”. This is an exchange from the server, where the server provides its security certificate, which tells the browser that all traffic is encrypted and this is a trusted website (Indicated by HTTPS on the URL and a lock icon next to the URL on your browser). This whole process is to make sure you the user are protected from people trying to pry on your traffic, and verifies that you are safe on the website you are on.
After the initial handshake greeting, the server then passes your request through a firewall. This is an added layer of security to protect the server and make sure the request isn’t trying to access a port it shouldn’t be, and to filter out any harmful data or requests to the server.
If you made it through the firewall successfully, you will now be redirected to something called a “load balancer” before you talk to an actual web server. This load balancer is used to control the flow of traffic, which helps if there’s a large number of users trying to access a web page. The balancer usually spreads out users evenly between a number of servers, however there are many different configurations a load balancer can use to distribute traffic.
Finishing up:
Alright the load balancer directed you to its preferred server, and your request finally made it to an actual web server. The web server now talks to the application server which actually generates the web page based on the GET request, and that application server is also talking to a database to get any relevant data that will be used in your page. Once the data is sent to the application server, and the application server delivers its content to the web server, the web content is finally then sent to your browser from the web server.
So when you visit any web page, theres actually a lot going on just so you can load a single page. Next time you visit youtube, or google, think of how much just happened, and how quickly it all happens!