System Design Diaries #2: The Internet's Biggest Network
Hey Readers.
Spotted: billions of devices talking to each other every second.
Your phone sends a message. A server responds. A video starts streaming. A payment gets processed.
But before any of that happens, the internet has to answer a few important questions:
Who are you? Where are you? How should we communicate?
Today, we're diving into the networking fundamentals that make modern systems possible.
Every Device Needs an Identity
Imagine trying to deliver a package without an address.
That's exactly why IP addresses exist.
An IP address is a unique identifier assigned to a device on a network.
Its job is simple:
Identify a machine
Help devices communicate
Route data across the internet
Without IP addresses, the internet would basically be a giant group chat with no usernames.
IPv4: The Original Celebrity
IPv4 uses 32-bit addresses.
Example:
192.168.1.1
This allows approximately 4.3 billion unique addresses.
That sounded like a lot back in the day.
Then everyone got smartphones.
And laptops.
And smart TVs.
And smart refrigerators.
Suddenly, 4.3 billion didn't feel so unlimited anymore.
IPv6: The New Generation
IPv6 uses 128-bit addresses.
Example:
2001:db8::7334
The address space is so massive that running out is practically impossible.
IPv6 was created to solve IPv4 exhaustion and support the ever-growing internet.
Ports: Finding the Right Room
An IP address identifies the machine.
A port identifies the application.
Think of it this way:
IP Address = Apartment Building
Port = Apartment Number
Without ports, your computer wouldn't know whether incoming data belongs to your browser, database, or video call.
Common ports:
| Port | Service |
|---|---|
| 80 | HTTP |
| 443 | HTTPS |
| 22 | SSH |
| 3306 | MySQL |
| 5432 | PostgreSQL |
The internet loves organization.
TCP: The Reliable Friend
Some conversations cannot afford mistakes.
Bank transfers.
Authentication systems.
Payment processing.
For those situations, we use TCP.
TCP (Transmission Control Protocol) is reliable and connection-oriented.
Before communication starts, both sides establish a connection.
Features of TCP
Connection-oriented
Reliable delivery
Ordered delivery
Error detection
Retransmission of lost packets
Why Engineers Love TCP
If data gets lost, TCP sends it again.
If packets arrive out of order, TCP rearranges them.
If something goes wrong, TCP notices.
It's basically the responsible friend of networking.
The Famous Three-Way Handshake
Before communication begins:
Client ā SYN
Server ā SYN + ACK
Client ā ACK
Connection established.
Only then does data start flowing.
The Tradeoff
Reliability comes at a cost.
TCP introduces:
More overhead
Higher latency
Slower communication compared to UDP
Sometimes being careful takes time.
UDP: The Speed Demon
Not every application needs perfection.
Sometimes speed matters more.
Enter UDP.
UDP (User Datagram Protocol) is fast and connectionless.
It doesn't establish a connection.
It doesn't guarantee delivery.
It doesn't promise packet ordering.
It just sends data.
Features of UDP
No handshake
No retransmission
No ordering guarantee
Lower overhead
Advantages
Extremely fast
Low latency
Lightweight
Disadvantages
Packet loss possible
No delivery guarantee
No ordering guarantee
UDP's philosophy is simple:
"Good luck."
And surprisingly, that's exactly what many applications need.
Common Uses
Online gaming
Live streaming
Voice calls
Video conferencing
A dropped packet during a video call is annoying.
Waiting three seconds for perfect delivery is worse.
DNS: The Internet's Phonebook
Humans remember names.
Computers remember numbers.
That's where DNS comes in.
DNS (Domain Name System) converts domain names into IP addresses.
Example:
google.com
ā
142.250.x.x
Without DNS, we'd all be memorizing long strings of numbers.
And nobody wants that.
What Happens When You Type Google.com?
The request follows a surprisingly long journey.
Browser
ā
Local DNS Cache
ā
ISP DNS Resolver
ā
Root DNS Server
ā
TLD Server (.com)
ā
Authoritative DNS Server
ā
IP Address Returned
ā
Browser Connects
All of this happens in milliseconds.
The internet is dramatic, but efficient.
DNS Caching: Working Smarter
DNS lookups happen constantly.
Repeating the entire lookup process every time would be wasteful.
So DNS results are cached.
Common cache locations:
Browser
Operating System
ISP
Benefits:
Faster lookups
Lower latency
Reduced DNS traffic
The best request is often the one you never have to make.
HTTP: The Language of the Web
Now that we've found the server, we need a way to communicate.
That's where HTTP comes in.
HTTP (HyperText Transfer Protocol) enables communication between clients and servers.
Every website you've ever visited depends on it.
HTTP Is Stateless
This is one of the most important interview concepts.
HTTP treats every request independently.
The server does not automatically remember previous requests.
Example:
Request #1
Login
Request #2
View Profile
Request #3
View Dashboard
By default, the server doesn't remember who sent those requests.
To maintain user state, applications use:
Cookies
Sessions
JWT Tokens
Without them, you'd be logging in every few seconds.
HTTP Methods
Different actions require different methods.
| Method | Purpose |
|---|---|
| GET | Read Data |
| POST | Create Data |
| PUT | Replace Resource |
| PATCH | Partial Update |
| DELETE | Remove Resource |
Think of them as different verbs for talking to a server.
HTTP Status Codes
Servers are surprisingly chatty.
They always tell you how things went.
2xx Success
200 OK
Everything worked.
3xx Redirection
301 Moved Permanently
The resource moved somewhere else.
4xx Client Errors
400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
429 Too Many Requests
You made a mistake.
Or at least the server thinks you did.
5xx Server Errors
500 Internal Server Error
503 Service Unavailable
This time, the server messed up.
It happens to the best of us.
Final Thoughts
Today's lesson revealed something interesting.
The internet isn't one giant system.
It's thousands of small systems working together.
IP addresses identify devices.
Ports identify applications.
TCP guarantees reliability.
UDP prioritizes speed.
DNS translates names into addresses.
HTTP allows communication between clients and servers.
Every time you open a website, all of these pieces quietly work together behind the scenes.
And somehow, after billions of requests every day, the internet still manages to keep everyone's secrets.
XOXO.
