DevPrep
  • Interview Prep
  • Projects
  • Resources
  • Pricing
  • About Us
Submit Question
DevPrep
  • Pricing
  • About Us
Submit Question
  1. Home
  2. Articles
  3. Frontend Engineering
  4. What is the Difference Between TCP and UDP?
XLinkedInReddit
MediumFrontend Engineering

What is the Difference Between TCP and UDP?

D
DevPrep Team
February 9, 2026·2 min read·0
Table of Contents
  • The One-Line Answer
  • TCP (Transmission Control Protocol)
  • UDP (User Datagram Protocol)
  • When to Use Which
  • TCP Use Cases
  • UDP Use Cases
  • The Frontend Connection: HTTP/3 and QUIC
  • WebRTC and UDP
  • Real-World Comparison
  • Summary

By Rahul — Google Frontend Engineer

The One-Line Answer

TCP guarantees delivery and order. UDP does not. That is the fundamental tradeoff — reliability vs speed.

TCP (Transmission Control Protocol)

  • Connection-oriented: 3-way handshake before data flows
  • Reliable: Every packet is acknowledged. Lost packets are retransmitted
  • Ordered: Packets are reassembled in the correct order
  • Flow control: Sender slows down if receiver cannot keep up
  • Congestion control: Reduces speed if the network is congested

UDP (User Datagram Protocol)

  • Connectionless: No handshake. Just fire and forget
  • Unreliable: No guarantee packets arrive
  • Unordered: Packets may arrive in any order
  • No flow/congestion control: Sends as fast as possible
  • Lightweight: 8-byte header vs TCP's 20-byte header

When to Use Which

TCP Use Cases

  • HTTP/HTTPS (web pages, APIs)
  • Email (SMTP, IMAP)
  • File transfers (FTP)
  • SSH
  • Any time you need every byte to arrive correctly

UDP Use Cases

  • DNS lookups (single request-response, fast)
  • Video streaming (dropping a frame is better than pausing)
  • Online gaming (old position data is useless, just send the latest)
  • VoIP (slight audio glitch is better than delay)
  • IoT sensor data (losing one reading out of thousands is fine)

The Frontend Connection: HTTP/3 and QUIC

HTTP/3 uses QUIC, which is built ON TOP of UDP. Why? TCP's head-of-line blocking slows down HTTP/2 when a single packet is lost. QUIC handles packet loss per-stream, so one lost packet does not block all other streams.

HTTP/1.1 → TCP (one request at a time per connection)
HTTP/2   → TCP (multiplexed, but head-of-line blocking)
HTTP/3   → QUIC over UDP (multiplexed, no head-of-line blocking)

WebRTC and UDP

WebRTC (used for video calls in the browser) uses UDP for media streams. If you have ever been on a video call where the video froze momentarily but the audio kept going — that is UDP at work. It dropped the video frames rather than delaying everything.

Real-World Comparison

TCP is like registered mail:
- Guaranteed delivery
- Confirmation of receipt
- Slow but reliable

UDP is like shouting across a room:
- Fast
- No confirmation they heard you
- Some words might get lost
- But for real-time conversation, it works better

Summary

TCP = reliable, ordered, connection-oriented. UDP = fast, unreliable, connectionless. The web is moving toward UDP-based protocols (QUIC/HTTP/3) that build reliability on top of UDP's speed. Understanding this helps you appreciate why modern web protocols are faster.

Related Articles

MediumFrontend Engineering

System Design #12: Design a Multi-Step Form Wizard

7 min read
MediumFrontend Engineering

Mastering Senior-Level JavaScript Interview Concepts

2 min read
MediumFrontend Engineering

System Design #9: Design a Collaborative Text Editor

9 min read

Comments (0)

Sign in to leave a comment.

No comments yet. Be the first to comment.

Table of Contents

  • The One-Line Answer
  • TCP (Transmission Control Protocol)
  • UDP (User Datagram Protocol)
  • When to Use Which
  • TCP Use Cases
  • UDP Use Cases
  • The Frontend Connection: HTTP/3 and QUIC
  • WebRTC and UDP
  • Real-World Comparison
  • Summary

Series

View all Frontend Engineering articles →

Practice

  • JavaScript
  • DSA
  • Machine Coding
  • System Design

Resources

  • Learning Tracks
  • Articles
  • Roadmaps
  • Compare Concepts
  • Glossary
  • Developer Tools
  • All Questions

Company

  • About
  • Pricing

Legal

  • Privacy Policy
  • Terms of Service
DevPrep

© 2026 DevPrep. All rights reserved.