Overview
TCP guarantees that bytes arrive in order, exactly once, with flow and congestion control — at the cost of handshakes, acknowledgements and head-of-line blocking. UDP just fires datagrams with no delivery guarantee, which makes it ideal when speed matters more than perfection and the app can tolerate (or handle) loss.
TCP vs UDP: key differences
| TCP | UDP | |
|---|---|---|
| Connection | Handshake, stateful | Connectionless |
| Reliability | Guaranteed, ordered | Best-effort, may drop/reorder |
| Overhead | Higher (ACKs, retransmit) | Minimal |
| Latency | Higher | Lower |
| Use cases | HTTP, DB, file transfer | Video/voice, gaming, DNS |
When to use TCP
Anything that must arrive intact and in order: web requests, database connections, file transfer, most application traffic.
When to use UDP
Real-time media, gaming, telemetry and DNS — where a dropped packet is better than a late one, or the app builds its own reliability (e.g. QUIC).
Verdict
Use TCP unless low latency and loss-tolerance specifically favour UDP. Modern protocols like QUIC/HTTP-3 run reliability on top of UDP to get the best of both.
Common questions
Is UDP faster than TCP?
UDP has lower latency and overhead because it skips handshakes and acknowledgements — but it provides no delivery guarantee, so "faster" only helps if your app tolerates loss.
Why does HTTP/3 use UDP?
HTTP/3 runs on QUIC, which is built on UDP to avoid TCP head-of-line blocking and enable faster connection setup, while re-implementing reliability and ordering itself.