Interview's MateSystem Design
Interview's Mate

System Design

Architecture & trade-offs

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
All topics/Networking & Protocols
FUNDAMENTALS & NETWORKING · SUBTOPIC

TCP vs. UDP

Understand reliable ordered streams (TCP) versus fast, connectionless datagrams (UDP).

BeginnerPart of Networking & Protocols
Practice in AI HLD
Subtopics in Networking & Protocols (2)
OverviewTCP vs. UDPHTTP/2, QUIC & gRPC

In plain words

TCP is registered mail with tracking numbers and signatures for every box. UDP is tossing postcards - fast and lightweight, though an occasional card might get lost.

Think of it like…

Writing an email (every letter must arrive accurately → TCP) vs. speaking live on a phone call (if a syllable glitches, keep talking → UDP).

Loading interactive diagram
Loading interactive exercise

Theory & how it works

When TCP hurts latency

Setting up a fresh TCP + TLS 1.2 connection takes multiple network round trips (~100–200 ms across regions). Reuse existing connections with keep-alive and connection pooling!

Key points & practical guide

Summary checklist

  • TCP guarantees ordering and retransmission
  • UDP skips handshakes and retries for minimal latency
  • Always reuse TCP connections via pooling / keep-alive

When to use it

  • TCP for APIs, databases, file transfers, chat text
  • UDP for live video/audio (WebRTC), multiplayer games, DNS, QUIC

Watch out for

  • Opening a new TCP+TLS connection on every internal microservice call without pooling

Quick check

Loading quiz
Parent topic
Networking & Protocols
Next subtopic
HTTP/2, HTTP/3 (QUIC) & gRPC