Networking & IoT · Interview question

When would you choose UDP over TCP?

A strong answer

When timeliness or low overhead matters more than guaranteed delivery, or when TCP's model doesn't fit. Real-time media (voice, video, telemetry) prefers UDP because a retransmitted late packet is useless, by the time it arrives the moment has passed, and TCP's head-of-line blocking would stall the stream waiting for a resend; it's better to drop the lost frame and keep going, optionally concealing the loss. DNS uses UDP because a query/response is a single small exchange where setting up a TCP connection would add round-trips for nothing. Multicast and broadcast require UDP, since TCP is strictly point-to-point. And constrained IoT devices favor UDP because TCP's per-connection buffers and state cost scarce RAM, and the handshake costs energy on a battery radio, which is why CoAP runs over UDP and adds its own lightweight, optional reliability. The general rule: pick UDP when you can tolerate (or handle yourself) loss/reordering and want minimal latency, overhead, and state; pick TCP when correctness and ordering are non-negotiable and you can afford the resources.

What a weak answer sounds like

You know the answer. Do you know what gets you dinged?

Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.

From the lesson

TCP vs UDP

The two transport protocols: TCP's connection, ordering, and retransmission (a reliable byte stream) vs UDP's connectionless best-effort datagrams, and which to pick on a constrained device.

More TCP vs UDP questions

Browse all 472 interview questions
When would you choose UDP over TCP? | EmbeddedPrep.io