TCP vs UDP
Reliable or fast.
Under HTTP, data is broken into small packets. Two protocols carry them. TCP makes sure every packet arrives, in order. UDP just sends them, and hopes for the best.

- Data in small packets
- TCP: every packet, in order
- UDP: send and hope
Two protocols
TCP starts with a handshake, numbers every packet, and resends anything that's lost. That makes it reliable, but a little slower. UDP skips all of that. It's faster, with less delay, but packets can be lost or arrive out of order. The application has to cope.
TCP: reliable
- Handshake firstResends lost packetsWeb, email, files
UDP: fast
- No handshakeLost is lostVideo calls, games, DNS
Choosing one
When should you use which? If every byte matters, like a web page, a payment, or a file, use TCP. If speed matters more than perfection, like a live video call, use UDP. A missing video frame is better than a frozen call. Newer protocols, like HTTP three, build reliability on top of UDP.
Summary
TCP is reliable and ordered, UDP is fast and loose. Most web traffic uses TCP. Next, the most common way to design an API. REST.
Key takeaways- TCP: reliable, ordered
- UDP: fast, lossy
- Pick by what matters