What is the difference between TCP and UDP, and when would you choose each?
What they are really testing: Whether you understand the reliability-versus-overhead trade-off, not just the labels. They want you to connect each protocol to real workloads.
A real interview question
What is the difference between TCP and UDP, and when would you choose each?
What most people say
drag me
“TCP is reliable and UDP is fast, so you usually want TCP.”
It memorizes the adjectives without the why, and "usually want TCP" misses that UDP is the right call for real-time and DNS. No connection to actual workloads.
The follow-ups they ask next
Why does DNS mostly use UDP?
A query and response are tiny and fit in one packet, so the handshake overhead of TCP is not worth it; if the response is too large or truncated, the resolver retries over TCP.
What problem does TCP congestion control solve?
It stops senders from overwhelming the network: TCP probes for available bandwidth and backs off on loss, which keeps shared links from collapsing under congestion.
What the interviewer is listening for
- Ties each protocol to real workloads
- Knows DNS and real-time use UDP
- Mentions ordering/retransmission/congestion control
What sinks the answer
- Just "TCP reliable, UDP fast"
- Thinks TCP is always the safe default
- Cannot name a UDP use case
If you genuinely do not know
Say this instead of freezing. Reasoning out loud from what you do know beats silence every single time, and a good interviewer is listening for exactly that.
“TCP is [connection-oriented: handshake, then reliable ordered delivery with congestion control]. UDP is [connectionless: no guarantees, lower latency, app handles loss]. I pick TCP for [HTTP, SSH, databases, where every byte matters] and UDP for [live video/voice, gaming, DNS, where fresh beats complete].”
Keep going with networking
Foundation
What is a VPC, and what is a subnet within it? Why split a network into subnets at all?
Foundation
What happens, step by step, when you type a URL into a browser and press enter?
Foundation
How does DNS resolution actually work, and what is the difference between an A record and a CNAME?
Foundation
What is the difference between IPv4 and IPv6, and why does IPv6 exist?
Junior
An EC2 instance in a private subnet needs to download OS updates from the internet. Walk me through how you make that work, and why.
Junior
In AWS, what is the difference between a security group and a network ACL, and when would you reach for each?
Knowing the answer is not the same as recalling it under pressure
Sign in to send the questions you fumble to spaced recall, so they come back right before you would forget them, and learn the concepts behind them with hands-on labs.
Start free