TCP vs UDP: When Each Wins, in Plain Terms
TCP and UDP are not interchangeable. The choice is workload-shaped; the consequences are operational.
What each guarantees
TCP: ordered, reliable, congestion-controlled.
UDP: best-effort; you handle ordering and loss.
When TCP wins
- Anything where loss = wrong outcome.
- Most app traffic; APIs; databases.
- HTTP/1.1; HTTP/2.
When UDP wins
Real-time media (occasional loss tolerable).
Game state (latest position matters).
DNS (small, single-packet).
Custom protocols where you handle reliability yourself (HTTP/3, QUIC).
HTTP/3 case study
HTTP/3: built on QUIC (UDP); custom reliability + congestion control in user space.
Bypasses TCP head-of-line blocking; better on lossy networks.
Antipatterns
- UDP for ‘speed’ without handling loss. Bugs.
- TCP for fire-and-forget telemetry. Overkill.
- Mixing both for the same flow. Confusion.
What to do this week
Three moves. (1) Apply this pattern to your highest-risk network path. (2) Measure the failure mode rate before/after. (3) Document the change so the next incident-responder inherits the knowledge.