FoundationNetworking

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

All 336 cloud engineer questions

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