Foundations: Linux, scripting, Git & networking
TCP vs UDP
TCP and UDP are the two transport protocols (layer 4) that almost all traffic rides on. TCP gives applications a reliable, ordered byte stream at the cost of handshakes, acknowledgements and congestion control; UDP sends independent datagrams and leaves reliability to the application. Senior interviews go past "TCP is reliable, UDP is fast": they ask how TCP achieves reliability and why packet loss hurts throughput so much, why DNS uses both, why HTTP/3 moved to UDP, how load balancers and NAT treat each protocol, and how to diagnose transport-level problems in production.
After this topic you can
- Choose between TCP and UDP for a workload
- Explain ports, connections and reliability
- Recognise symptoms of packet loss and timeouts
Lessons
-
1The transport layer: ports and sockets
- What layer 4 adds
- Sockets and connections
-
2TCP in depth
- Properties
- The TCP header
- Reliability: sequence numbers, ACKs and retransmission
- Flow control: the receive window
- Congestion control: why loss kills throughput
- Nagle, delayed ACKs and latency
- Keepalive and idle timeouts
- Head-of-line blocking
- TCP Fast Open
-
3UDP in depth
- Properties
- Why choose UDP
- QUIC and HTTP/3
-
4Comparison and protocol mapping
- TCP vs UDP
- Which protocol uses what
- DNS: the protocol that uses both
-
5Operating TCP and UDP services
- Firewalls and NAT
- Load balancers
- Kubernetes
- Security group rules to remember
- Application patterns
-
6Performance and troubleshooting
- Inspecting connections
- Measuring and testing
- Symptom guide
- Kernel tuning you might mention
- 7Security: floods and amplification
-
8Interview questions and model answers
- "TCP vs UDP — when would you pick UDP?"
- "How does TCP guarantee delivery?"
- "Why does 1% packet loss hurt TCP throughput so much?"
- "Why does DNS use both UDP and TCP?"
- "Why did HTTP/3 move to UDP?"
- "Pods see random 5-second delays on outbound calls. What's going on?"
- "How do you load balance a UDP service on AWS?"