CodeWithYash
DSA
Spring Boot
System Design
Series
Articles
Leaderboard
Sign In

Subscribe to Newsletter

Get the latest articles, DSA sheets, and system design challenges delivered to your inbox.

<CODEWITHYASH/>

The ultimate sanctuary for software engineers seeking deep mastery of core technical principles.

Library

  • Articles
  • DSA Sheets
  • Roadmaps

Connect

  • GitHub
  • LinkedIn
  • About
  • Contact

Legal

  • Privacy
  • Terms
  • Support

© 2026 CodeWithYash Global Systems.

Status: OperationalVersion: 4.2.0
System Design
OverviewTheory lessonsHLDLLD
All SeriesSeries
Distributed Systems

System Design Series

0%

0 of 33 topics completed

Progress
Hardware Numbers Every Systems Engineer Must KnowCore
20 min
Network Protocols & Real-Time Communication ParadigmsCore
25 min
Latency vs. Throughput & The Tail at ScaleCore
25 min
Scalability Dimensions & Universal LawsCore
25 min
Availability, SLOs, SLIs & Error BudgetsCore
20 min
ACID vs. BASE & The Consistency SpectrumCore
30 min
CAP Theorem & PACELC FrameworkCore
25 min
System DesignFoundations & Mental ModelsNetwork Protocols & Real-Time Communication Paradigms

Foundations · Phase 1: Foundations

Network Protocols & Real-Time Communication Paradigms

Compare TCP, UDP, QUIC (HTTP/3), gRPC Protocol Buffers, WebSockets, Server-Sent Events, and Long Polling for high-performance and real-time architectures.

Primary specification: RFC 9000: QUIC - A UDP-Based Multiplexed and Secure Transport

Written & reviewed by Yash Patel 25 minBaseline 2026.1 Curated Blueprint· Verified 2026-09-14

Lesson 2 of 33

1d streak

The Architectural Question

Developers default to polling or raw WebSockets for all real-time requirements, causing server file descriptor exhaustion and high mobile battery drain.

Core Engineering Objectives

  • TCP flow control, sliding window, slow-start, and head-of-line blocking vs UDP datagrams
  • HTTP/1.1 vs HTTP/2 binary multiplexing vs HTTP/3 QUIC independent streams over UDP
  • Bi-directional WebSockets vs uni-directional Server-Sent Events (SSE) vs Short/Long polling

1. What is it & Why it Matters

Network protocols govern how distributed systems transmit bytes across the wire. Selecting the optimal protocol dictates latency floors, connection overhead, packet loss recovery, and real-time streaming capabilities.

Why it matters in System Design

Defaulting to standard HTTP/1.1 or raw WebSockets for every service causes connection exhaustion, mobile battery drain, and head-of-line blocking. Choosing the right protocol (gRPC for internal microservices, SSE for 1-way streams, WebSockets for 2-way chat) eliminates infrastructure waste.

2. Transport Layer: TCP vs. UDP vs. QUIC

ProtocolHandshake OverheadOrdering & ReliabilityHead-of-Line (HoL) BlockingBest Use Case
TCP1 RTT handshake (SYN, SYN-ACK, ACK) + 1-2 RTT for TLSStrictly ordered, guaranteed delivery via retransmissionsYes: 1 dropped packet stalls entire connection stream in OS kernelWeb browsing, file transfer, transactional APIs
UDP0 RTT (connectionless datagrams)Unreliable: packets may drop, duplicate, or arrive out of orderNo: packets are completely independentLive video streaming, gaming state broadcast, DNS lookups, WebRTC
QUIC (HTTP/3)0-1 RTT (combines transport & TLS 1.3 handshake over UDP)Reliable delivery with independent stream orderingTransport-level stream blocking is reduced; connection-level congestion can still affect streamsMobile web apps, flaky wireless networks, modern CDNs

3. Application Protocols: HTTP Evolution and gRPC

  1. 01HTTP/1.1: Text-based, synchronous request-response. Suffers from HTTP head-of-line blocking: each TCP connection handles only one request at a time, requiring browser connection pooling (6 connections per host).
  2. 02HTTP/2: Binary framing, multiplexes multiple virtual streams over a single TCP connection, supports header compression (HPACK) and server push. Still vulnerable to TCP packet-loss head-of-line blocking.
  3. 03HTTP/3 (QUIC): Replaces TCP with QUIC over UDP. Eliminates transport head-of-line blocking and supports connection migration (maintains active downloads when client switches from Wi-Fi to cellular).
  4. 04gRPC: RPC framework commonly used with HTTP/2 and Protocol Buffers. It provides generated types, streaming, and deadline propagation; benchmark it against alternatives for the actual payload and network.

Architectural Boundary · Do Not Confuse

Concept A

REST over HTTP/1.1 (JSON text payloads)

Concept B

gRPC over HTTP/2 (Protocol Buffer binary payloads)

REST/JSON is human-readable and universally supported by browsers, making it the standard for public APIs. gRPC is compact, CPU-efficient, and multiplexed, making it the gold standard for high-volume internal microservice RPCs.

4. Real-Time Web: WebSockets vs. SSE vs. Polling

TechnologyDirectionalityTransport ProtocolState Overhead on ServerOptimal Workload
Short / Long PollingClient → ServerStandard HTTPLow (stateless requests, but high connection churn)Legacy systems, low-frequency updates (> 30s)
Server-Sent Events (SSE)Server → Client (1-way)HTTP/2 streamingLow: runs over standard HTTP, native browser reconnectionStock tickers, sports scores, AI token generation, push notifications
WebSocketsBidirectional (Full Duplex)TCP upgrade (ws://)High: server must maintain persistent state machine and heartbeats per socketMultiplayer gaming, collaborative document editing, real-time chat

Use it when

Consider Server-Sent Events when updates are only server-to-client and ordinary HTTP infrastructure is valuable. Browsers reconnect automatically, but the application still needs event IDs, replay, authorization, and failure handling.

Reconsider when

Use WebSockets when true bidirectional, low-latency client-to-server messaging is required (e.g., chat typing indicators, gaming controller inputs).

5. Protocol Selection Cheat Sheet for Interviews

  1. 01Public Web / Mobile Client → API: HTTP/2 or HTTP/3 HTTPS with JSON or Protobuf.
  2. 02Internal Microservice → Microservice: gRPC with Protocol Buffers and client-side load balancing.
  3. 03Live Chat / Multiplayer Game: WebSockets for full-duplex bidirectional messaging.
  4. 04Dashboard / LLM Output Streaming: Server-Sent Events (SSE).
  5. 05Video / Audio Conferencing: WebRTC over UDP.

6. Active Recall Checkpoint

Active Recall Checkpoint

Why does HTTP/2 still suffer from Head-of-Line (HoL) blocking despite supporting stream multiplexing, and how does HTTP/3 solve it?

Hint: Think about the difference between application-layer multiplexing and transport-layer TCP packet delivery.

Show answer & explanation

HTTP/2 multiplexes multiple streams over a single Layer 4 TCP connection. Because TCP enforces strictly ordered byte delivery, if a single IP packet drops, the OS kernel pauses delivery of all multiplexed streams until the lost packet is retransmitted. HTTP/3 replaces TCP with QUIC over UDP, tracking retransmissions independently per stream so loss recovery is ordered per stream; shared congestion control and network conditions can still affect the connection.

Production Postmortem & Verification

Production Incident Postmortem

  1. Trigger / Setup: A news notification service connects 500,000 mobile clients over persistent bidirectional WebSockets for occasional 1-way breaking alerts.
  2. Production Symptom: Server clusters consume 80GB of RAM purely maintaining idle WebSocket state machines and heartbeats, crashing the edge tier.
  3. Root Cause & Fix: Unidirectional alerts should leverage HTTP/2 Server-Sent Events or mobile push networks (FCM/APNS) rather than stateful WebSockets.

Acceptance Criteria & Outcomes

  • Contrast TCP handshakes and packet loss recovery with UDP zero-connection delivery.
  • Explain how HTTP/3 QUIC eliminates TCP head-of-line blocking across mobile network handovers.
  • Select the optimal protocol (WebSockets, SSE, gRPC, Long Polling) based on directionality, multiplexing, and reconnection constraints.

End-of-Chapter Synthesis & Key Takeaway

Network Protocols & Real-Time Communication Paradigms is built around one fundamental rule: Establish clear responsibility and explicit trade-offs.. Before adding components, establish explicit quantitative SLAs for latency, throughput, and consistency. Choose the simplest architecture that meets stated constraints.

Architectural & Technical Interview Review

Core FAANG Interview Questions

3 Questions
Q01
How do you justify introducing Network Protocols & Real-Time Communication Paradigms into a high-scale production architecture?
Click to reveal model answer →Hide answer ↑Requirements & Design Brief

Introduce Network Protocols & Real-Time Communication Paradigms only when measured scale, data size, or failure boundaries exceed single-node capacity. State the exact bottleneck, evaluate operational overhead, and verify that the trade-offs justify the added moving parts.

Source section: Requirements & Design Brief
Q02
What is the primary trade-off and hidden operational cost of Network Protocols & Real-Time Communication Paradigms?
Click to reveal model answer →Hide answer ↑Architecture Trade-offs

It improves scalability and availability, but introduces network hops, serialization overhead, and eventual consistency or coordination complexity.

Source section: Architecture Trade-offs
Q03
How do you handle catastrophic failure or dependency degradation in Network Protocols & Real-Time Communication Paradigms?
Click to reveal model answer →Hide answer ↑Failure Review & Recovery

Implement connect/read timeouts, exponential backoff with jitter, and fallback defaults so downstream degradations do not cause cascading outages.

Source section: Failure Review & Recovery

Production Pitfalls & Anti-Patterns

Critical Failure Anti-Patterns

!

Premature Distributed Complexity

Scattering distributed components before identifying concrete write, read, or storage limits creates accidental points of failure and operational debt.

Production Mitigation: Start with the simplest modular design that satisfies requirements, evolving it only as measured constraints dictate.

!

Unbounded Retries and Cascading Storms

When a dependency degrades, immediate synchronized retries multiply downstream traffic, turning a minor slowdown into a total fleet outage.

Production Mitigation: Enforce strict retry budgets, exponential backoff, and full randomized jitter on all client calls.

!

Neglecting Observability and Metrics

Deploying architecture without distributed tracing or p99 tail latency alerts leaves engineers blind when partial partitions occur.

Production Mitigation: Export metrics for request rate, error rate, p95/p99 duration, and saturation at every service boundary.

Primary Documentation & Specifications

RFC 9000: QUIC - A UDP-Based Multiplexed and Secure Transport
Previous LessonHardware Numbers Every Systems Engineer Must KnowFoundationsNext LessonLatency vs. Throughput & The Tail at ScaleFoundations

In this chapter

01Architectural Question021. What is it & Why it Matters032. Transport Layer: TCP vs. UDP vs. QUIC043. Application Protocols: HTTP Evolution and gRPC054. Real-Time Web: WebSockets vs. SSE vs. Polling065. Protocol Selection Cheat Sheet for Interviews076. Active Recall Checkpoint08Production Verification09Synthesis & Review10Primary References

Chapter promise

TCP flow control, sliding window, slow-start, and head-of-line blocking vs UDP datagrams