TCP vs UDP: When to Use Which
- Networking Fundamentals & OSI Model
- TCP/IP Model
- Network Topologies
- IP Addressing & Subnetting
- Routing Algorithms & Protocols
- Switching Concepts
- Transport Layer Protocols (TCP & UDP)
- Application Layer Protocols
- Network Security & Firewalls
- Wireless Networking & Wi-Fi
- Network Address Translation (NAT)
- DNS Deep Dive
- Congestion Control & Flow Control
- Error Detection & Correction
- Network Devices
- VPN & Tunneling
- Load Balancing & CDN Networking
- Socket Programming
- Network Troubleshooting Tools
- Physical Layer & Transmission Media
- Data Link Layer & MAC Addressing
- Ethernet Protocol
- ARP (Address Resolution Protocol)
- ICMP Protocol
- Unicast, Multicast, Broadcast and Anycast
- Proxy Servers
- Port Numbers Reference
- Network Performance Metrics
- Quality of Service (QoS)
- Software-Defined Networking (SDN)
- HTTP/2 and HTTP/3 Overview
- 5G and Mobile Networks
- IoT Networking Basics
- VoIP Networking Basics
The Core Trade-off
TCP guarantees reliable, ordered delivery at the cost of extra overhead and latency. UDP is fast and lightweight, but leaves reliability entirely up to the application, if it needs it at all. Choosing between them means deciding which of those two properties actually matters more for a given task.
Side-by-Side Comparison
| TCP | UDP | |
|---|---|---|
| Connection | Requires a handshake first | None - just send |
| Reliability | Guaranteed delivery, retransmits lost data | No guarantee - lost data stays lost |
| Ordering | Data arrives in the order it was sent | No ordering guarantee |
| Speed | Slower, due to handshakes and acknowledgments | Faster, minimal overhead |
| Typical uses | Web pages, file transfers, email | Video calls, gaming, DNS |
A Simple Way to Decide
- Does losing or reordering a piece of data break the whole thing? A corrupted file is unusable - choose TCP.
- Is slightly stale or missing data acceptable if it means staying fast? A dropped video frame is barely noticeable - choose UDP.
- Does the application already handle its own retries? DNS resolvers retry on their own, so UDP's simplicity is preferred there.
When Applications Add Their Own Reliability on Top of UDP
Some modern protocols (like QUIC, which underlies HTTP/3, covered in a later note) use UDP as their base but implement their own custom reliability and ordering logic on top of it - getting UDP's speed while still selectively guaranteeing delivery where it actually matters.