kokobob.com

Why Google Selected HTTP/2 for gRPC Implementation

Written on

Chapter 1: Understanding gRPC's Design Choices

gRPC is an open-source, high-performance Remote Procedure Call (RPC) framework developed by Google. Its design is aimed at functioning seamlessly across various environments, featuring support for pluggable load balancing, tracing, health checks, and authentication. This framework accommodates service calls both within and between data centers and is adept at connecting devices, mobile apps, and browsers to backend services.

For a deeper insight into the motivations and foundational principles guiding gRPC's creation, refer to this comprehensive article: gRPC Motivation and Design Principles.

Key Highlights from the Official Documentation:

  • Internally, Google operates a framework named Stubby, which isn't aligned with any established standards.
  • gRPC is versatile, catering to various environments including IoT, mobile platforms, and web browsers.
  • It offers robust streaming and flow control capabilities.
  • Notably, performance isn't the sole focus of gRPC's architecture.

What Leads to the Choice of HTTP/2?

Before delving into why gRPC adopted HTTP/2, it's essential to grasp the fundamentals of HTTP/2. This protocol enhances the communication framework significantly compared to its predecessor.

Visual representation of HTTP/1 and HTTP/2 headers.

To explore HTTP/2 connections in Chrome, visit: chrome://net-internals/#http2.

gRPC operates on a layered architecture, allowing it to support various underlying protocols, with the current focus primarily on:

  • gRPC over HTTP/2
  • gRPC Web

Let’s analyze a sample gRPC SayHello request and observe its implementation over HTTP/2 using a tool like Wireshark:

Wireshark analysis of gRPC SayHello request.

The following headers are identified in the request:

  • :authority: localhost:50051
  • :path: /helloworld.Greeter/SayHello
  • :method: POST
  • :scheme: http
  • content-type: application/grpc
  • user-agent: grpc-java-netty/1.11.0

The request parameters are encapsulated in the DATA frame, illustrating that gRPC utilizes HTTP/2 Headers for metadata while the serialized request parameters reside in the DATA frame.

Advantages of HTTP/2

  1. Open Standard: Google opted to develop a new protocol rather than open-source Stubby, anticipating a shift towards more open technologies that limits proprietary protocols.
  2. Proven Track Record: HTTP/2 was built on practical experiences, avoiding the pitfalls of many standards that failed due to lack of implementation foresight.
  3. Support for Modern Platforms: Mobile devices and browsers were among the first to adopt HTTP/2, driven by the needs of the mobile internet.
  4. Ease of Multilingual Implementation: The existence of mature HTTP/2 clients across popular programming languages enhances its adoption.
  5. Stream and Flow Control: HTTP/2 offers prioritized streams, beneficial in complex scenarios.
  6. Gateway and Proxy Compatibility: Tools like Nginx and Envoy provide seamless support for gRPC.
  7. Inherent Security: HTTP/2 naturally incorporates SSL, making it easier to ensure secure communications.
  8. Mature Authentication: Existing authentication systems from HTTP/1 transition smoothly to HTTP/2, simplifying backend communication.

Disadvantages of HTTP/2

  1. RPC Metadata Transmission Inefficiencies: Although HPAC can compress HTTP headers, simplifying function calls could enhance performance.
  2. Multiple Decodings Required: Each gRPC call necessitates decodings for both HEADERS and DATA frames, which can introduce latency.
  3. TCP Connection Constraints: Although HTTP/2 typically allows a single TCP connection, practical implementations may necessitate multiple connections.

While HTTP/2 may not deliver the highest performance for gRPC, its moderate queries per second (QPS) are often acceptable, prioritizing generality and compatibility.

Google's Influence on Standards

Over the past decade, Google's role in establishing standards has strengthened, evident in:

  • HTTP/2
  • WebP image format
  • WebRTC for real-time communication
  • VP9/AV1 video encoding standards
  • Service Worker/PWA
  • QUIC/HTTP/3

Despite some setbacks, such as the failed Native Client initiative, gRPC has emerged as a key standard within the Kubernetes ecosystem.

The Emergence of gRPC

The rise of HTTP/2-based RPCs is largely driven by the demand for open interoperability in the Cloud Native landscape. Even without gRPC, other HTTP/2-based RPC solutions would likely have surfaced.

Initially, gRPC was implemented internally at Google for the Google Cloud Platform and public APIs.

Summary

Although gRPC may not replace internal RPC frameworks, its capacity for open interoperability will likely lead to its broader adoption beyond Kubernetes.

References

Chapter 2: Exploring gRPC's HTTP/2 Benefits

In this chapter, we will dive into the specific advantages and practical applications of gRPC over HTTP/2.

Video Description: This video discusses the essential aspects of gRPC and its relationship with HTTP/2, covering key advantages and use cases.

Video Description: A comprehensive crash course on gRPC, detailing its modes, examples, pros and cons, providing a well-rounded understanding of the framework.

Share the page:

Twitter Facebook Reddit LinkIn

-----------------------

Recent Post:

Understanding the Crab-in-Barrel Mentality in the Black Community

An exploration of the crab-in-barrel mentality within the black community and its implications for progress and unity.

Reconnecting with Old Friends: Is It Awkward to Reach Out?

Exploring the nuances of reaching out to old high school friends and the potential for rekindling connections.

Am I Fun Bobby? Navigating a Family Wedding, Sober

Reflecting on attending a family wedding sober and enjoying the experience.

# Why Society Critiques Creative Minds: An In-Depth Look

Exploring the societal criticism faced by innovative thinkers and the reasons behind it.

Breaking Free from Limiting Beliefs: A Comprehensive Guide

Discover effective strategies to overcome limiting beliefs and foster personal growth through this insightful guide.

Transform Your Mindset: 9 Strategies to Care Less About Others

Explore nine effective strategies to shift your mindset and reduce concern for others' opinions, paving the way for a more fulfilling life.

Understanding Minkowski Spacetime and Relativity's Geometry

Explore the geometry of Minkowski spacetime and its implications for special relativity through interactive diagrams and insights.

Cultivating Resilience: 11 Inspiring Strategies for Growth

Discover 11 impactful strategies to foster resilience and thrive through life's challenges, enhancing your mental health and well-being.