How does the web actually work? It is easier than you think!
Many people are curios about how web actually works, so now I will try to explain it.
We have already talked about DNS records, and it is important to understand DNS first. Bur just to recap: Humans use street names for orientation and computer uses IP addresses. DNS is just a system that resolves website name (for example google.com) to an IP address (for example 18.104.22.168). Now that we got that out of the way lets begin with inner workings of an average website.
Websites are composed of multiple layers. But where are those layers stored? They are all stored on a server (which has an IP address). You can find out more about servers and their configuration in this post.
Each web server will have Operating System installed. In most cases, it would be Linux or Windows. One important thing that we would need in order to run our website is the actual server software installed as well. In most cases, it would be Apache, NGINX or IIS. This is the software that is responsible for the actual delivery of your website. With server software installed we would now need an installed programming language like C#, PHP, JAVA, Ruby, or some other language. After our programming language is installed we would now need someplace to store our data - SQL, MySQL, or MariaDB are used usually.
The diagram above explains the entire pipeline. This is what happens when you try to access a website.
Here is how web actually works:
- You type a website name into the URL bar
- The browser looks for DNS server IP address and sends website name to it
- DNS server responds with an IP address of the desired website
- Your browser sends a request to a specified IP address
- After web server receives a request it starts to process the request which means it loads up a website's code and processes it depending on your request
- Usually, website code will use the database to store data, so now website code will talk to the database in order to retrieve desired data
- After the code of our website retrieves data, the website's code starts to generate a response
- The response will usually be an HTML output which your browser would process and you will be presented with a beautiful website
This is a very simplified explanation, of course, there are other things that are happening during this entire process. For example one of the things may be a "two-way handshake" or establishing a secure SSL connection, which is displayed as https in your browser URL bar. But overall that is how the web actually works!
For example, we may encounter a web server that uses a load balancer. But as I said, I will try to keep this as simple as possible.
I hope you have found out something new today, in my next posts I will try and go over some server technologies and my favorite setup!
As always, stay safe and #keepCoding!