TCP vs UDP - When to Use Each (Reliability vs Speed)
Imagine streaming a live sports event where delays ruin the experience, versus sending an important email where every bit must be correct.
Explain the differences between TCP and UDP, and when to use each protocol considering reliability and speed requirements.
Connection-oriented vs connectionless communicationReliability mechanisms like acknowledgments and retransmissionsUse cases favoring speed over reliability and vice versa- What happens if a UDP packet is lost during a live video stream?
- How does TCP handle network congestion and packet loss?
- What if an application requires both speed and reliability?
- What happens when a TCP connection is abruptly closed?
Interviewer thinks candidate lacks understanding of UDP's valid use cases
✅ Explain that UDP is suitable for applications prioritizing speed and can tolerate some loss, like live streaming or DNS
Interviewer doubts candidate's grasp of transport layer concepts
✅ Clarify TCP's three-way handshake is a transport layer mechanism independent of application protocols
Interviewer notes candidate's unrealistic expectations of TCP
✅ Explain TCP ensures reliable delivery through retransmissions but cannot prevent all network failures
Interviewer suspects candidate missed UDP's checksum feature
✅ Mention UDP includes a checksum for basic error detection but no retransmission
