Pfft I know how the internet works, why bother?
Understanding the internet at a bit of a lower level and recognizing all websites can actually be reduced to the same steps helps us understand more complicated things.
The history of the internet (not from Tim Berners Lee time but sure if you want…), helps us understand why and how certain things like docker, digital ocean, and aws came to be.
Bob is sort of the user we'll follow.
He could be you or I or anyone else. He's just a person accessing the internet to view webpages.
Company XYZ is more or less a placeholder for a random company that has a website.
We'll look at what they have to do to host their website so Bob can interact with it.
I'll probably make them Google often because https://www.google.com is a site we're familiar with.
I'll also use a small flower chain or taco cart as other companies.
Steps:
Let's say we navigate to google.com.
Our browser somehow automagically figured out the logo and search bar and everything else.
To understand this, we have to understand the role of a browser –>
A browser can be boiled down to 2 functionalities:
Let's save this into a file like hello.html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>Hello</title>
</head>
<body>Hello there.</body>
</html>
Copy the path eg
/home/shan/hello.html
(it'll differ per OS and user and where you save…)
and paste it in the address bar in your browser!
Let's view this (I know… center is deprecated but still supported by every browser mkay? ๐):
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>Hello</title>
</head>
<body style="color: salmon;">
<center>Hello there.</center>
</body>
</html>
At this point, we're convinced that the browser parses and visualizes files.
But what about requests? Well, open up your inspect element and head over to the network
tab and reload hello.html
!
But we don't have any of that data saved on our computer, so how did the browser get the HTML for google.com?
When we throw in google.com in our address bar, that query goes
browser -> ISP -> DNS
and the DNS performs a lookup for its address and returns something like 172.217.0.0
(Google has many IPs)
browser <- ISP <- DNS
Think of a DNS somewhat like a phonebook… if you still remember what those are ๐
Next, your browser makes a request directly to Google's for the HTML.
For now, we'll focus on GET
requests, but they're just easier to talk about.
Basically everything connected to the internet has its own IP address.
Via the address, it can expose endpoints which server up information depending on how they're invoked + its implementation.
Just as we were able to get HTML from our local filesystem, a simple apache server can expose the filesystem such that instead of your prefixed root path, it'll be ip address/path/to/file
The pattern more or less is as follows --
The codes are in hundreds. You're probably already familiar with some like 404 for a page not found.
TB to the that visit to google.com
Now, if you're running a website, let's say you're doing it for profit. You have some model that has customers visit your site
Eg: A taco cart is selling tacos ๐คจ
Like we've learned, every site follows the same pattern of requests per user.
What happens when many users visit your website at once?
You may not be able to handle a lot of users due to server limitations… you lose out on customers + other customers may have a bad experience ๐ฑ.
There are a few ways to handle more customers.
There are a few costs and responsibilities associated with having your own server room:
This is how VPS came to be.
Basically someone owns data centers and farms and has a bunch of machines running anyways, so they rent out some to users.
I'm not totally clear if VMs came first or VPS, but users would want to run multiple things OS dependently which meant they would need multiple machines… or did it?
VMs basically virtual-izes OSs such that it has its own CPU, memory, network interface, and storage from your one setup.
This lets you either switch seamlessly or potentially have both running at the same time $$$
VMs probably led to the evolution towards containerization.
The idea is maybe your programs can share more lower level things and sandbox differently.
So, time for another scenario to see why serverless: a flower chain selling flowers ๐บ
For this chain, let's say it doesn't only sell to one location like the taco cart may have.
Your traffic may be low on some days but spike during Valentine's Day.
You're paying needless $$$ ๐ฑ
Maybe… just maybe… servers can scale up and down as needed.
This gives rise to AWS and GCP.