FUNDAMENTALS & NETWORKING · SUBTOPIC
TCP vs. UDP
Understand reliable ordered streams (TCP) versus fast, connectionless datagrams (UDP).
BeginnerPart of Networking & Protocols
Subtopics in Networking & Protocols (2)
In plain words
TCP is registered mail with tracking numbers and signatures for every box. UDP is tossing postcards - fast and lightweight, though an occasional card might get lost.
Think of it like…
Writing an email (every letter must arrive accurately → TCP) vs. speaking live on a phone call (if a syllable glitches, keep talking → UDP).
Loading interactive diagram
Loading interactive exercise
Theory & how it works
When TCP hurts latency
Setting up a fresh TCP + TLS 1.2 connection takes multiple network round trips (~100–200 ms across regions). Reuse existing connections with keep-alive and connection pooling!
Key points & practical guide
Summary checklist
- TCP guarantees ordering and retransmission
- UDP skips handshakes and retries for minimal latency
- Always reuse TCP connections via pooling / keep-alive
When to use it
- TCP for APIs, databases, file transfers, chat text
- UDP for live video/audio (WebRTC), multiplayer games, DNS, QUIC
Watch out for
- Opening a new TCP+TLS connection on every internal microservice call without pooling
Quick check
Loading quiz