Networking Essentials

OSI model

Pasted image 20250928155613.png

Here’s a quick comparison table ✅

Feature gRPC REST
Protocol HTTP/2, binary (Protobuf) HTTP/1.1/2, text (JSON/XML)
Performance Faster, smaller payloads Slower, larger payloads
Streaming Built-in bidirectional streaming Limited (mostly request/response, SSE, WebSockets)
Typing Strongly typed (IDL: .proto) Weakly typed (JSON schema optional)
Tooling Auto codegen for many languages Widely supported, simple tools (curl, Postman)
Interoperability Harder for browsers (needs gRPC-Web) Native to browsers (JSON/HTTP)
Ease of use More setup (protos, stubs) Easier (just HTTP + JSON)
Best for High-performance, microservices, internal APIs Public APIs, wide client compatibility

👉 In short: gRPC = fast & efficient for internal microservices, REST = simpler & universal for external APIs.


In Server-Sent Events (SSE), the server uses plain HTTP response headers to establish and maintain the stream.

Required headers


WebSocket is built on top of TCP.

How it works:

  1. Starts as HTTP (over TCP) → The client sends an HTTP/1.1 request with Upgrade: websocket.
  2. Handshake → If the server agrees, it upgrades the connection from HTTP to WebSocket.
  3. Persistent TCP channel → After that, both client and server can send messages anytime (full-duplex, low latency).

Key points


👉 In short: WebSocket = an application protocol that uses a persistent TCP connection after an HTTP handshake.

Do you want me to also compare WebSocket vs SSE vs HTTP/2 streams in a quick table?