When should you use TCP versus UDP?
Use TCP when all data must arrive intact and in order (databases, web, email); use UDP when speed and low latency matter more than perfect delivery (live video, VoIP, gaming).
The underlying trade-off is what to do about a packet problem. TCP buys reliability and ordering by adding handshakes, acknowledgments, and retransmissions, and those mechanisms add latency and overhead. UDP throws all of that away to be fast and lightweight. So the real question is which hurts this application more: a delayed packet or a missing one? For a bank transfer a missing byte is unacceptable, so you pay TCP's latency tax. For a live call, a retransmitted packet would arrive too late to be useful anyway, so UDP simply skips it and moves on, because a fresh audio sample beats a stale corrected one. That is also why interactive real-time media prefers UDP even though it could lose data: the application or codec tolerates the loss far better than it tolerates the stall TCP would cause while waiting for a resend.
Choosing the Right Protocol:
Use TCP for:
- Databases
- Web browsers
- Email clients
- Applications requiring all data to arrive intact
Use UDP for:
- Live video streaming
- VoIP (Voice over IP)
- Online gaming
- Applications that can tolerate some data loss
Key Decision Factor:
| Requirement | Protocol |
|---|---|
| Complete, accurate data | TCP |
| Speed over reliability | UDP |
| Ordered delivery needed | TCP |
| Real-time, low latency | UDP |
Example: If one or two segments of a live video stream fail to arrive, it causes only a momentary disruption that may not be noticeable to the user.
Go deeper:
TCP vs UDP Crash Course — Hussein Nasser frames the choice around latency vs guaranteed delivery.
QUIC — how HTTP/3 gets reliability on top of UDP, the modern twist on this trade-off.