When would you choose UDP over TCP? Give real examples.
Choose UDP when speed and low delay matter more than perfect delivery, or when the app wants its own control: live video calls, online games, DNS lookups, and streaming. Old data is useless in real time, so waiting for a retransmission is worse than skipping it.
Explain it simply
On a live cricket commentary call, if one word is lost you would rather hear the next word than have the whole call pause until the missing word is resent. TCP would pause. UDP lets the stream continue.
Example
Use case Why UDP fits
Google Meet call stale audio is worthless; skip it
Online game latest position matters, not old positions
DNS query one small question, one small answer
Live broadcast same stream to many viewers (multicast)
QUIC / HTTP/3 builds its own reliability on top of UDPTCP guarantees order and delivery but pays for it with a handshake, retransmissions and head-of-line blocking. UDP adds almost nothing on top of IP: no connection, no ordering, no retransmission. If an app needs some of those, it builds them itself, choosing only what it needs.
File downloads, web pages, UPI payments and email need every byte exactly right, so they use TCP.
What to say in the interview
"UDP is connectionless and unreliable but low-overhead and low-latency. I would pick it for real-time media, games, DNS and as a base for QUIC. If correctness of every byte matters, such as payments or file transfer, TCP is the right default."
Common mistakes
- Saying UDP is always faster. It has less overhead, but it can lose data and flood a network without congestion control.