Skip to main content
Network Protocols
HTTP, WebSocket, gRPC, WebRTC
Communication Protocol?
- a protocol is a set of rules that govern how data is exchanged over the network
Multiplexing
- to allow multiple requests and responses to be multiplexed over a single connection
TCP vs UDP
- TCP is reliable, every packet needs a confirmation of receival
- UDP is fast, data packets may be lost, ideal for streaming services where a dropped frame doesn't matter that much
- Network round trip time is the limiting factor in TCP throughput and performance in most cases, consequently, latency is the performance bottleneck and most web applications deliver over it.
- TCP was built to handle long-lived connections and to transfer a lot of data.
HTTP/1
- only from client to the server
- developed for traditional website scenarios where data is fetched on a per-needed basis
- HTTP/1 are designed to open a bunch of short-lived TCP connections and usually only send small pieces of data
HTTP/1 Real-Time
- Short Polling: periodic small requests
- Long Polling: same as short polling, but server holds each connection open for a little while just in case some updates comes in. Less requests than short polling, but longer time for each request if no updates
-
Server-Sent Events (SSE): client opens a connection and hold it open, server push updates to client in real-time. Client can't send data to server.
HTTP/1.1
- HTTP/1 only allows one request/response per TCP connection, HTTP/1.1 allows multiple request/response in the same TCP connection. But these requests and responses are run in sequential order: request->reposne->request->response->... and so on. This is the head-of-line blocking
- It is possible to do parallelism: open multiple TCP connections at the same time, but browsers only allow up to 6 connections to the same origin.
-