KatInterview

Real-Time Web Communication and Network Protocol Fundamentals

System DesignModel answer
HardModel answerSystem Designnetworkingprotocolsreal-time

Last updated

Evaluate trade-offs between real-time communication approaches and demonstrate understanding of network protocol layers and modern transport mechanisms.

You're architecting real-time capabilities for a web platform. This discussion explores your networking fundamentals across multiple protocol layers, focusing on practical engineering decisions rather than theoretical knowledge.

Address each section independently. Emphasize communication flow, protocol mechanics, performance characteristics, and production considerations. Avoid generalizations—specificity matters.

Context & Constraints

  • Target environment: contemporary browsers, cloud infrastructure with reverse proxies and load balancers fronting stateless application servers
  • "Real-time" means low-latency message delivery, not hard real-time systems guarantees
  • All traffic over HTTPS; TLS is mandatory
  • Consider behavior across both reliable wired connections and unreliable mobile networks

Questions to Explore First

  • What's the message flow pattern: server-push only, client-send only, or full bidirectional?
  • What scale are we targeting: concurrent connections and per-client message frequency?
  • What network intermediaries exist: CDNs, corporate proxies, firewalls that might buffer, timeout, or block certain protocols?
  • Which client platforms matter: browsers exclusively, native mobile apps, embedded devices? Any legacy compatibility requirements?
  • What guarantees do we need: fire-and-forget or reliable delivery with resumption?

Section 1: Real-Time Communication Approaches

Analyze WebSocket, Server-Sent Events, and long polling across these dimensions:

  • Communication patterns (unidirectional vs. bidirectional)
  • Underlying transport and connection lifecycle
  • Client/browser compatibility landscape
  • Reconnection handling and message resumption
  • Infrastructure implications: load balancer affinity, proxy buffering, connection pooling
  • Representative use cases

Provide a decision framework for selecting among these three approaches.

Section 2: Network Layer Models

Describe each layer of the OSI reference model: its role and a concrete protocol or technology example. Then explain how OSI's seven layers correspond to the TCP/IP model's four layers, and why practitioners typically work with the simplified model.

Section 3: Transport Protocol Evolution

Compare TCP and QUIC on:

  • Execution environment (kernel vs. userspace)
  • Connection setup overhead and handshake steps
  • TLS integration approach
  • Stream multiplexing and head-of-line blocking behavior
  • Connection portability across network changes
  • Scenarios favoring QUIC (like HTTP/3) and arguments against adopting it

Include the practical deployment and operational trade-offs, not just feature comparisons.

Hints

Hint 1

Consider what happens when a load balancer must route subsequent messages from a long-lived connection

Hint 2

Think about the difference between blocking at the transport layer versus blocking at the application protocol layer

Hint 3

Modern protocols like QUIC encrypt more of the packet, which affects both security and operational visibility