2 Topics
Chapter•100 Minutes

Advanced Networking: HTTP/2, HTTP/3, TCP, and Real-Time Protocols

Understand connection behavior, protocol multiplexing, NAT limits, and the design of persistent real-time connections.

HTTP/2, HTTP/3, and Connection Reuse

HTTP/2 multiplexes streams over a TCP connection and compresses headers, reducing setup overhead. TCP packet loss can still delay streams sharing that connection. HTTP/3 uses QUIC over UDP and provides stream-level transport behavior that can reduce cross-stream head-of-line blocking.

Connection reuse avoids repeated TCP and TLS handshakes but keeps resources open and can preserve an unhealthy routing choice. Configure keep-alive, idle timeouts, connection draining, and pool sizes based on real intermediaries and workload. Protocol choice alone does not solve slow database queries, large payloads, or server queueing.

Measure DNS time, TCP connection time, TLS negotiation, time to first byte, and transfer duration separately. A single generic timeout obscures whether a problem is in name resolution, network setup, server processing, or response transfer.

Key Takeaways
  • HTTP/2 multiplexes over TCP; HTTP/3 uses QUIC.
  • Connection reuse reduces setup cost but consumes resources.
  • Break latency into distinct network and application phases.

TCP, NAT, Port Exhaustion, WebSockets, and SSE

TCP flow control protects the receiver; congestion control adapts sending behavior to network conditions. High connection churn to a small set of destinations can exhaust ephemeral ports or NAT state. Reuse connections where appropriate and monitor resets, retransmissions, connection counts, and NAT utilization.

WebSockets provide bidirectional persistent communication. Server-Sent Events (SSE) provide a server-to-client stream, while long polling holds HTTP requests open until data or a timeout is available. Select based on interaction direction, infrastructure compatibility, and client behavior.

Persistent connections require heartbeats, reconnect backoff, connection limits, graceful draining, and resume cursors. Real-time transport is not durable storage: clients should resynchronize from authoritative state after reconnecting.

Key Takeaways
  • Connection churn can exhaust ports or NAT tracking state.
  • WebSocket, SSE, and long polling have different interaction semantics.
  • Use cursors to recover missed events after reconnects.