TCP or UDP: how do you choose for an application?
BeginnerScenarioPerformance, MTU, Latency & Tools
Answer
Situation read → Reliability and ordering versus latency and overhead.
What I'd do →
- TCP gives ordered, reliable delivery with congestion control, good for web, databases, APIs
- UDP has no handshake or retransmit, good for DNS, real-time media, gaming and QUIC (which builds reliability on top)
- Test UDP reachability with
nc -u -vz host 53 - Open the correct protocol in security groups, since TCP rules don't cover UDP
Why → TCP trades latency for guarantees; UDP leaves reliability to the application.
Interview tip → Say HTTP/3 is reliable but runs on UDP through QUIC.
More on Performance, MTU, Latency & Tools
Latency, bandwidth and throughput: what is the difference and why does it matter?BeginnerWhen do you use ping, traceroute and mtr?BeginnerWhat is MTU and what is the usual value?BeginnerHow do you check what is listening on a port and who is connected?BeginnerHow do you measure where time goes in a slow HTTP request?BeginnerWhat does tcpdump do and what are the first filters you use?Beginner