CodePark/ questions / TCP vs UDP
START PRACTICINGPRACTICE
Backend question · OS, networking & Linux › TCP vs UDP

Which of these normally runs over UDP rather than TCP?

A typical DNS query to a resolver

"A typical DNS query to a resolver" is right. DNS queries normally use UDP on port 53. The query is one small question and one small answer, so a TCP handshake (the setup messages before a connection opens) is not worth the extra time. DNS switches to TCP for large responses and for zone transfers (copying a whole DNS zone between servers).

"An SSH session", "A PostgreSQL client connection" and "An HTTP/1.1 request" are wrong. They all need a reliable, ordered stream of bytes, so they run on TCP.