TCP vs UDP: Choose for a Scenario
Problem
For each of the following, choose TCP or UDP as the transport, and justify the choice from the protocol's guarantees and costs rather than from convention. Where a plain answer is misleading, say what the real deployed systems do.
- A video call between two people.
- A file transfer of a 4 GB build artifact between data centers.
- A DNS query from a laptop.
- Position updates in a fast multiplayer game, 30 times per second per player.
- A metrics agent sending 10,000 gauge samples per second from every host to a collector.
- A web browser fetching a page with 50 sub-resources over a lossy mobile network.
State the mechanisms in TCP that matter for each decision (ordering, retransmission, congestion control, head-of-line blocking, connection setup) and what you would have to build yourself if you picked UDP.
Examples
The protocol facts the six decisions rest on:
- TCP guarantees: bytes arrive in order, without gaps or duplicates, or the connection fails. It achieves this with sequence numbers, acknowledgements, retransmission of lost segments, and a receive window; it also runs congestion control that slows down when it detects loss.
- TCP costs: a three-way handshake (1 RTT) before data; a lost segment stalls delivery of everything after it until the retransmission arrives (head-of-line blocking), which on a 50 ms RTT link means a minimum ~50 ms stall and typically 200+ ms with retransmission timers; congestion control halves the send rate on loss; per-connection kernel state.
- UDP guarantees: none. Datagrams may be lost, reordered, or duplicated. There is no connection, no handshake, no retransmission, no congestion control, and the sender can push as fast as it likes.
- UDP costs: you own reliability, ordering, and fairness if you need them; middleboxes and some corporate firewalls block or throttle UDP; NAT traversal is more work.
- Reference latencies: last-mile RTT 20-50 ms on broadband, 30-60 ms on LTE; a voice packet is ~20 ms of audio; a 30 Hz game tick is 33 ms; loss rates on mobile are 0.1-1% and bursty.
Hints
- Ask of each scenario: if a packet is lost, is the old data still worth receiving late, or has it been superseded by newer data? That single question decides most cases.
- Head-of-line blocking is TCP's hidden cost: one lost packet delays every packet behind it. Where does that hurt, and where does it not matter?
- "UDP" in practice usually means "UDP plus a protocol on top" (RTP, QUIC, a game netcode). Say which one and what it adds back.
Last reviewed 8 September 2026
Approach · Answer · Complexity · Follow-ups · Company variations
The rest of this question — the worked approach, the Python solution with passing tests, complexity, follow-ups and how each company frames it — is part of the guides.
Get the full guide
Pick the company you're interviewing with. Each guide has every question tiered for that loop — one-time purchase, lifetime access.
Also in: Apple, Google, Meta, Microsoft, Netflix
Interviewing at more than one? All 6 guides for $499 · save $395
Not ready to buy? Get the free starter pack — 13 questions with full solutions.