TCP vs UDP: Key Differences and the Applications That Suit Each

Read the full interview experience this question came from →

Quick Overview

From a TikTok backend intern interview: compare TCP and UDP, including connection setup, reliability, ordering, flow and congestion control, message boundaries and overhead, and explain which applications suit each protocol. It tests tying transport-layer guarantees and their costs to real application needs.

TCP vs UDP: Key Differences and the Applications That Suit Each

Company: ByteDance

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Technical Screen

Compare TCP and UDP. Explain how the two transport protocols differ, and for each one, describe the application scenarios where it is the right choice and why. ```hint Go beyond reliable versus unreliable List what TCP actually guarantees (connection setup, ordering, retransmission, flow and congestion control), what each guarantee costs in latency or overhead, and which applications would rather not pay that cost. ``` ### Clarifying Questions - Should the comparison stay at the transport layer, or also cover protocols built on top of UDP that add their own reliability? - Is there a specific workload in mind, such as the e-commerce backend services this team builds, or is a general comparison wanted? ### What a Strong Answer Covers - Connection model: the handshake and teardown of TCP versus connectionless datagrams - Delivery semantics: an ordered, reliable byte stream versus datagrams that may be lost, duplicated or reordered, and what each means for message boundaries - Flow control, congestion control and header overhead, plus the latency cost of retransmission and head-of-line blocking - Scenarios matched to each protocol with the deciding property, not just a list of names - How applications that need some reliability over UDP add it themselves ### Follow-up Questions - Why does DNS normally use UDP, and when does it fall back to TCP? - What is head-of-line blocking in TCP, and how does QUIC avoid it while running over UDP? - What is the TIME_WAIT state, and why can a client that opens many short-lived TCP connections run into trouble? - TCP delivers a byte stream. How does an application on top of it know where one message ends and the next begins?

Overview: From a TikTok backend intern interview: compare TCP and UDP, including connection setup, reliability, ordering, flow and congestion control, message boundaries and overhead, and explain which applications suit each protocol. It tests tying transport-layer guarantees and their costs to real application needs.

Read the full ByteDance Software Engineer interview experience this question came from

|Home/Software Engineering Fundamentals/ByteDance
ByteDance logo
ByteDance
Sep 25, 2026
mediumSoftware EngineerTechnical ScreenSoftware Engineering Fundamentals
0
0

Compare TCP and UDP. Explain how the two transport protocols differ, and for each one, describe the application scenarios where it is the right choice and why.

Clarifying Questions Guidance

  • Should the comparison stay at the transport layer, or also cover protocols built on top of UDP that add their own reliability?
  • Is there a specific workload in mind, such as the e-commerce backend services this team builds, or is a general comparison wanted?

What a Strong Answer Covers Guidance

  • Connection model: the handshake and teardown of TCP versus connectionless datagrams
  • Delivery semantics: an ordered, reliable byte stream versus datagrams that may be lost, duplicated or reordered, and what each means for message boundaries
  • Flow control, congestion control and header overhead, plus the latency cost of retransmission and head-of-line blocking
  • Scenarios matched to each protocol with the deciding property, not just a list of names
  • How applications that need some reliability over UDP add it themselves

Follow-up Questions Guidance

  • Why does DNS normally use UDP, and when does it fall back to TCP?
  • What is head-of-line blocking in TCP, and how does QUIC avoid it while running over UDP?
  • What is the TIME_WAIT state, and why can a client that opens many short-lived TCP connections run into trouble?
  • TCP delivers a byte stream. How does an application on top of it know where one message ends and the next begins?
Loading comments...