🔌 gRPC Beginner

What is HTTP/2 and why does gRPC use it?

Answer

HTTP/2 is the second major version of HTTP, bringing fundamental improvements over HTTP/1.1. gRPC uses HTTP/2 because of: (1) Multiplexing — multiple requests/streams can be in flight simultaneously on a single TCP connection, eliminating head-of-line blocking; gRPC streams map to HTTP/2 streams; (2) Binary framing — HTTP/2 uses binary frames instead of text, enabling efficient parsing; (3) Header compression (HPACK) — eliminates repetitive header overhead across requests; (4) Flow control — per-stream flow control prevents fast senders from overwhelming slow receivers; (5) Server push (though gRPC doesn't use this). HTTP/2 enables gRPC's four service types: multiplexing allows simultaneous streams, and binary framing supports both text and binary payloads efficiently. All gRPC connections use HTTP/2 — gRPC cannot work over HTTP/1.1.