Skip to main content

Command Palette

Search for a command to run...

TCP vs UDP (and where HTTP fits): the “rules of the internet”

Updated
8 min read

When I first started learning web dev, I thought the internet was basically:

“Browser sends something… server sends something… page appears.”

Then I met three acronyms that kept popping up: TCP, UDP, and HTTP.

They’re not the same thing. They don’t even live at the same “layer” of the network stack. But they work together all the time.

This article is the mental model I wish I had early on—behavior and use cases, not deep packet internals.


1) The internet needs rules to send data

At the lowest practical level, sending data over the internet is like moving boxes through a huge city:

  • boxes can get lost
  • boxes can arrive late
  • boxes can arrive out of order
  • boxes can arrive twice

So we need rules for how to deliver data from one machine to another.

That’s where transport protocols like TCP and UDP come in.


2) What are TCP and UDP (very high level)

TCP (Transmission Control Protocol)

TCP is like a careful, reliable conversation.

  • It establishes a connection first
  • It makes sure data arrives
  • It keeps data in order
  • It retransmits if something is missing

Analogy: a phone call + written receipts
Or a courier service that requires signatures and re-sends if needed.

UDP (User Datagram Protocol)

UDP is like sending quick messages into the air.

  • No connection setup
  • No built-in guarantee it arrives
  • No built-in ordering
  • No built-in retransmission

Analogy: a live announcement / walkie-talkie broadcast
Or throwing postcards: fast, but you don’t get delivery confirmation.


3) Key differences between TCP and UDP

Here’s the simplest “behavior-level” comparison:

FeatureTCPUDP
Connection setupYesNo
Reliability (guaranteed delivery)Yes (built-in)No (app must handle if needed)
OrderingYesNo
RetransmissionYesNo
Speed/latencyUsually higher overheadOften lower overhead
Best forcorrectnessreal-time responsiveness

Important beginner truth:

UDP isn’t “bad.” It’s just “don’t slow me down; I’ll deal with losses.”


4) TCP vs UDP communication flow (big diagram)

This is a high-level picture of what typically happens.

If you remember nothing else: TCP tries hard to be correct, UDP tries hard to be fast.


5) When to use TCP

I mentally choose TCP when I’m thinking:

“If even one part is missing or scrambled, this is basically broken.”

Typical TCP-friendly situations:

  • Web pages (classic HTTP/1.1 and HTTP/2 normally run over TCP)
  • Login/auth flows (you want correctness)
  • APIs (requests/responses must be accurate)
  • File downloads / uploads
  • Email (SMTP/IMAP)
  • SSH (remote terminal)

If a single missing packet would ruin the result, TCP is a good default.


6) When to use UDP

I mentally choose UDP when I’m thinking:

“It’s more important to be on time than to be perfect.”

UDP-friendly situations:

  • Voice calls / video calls
  • Live streaming
  • Online gaming (real-time updates)
  • DNS lookups (often UDP; can fall back to TCP in some cases)

Why UDP works well here:

  • If one tiny piece is missing, it’s often better to skip it and continue than to pause and wait.

Real example feeling:

  • In a video call, a half-second freeze is worse than a tiny visual glitch.

Also: many UDP-based apps implement their own reliability only where needed, rather than paying TCP’s overhead for everything.


7) Common real-world examples of TCP vs UDP

Here’s a practical mapping (not a law of nature, just the usual defaults):

Use caseUsuallyWhy
Loading websites (HTTP/1.1, HTTP/2)TCPcorrectness matters
REST APIsTCPrequest/response must be correct
File downloadTCPmust arrive complete
Video call / VoIPUDPlow latency > perfection
Online multiplayer updatesUDPfast state updates
DNS queryUDP (often)small, quick requests

8) OSI / TCP‑IP layer mapping (simplified)

This is where a lot of beginner confusion comes from: HTTP and TCP are not the same kind of thing.

HTTP is an application-layer protocol. TCP/UDP are transport-layer protocols.

The main takeaway:

  • HTTP defines what messages mean (GET, POST, headers, status codes).
  • TCP/UDP define how messages travel between machines.

9) What is HTTP and where it fits?

HTTP (HyperText Transfer Protocol) is the language your browser and a web server use to communicate about web stuff:

  • “GET /products
  • “POST /login
  • “Here are headers”
  • “Here’s a response status: 200 / 404 / 500”
  • “Here is HTML / JSON / an image”

HTTP is not responsible for guaranteeing delivery on its own.

HTTP assumes:

“I can send bytes to the other side somehow.”

That “somehow” is usually TCP.


10) Relationship between TCP and HTTP (and why HTTP doesn’t replace TCP)

A clean way to say it:

  • TCP is a reliable pipe (transport).
  • HTTP is the conversation you have through that pipe (application rules).

Why HTTP does not replace TCP

Because HTTP doesn’t do transport jobs like:

  • retransmitting lost packets
  • ordering chunks correctly
  • dealing with duplicates
  • managing connection state at the transport level

If you removed TCP and tried to do everything with “just HTTP,” you’d still need to reinvent the transport rules underneath.


11) HTTP request flowing over a TCP connection (sequence diagram)

This is the typical story for “browser loads a page” at a high level:

If you’ve ever wondered “why do we talk about TCP when I’m just learning HTTP?” — it’s because HTTP needs a transport to carry it.


12) Common beginner confusion: “Is HTTP the same as TCP?”

No—and the easiest way to keep them separate is to ask:

  • HTTP answers: “What does this message mean?”
  • TCP/UDP answer: “How do we move the message between machines?”

Another quick mental check:

  • If you’re discussing GET, POST, headers, status codes → HTTP
  • If you’re discussing reliability, packet loss, ordering, handshake → TCP
  • If you’re discussing speed/latency without guaranteed delivery → UDP

13) Real-world use cases mapped to TCP or UDP (big tree diagram)

This is the “cheat sheet tree” I keep in my head.


Wrap-up (what I’d actually remember)

  • TCP = reliable, ordered, connection-based (safe)
  • UDP = fast, connectionless, best-effort (risky but useful)
  • Use TCP when correctness matters (web pages, APIs, files)
  • Use UDP when real-time matters (calls, games, live updates)
  • HTTP is not a transport protocol.
  • HTTP usually runs on top of TCP.
  • HTTP doesn’t replace TCP; it depends on transport to move bytes reliably.