惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tor Project blog
博客园 - 聂微东
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 【当耐特】
G
Google Developers Blog
J
Java Code Geeks
The Cloudflare Blog
Attack and Defense Labs
Attack and Defense Labs
宝玉的分享
宝玉的分享
Last Week in AI
Last Week in AI
Cisco Talos Blog
Cisco Talos Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
I
Intezer
Jina AI
Jina AI
T
Tenable Blog
P
Palo Alto Networks Blog
Project Zero
Project Zero
D
DataBreaches.Net
Hugging Face - Blog
Hugging Face - Blog
The Hacker News
The Hacker News
F
Full Disclosure
Cloudbric
Cloudbric
量子位
H
Heimdal Security Blog
K
Kaspersky official blog
有赞技术团队
有赞技术团队
罗磊的独立博客
V
Vulnerabilities – Threatpost
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
阮一峰的网络日志
阮一峰的网络日志
Vercel News
Vercel News
Recent Announcements
Recent Announcements
WordPress大学
WordPress大学
GbyAI
GbyAI
S
SegmentFault 最新的问题
M
MIT News - Artificial intelligence
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
I
InfoQ
Recorded Future
Recorded Future
Security Archives - TechRepublic
Security Archives - TechRepublic
AI
AI
Webroot Blog
Webroot Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
爱范儿
爱范儿
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
The Exploit Database - CXSecurity.com
Apple Machine Learning Research
Apple Machine Learning Research
C
Cybersecurity and Infrastructure Security Agency CISA
H
Hacker News: Front Page
Latest news
Latest news

Arpit Bhayani

Temporal Primer - Building Long-Running Systems What Matters in Production RAG Structure of Every LLM Chat How LLMs Really Work Your Monolith Is Already A Distributed System Databases Were Not Designed For This BM25 JOIN Algorithms Venting at Work Comes at a Reputation Cost Why Half Your Skills Expire Every Few Years Multi-Paxos - Consensus in Distributed Databases MySQL Replication Internals Bloom Filters When You Increase Kafka Partitions Product Quantization The Q, K, V Matrices The Day I Accidentally Deleted Production How LLM Inference Works What are Blocking Queues and Why We Need Them Heartbeats in Distributed Systems How Writes Work in Apache Cassandra Redis Replication Internals How to Handle Arrogant Colleagues at Work How Does a CDN Handle Content Replication You Can't Fix Everything on Day One When Emotions Spill Over at Work Meetings With No Agenda Are a Waste of Time Career Longevity Beats Constant Job Hopping Stay Relevant at Higher Salary Levels Why Distributed Systems Need Consensus Algorithms Like Raft Why Do Databases Deadlock and How Do They Resolve It Why and How Cache Locality Can Make Your Code Faster Why Eventual Consistency is Preferred in Distributed Systems Why does DNS use both UDP and TCP Should You Do a Master's My Honest Take Empathy Makes Great Engineers Unstoppable Good Mentors Build People, Not Just Skills Why You Should Always Have Back-Burner Projects Before You Push Back, Know What You're Standing On Be the One They Can Count On How Much Are People Willing to Bet on You How to Get Leadership to Say Yes to Your Project Don't Let Your Best Ideas Die in Silence Be the Person Everyone Wants to Work With The XY Problem and How to Avoid It The Startup Hiring Lie Nobody Talks About You Won't Be Promoted Unless You Ask It's Not Enough to be Right; Learn to be Heard No One Ships Great Software Alone You Don't Win by Proving Others Wrong Appreciate Generously; It Costs Nothing, But Builds Everything Your Soft Skills Aren't Soft at All Before you form an opinion, experience it Why You Need Both Curiosity and Action to Thrive A Daily Worklog Changed Everything How We Handle Mistakes Defines Us Own Your Mistakes Don't Wait. Step Up. Temporary Fixes Are Permanent Why Interviews Are Biased And What Sets You Apart Saying 'This isn't my problem' is actually the problem How to Write Effective OKRs Never Lose a Battle due to Miscommunication When In Doubt, Code It Out How to Follow Up Without Annoying People Lead Projects That Land, Execution Over Everything Abstract Thinking Will Define Your Next Decade We Engineers Suck at Task Estimation Shiny Obect Syndrome in Tech When to Change Jobs - The 3P Framework Comfort and Competition - Know When to Switch Gears Paper Notes - On-demand Container Loading in AWS Lambda Paper Notes - SQL Has Problems. We Can Fix Them Pipe Syntax In SQL Paper Notes - NanoLog - A Nanosecond Scale Logging System Don't Wait, Learn - The Best Resource is Mythical Paper Notes - WTF - The Who to Follow Service at Twitter The Unexpected Benefit of Reading Random Engineering Articles Roadmaps Are Limiting Your Growth Stop Leaving Money on the Table - Negotiate Your Job Offer Never Bad-Mouth Your Past Employers Show You're a Culture Fit Quantify your resume, Know Your Numbers The Importance of Being Likeable in Interviews Questions to Ask Your Interviewer How to Build Trust Through Collaboration Do This, Once You Are Out of the Interview Cycle Stop Pitching Ideas, Start Pitching Projects Read Those Design Docs, Even the Ones That Seem Irrelevant The Best Engineering Lessons Happen During Outages Great Engineers Start Broad LLM Summaries are Ruining Your Learning Turn System Design Interviews into Discussions Title Inflation At Work, Find Your Own Projects 6 Simple Strategies to Cracking Any Tech Interview How to Remain Unblocked Solving the Knapsack Problem with Evolutionary Algorithms Generating Pseudorandom Numbers with LFSR Local vs Global Indexes in Partitioned Databases Partitioning Data - Range, Hash, and When to Use Them
Why gRPC Uses HTTP2
Arpit Bhayani · 2025-09-24 · via Arpit Bhayani

When Google introduced gRPC in 2015, one of the most significant architectural decisions was building it on top of HTTP/2 rather than the widely adopted HTTP/1.1. This was just about following some trend, but a deliberate choice that fundamentally shapes how gRPC performs and behaves. Let’s dig deeper into why this decision was made and how it impacts real-world applications.

What Makes HTTP/2 Different

Before diving into gRPC’s specific needs, let’s understand what HTTP/2 brings to the table that HTTP/1.1 doesn’t.

Binary vs Text Protocol

HTTP/1.1 is a text-based protocol. When you make a request, it looks something like this:

GET /api/users HTTP/1.1
Host: example.com
Accept: application/json

HTTP/2, on the other hand, is a binary protocol. The same request is encoded into binary frames that are more compact and faster to parse. This improves performance, especially when dealing with thousands of concurrent connections (such as in a microservices architecture).

Multiplexing

The most interesting and important feature of HTTP/2 is multiplexing. In HTTP/1.1, each TCP connection can handle only one request at a time. If you want to make multiple requests, you either have to:

  1. Wait for each request to complete sequentially
  2. Use HTTP pipelining
  3. Open multiple TCP connections (which browsers limit to 6-8 per domain)

HTTP/2 allows multiple requests and responses to be interleaved over a single TCP connection using streams. Each stream has a unique ID, and frames can be sent for different streams without blocking each other.

                    Single TCP Connection
                    ═══════════════════════════════
Stream 1 (ID: 1):   [REQ A] -----> [RESP A]
                      |              |
                      t1            t3

Stream 2 (ID: 3):         [REQ B] -----> [RESP B]
                            |              |
                            t1.5          t2.5

Stream 3 (ID: 5):               [REQ C] -----> [RESP C]
                                  |              |
                                  t2            t4

This is how the timeline view of multiplexed HTTP/2 requests looks.

t1    t1.5   t2    t2.5   t3    t4
|     |      |     |      |     |
▼     ▼      ▼     ▼      ▼     ▼
┌─────┬──────┬─────┬──────┬─────┬─────┐
│REQ A│REQ B │REQ C│RESP B│RESP │RESP │
│(S:1)│(S:3) │(S:5)│(S:3) │A    │C    │
│     │      │     │      │(S:1)│(S:5)│
└─────┴──────┴─────┴──────┴─────┴─────┘

On the wire, this multiplexing looks something like this.

[H S:1][D S:1][H S:3][D S:3][H S:5][D S:5][D S:3][D S:1][D S:5]
REQ A   REQ A  REQ B  REQ B  REQ C  REQ C  RESP B RESP A RESP C

S:1, S:3, S:5 = Stream IDs
REQ = Request frames
RESP = Response frames

gRPC’s Core Requirements

Bidirectional Communication

gRPC supports four types of RPC calls:

  • Unary: Traditional request-response
  • Server streaming: Server sends multiple responses
  • Client streaming: Client sends multiple requests
  • Bidirectional streaming: Both sides stream data simultaneously

HTTP/1.1 simply cannot handle streaming scenarios effectively. While techniques like Server-Sent Events (SSE) or WebSockets exist, they’re either limited or require protocol upgrades that break the HTTP model.

HTTP/2’s stream-based architecture naturally supports these patterns. A bidirectional streaming gRPC call maps perfectly to an HTTP/2 stream where both client and server can send frames asynchronously.

Here’s a practical example…

Imagine a chat application where multiple users are sending messages simultaneously:

service ChatService {
  rpc LiveChat(stream ChatMessage) returns (stream ChatMessage);
}

With HTTP/2, this becomes a single stream where:

  • Client sends DATA frames containing serialized ChatMessage
  • Server sends DATA frames back with messages from other users
  • All happens over one TCP connection with proper flow control

High Throughput and Low Latency

In microservices architectures, services often make dozens of calls to other services to fulfill a single user request. With HTTP/1.1, this creates a bottleneck:

Service A → Service B (wait)
          → Service C (wait)
          → Service D (wait)

Even with connection pooling, you’re limited by the number of concurrent connections and the head-of-line blocking problem.

With gRPC over HTTP/2, Service A can make all these calls concurrently over a single connection:

Service A → Multiple streams to Services B, C, and D simultaneously

The multiplexing ensures that a slow response from Service B doesn’t block the faster responses from Services C and D.

Efficient Header Handling

gRPC makes extensive use of headers for metadata like authentication tokens, tracing information, and custom headers. In a typical microservices call chain, these headers are propagated through multiple services.

HTTP/1.1 sends headers as plain text with every request:

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
X-Trace-ID: 1234567890abcdef
X-User-ID: user123
Content-Type: application/grpc+proto

In a service mesh with hundreds of requests per second, this overhead becomes significant.

HTTP/2’s HPACK compression maintains a dynamic table of previously seen headers. After the first request, common headers are referenced by index rather than sent in full.

:method: POST               → Index 3
:path: /UserService/GetUser → Index 62
authorization: Bearer...    → Index 58

This reduces header overhead by 85-90% in real applications.

Performance

Connection Management

Consider a microservices application with 10 services, each making an average of 5 calls to other services under load.

HTTP/1.1 Scenario:

  • Each service needs connection pools to every other service
  • With 6 connections per pool, that’s 10 × 9 × 6 = 540 TCP connections
  • Each connection has TCP overhead, OS socket limits, and connection establishment latency

HTTP/2 Scenario:

  • Each service maintains 1-2 connections to every other service
  • Total connections: 10 × 9 × 2 = 180 TCP connections
  • 67% reduction in connection overhead

Latency Characteristics

In practice, the latency benefits of HTTP/2 for gRPC are most noticeable in:

  1. High-frequency, low-payload requests: Microservices often make many small calls. HTTP/2’s frame overhead is lower than HTTP/1.1’s text parsing.
  2. Concurrent requests: When a service needs to aggregate data from multiple sources, HTTP/2’s multiplexing provides a significant speedup.
  3. Long-lived connections: gRPC services maintain persistent connections for streaming. HTTP/2’s connection reuse is more efficient than HTTP/1.1’s connection establishment overhead.

Real-world numbers that I have observed

  • 20-40% latency reduction for concurrent requests
  • 50-80% reduction in connection overhead
  • 2-3x improvement in requests per second for small payloads

Streaming

Server Streaming Example

Consider a log streaming service:

service LogService {
  rpc StreamLogs(LogRequest) returns (stream LogEntry);
}

HTTP/1.1 Approach:

  • Long polling with timeouts
  • Chunked transfer encoding
  • Complex client-side reconnection logic requiring state management

HTTP/2 Approach:

  • Natural streaming with DATA frames
  • Built-in flow control via WINDOW_UPDATE(explained below) frames
  • Clean connection management

The HTTP/2 implementation is not only simpler but also more robust and efficient.

Flow Control in Action

HTTP/2’s flow control prevents fast producers from overwhelming slow consumers. In gRPC streaming:

  1. Client opens stream with initial window size (65KB default)
  2. Server sends data frames up to the window limit
  3. Client processes data and sends a WINDOW_UPDATE to increase the available window
  4. Server continues sending based on the updated window

The window size controls how much unacknowledged data can be “in flight” between sender and receiver at any given moment. Think of it as a buffering limit, not a message size limit.

This prevents memory exhaustion and provides natural backpressure, something that’s difficult to achieve cleanly with HTTP/1.1. Also, both client and server can send a WINDOW_UPDATE frame depending on their rate of consumption and production.

Trade-offs

When HTTP/2 Might Not Be Ideal

Single Request Scenarios - For simple, one-off requests, HTTP/1.1 might have lower latency due to:

  • Simpler protocol negotiation
  • Less connection setup overhead
  • Broader proxy support (though this is diminishing)

Resource-Constrained Environments - HTTP/2 requires more memory for:

  • HPACK compression tables
  • Stream state management
  • Flow control windows

In embedded systems or extremely memory-constrained environments, this overhead might be significant.

Proxy and Infrastructure Considerations

Load Balancer Compatibility - Not all load balancers handle HTTP/2 efficiently:

  • Some terminate HTTP/2 and forward as HTTP/1.1
  • Others don’t properly handle gRPC’s use of HTTP/2 trailers
  • Stream-aware load balancing is still evolving

Debugging Complexity - HTTP/2’s binary nature makes debugging more challenging:

  • Network captures require specialized tools
  • Stream interleaving makes request/response correlation complex
  • Traditional HTTP debugging tools may not work

Protocol Buffer Integration

And of course, talking about the most common - protobuf. gRPC’s use of Protocol Buffers pairs exceptionally well with HTTP/2

Protobuf’s binary serialization is naturally aligned with HTTP/2’s binary frames:

  • No text-to-binary conversion overhead
  • Efficient frame packing
  • Better compression ratios when combined with HTTP/2’s HPACK

Schema Evolution

Protobuf’s schema evolution capabilities work well with HTTP/2’s header compression:

  • Service versions can be negotiated via headers
  • Backward compatibility metadata travels efficiently
  • Feature flags and capabilities can be communicated compactly

gRPC’s adoption of HTTP/2 was a strategic decision that enables the framework’s core value propositions - performance, functionality, and scalability.

If you are building distributed systems, understanding this relationship between gRPC and HTTP/2 is crucial. It helps you build performant production environments.

As you design and implement gRPC services, keep these underlying mechanics in mind – they will inform your decisions about service boundaries, streaming strategies, and performance optimization.

The key is understanding how to leverage these capabilities effectively in your specific use case.