Transport and Networking - olga-mir/playground GitHub Wiki

Understanding AI Applications Networking Specifics

Below is a summary artefact of my learning session with Claude Sonnet 4

Websockets aren't strictly related but they are often compared to SSE and I needed a refresher to understand the intricacies a bit better

Transport Protocols

SSE: Best for server→client notifications with automatic reconnection

HTTP Streaming: Flexible for any server→client streaming (AI responses, downloads)

WebSockets: Required for bidirectional communication, but more complex infrastructure

Feature Server-Sent Events (SSE) HTTP Streaming WebSockets
Protocol HTTP/1.1 or HTTP/2 HTTP/1.1 or HTTP/2 WebSocket protocol (ws://, wss://)
Direction Server → Client only Server → Client only Bidirectional
Connection Type Long-lived HTTP connection Long-lived HTTP connection Persistent TCP connection
Data Format Structured events (data:, event:, id:) Any format (JSON, text, binary) Any format (text/binary frames)
Reconnection Automatic with last event ID Manual implementation Manual implementation
Infrastructure Works with standard HTTP proxies/LBs Works with standard HTTP proxies/LBs May need proxy configuration
Complexity Simple Medium Higher
Use Cases Real-time notifications, live feeds AI streaming responses, file downloads Chat, gaming, real-time collaboration
Connection Overhead HTTP headers on initial request HTTP headers on initial request WebSocket handshake overhead
Server Implementation Simple (flush response buffer) Simple (flush response buffer) Complex (frame handling, ping/pong)
Compression Standard HTTP compression Standard HTTP compression Per-message compression extensions