Get a comprehensive understanding of gRPC fundamentals through real-world examples. With this practical guide, you’ll learn how this high-performance interprocess communication protocol is capable of connecting polyglot services in microservices architecture, while providing a rich framework for defining service contracts and data types.
Complete with hands-on examples written in Go, Java, Node, and Python, this book also covers the essential techniques and best practices to use gRPC in production systems. Authors Kasun Indrasiri and Danesh Kuruppu discuss the importance of gRPC in the context of microservices development.
Author(s): Kasun Indrasiri; Danesh Kuruppu
Publisher: O'Reilly Media
Year: 2020
Language: English
Pages: 204
Copyright
Table of Contents
Preface
Why Did We Write This Book?
Who Is This Book For?
How This Book Is Organized
Using Code Examples
Conventions Used in This Book
O’Reilly Online Learning
How to Contact Us
Acknowledgments
Chapter 1. Introduction to gRPC
What Is gRPC?
Service Definition
gRPC Server
gRPC Client
Client–Server Message Flow
Evolution of Inter-Process Communication
Conventional RPC
SOAP
REST
Inception of gRPC
Why gRPC?
gRPC Versus Other Protocols: GraphQL and Thrift
gRPC in the Real World
Netflix
etcd
Dropbox
Summary
Chapter 2. Getting Started with gRPC
Creating the Service Definition
Defining Messages
Defining Services
Implementation
Developing a Service
Developing a gRPC Client
Building and Running
Building a Go Server
Building a Go Client
Running a Go Server and Client
Building a Java Server
Building a Java Client
Running a Java Server and Client
Summary
Chapter 3. gRPC Communication Patterns
Simple RPC (Unary RPC)
Server-Streaming RPC
Client-Streaming RPC
Bidirectional-Streaming RPC
Using gRPC for Microservices Communication
Summary
Chapter 4. gRPC: Under the Hood
RPC Flow
Message Encoding Using Protocol Buffers
Encoding Techniques
Length-Prefixed Message Framing
gRPC over HTTP/2
Request Message
Response Message
Understanding the Message Flow in gRPC Communication Patterns
gRPC Implementation Architecture
Summary
Chapter 5. gRPC: Beyond the Basics
Interceptors
Server-Side Interceptors
Client-Side Interceptors
Deadlines
Cancellation
Error Handling
Multiplexing
Metadata
Creating and Retrieving Metadata
Sending and Receiving Metadata: Client Side
Sending and Receiving Metadata: Server Side
Name Resolver
Load Balancing
Load-Balancer Proxy
Client-Side Load Balancing
Compression
Summary
Chapter 6. Secured gRPC
Authenticating a gRPC Channel with TLS
Enabling a One-Way Secured Connection
Enabling an mTLS Secured Connection
Authenticating gRPC Calls
Using Basic Authentication
Using OAuth 2.0
Using JWT
Using Google Token-Based Authentication
Summary
Chapter 7. Running gRPC in Production
Testing gRPC Applications
Testing a gRPC Server
Testing a gRPC Client
Load Testing
Continuous Integration
Deployment
Deploying on Docker
Deploying on Kubernetes
Observability
Metrics
Logs
Tracing
Debugging and Troubleshooting
Enabling Extra Logging
Summary
Chapter 8. The gRPC Ecosystem
gRPC Gateway
HTTP/JSON Transcoding for gRPC
The gRPC Server Reflection Protocol
gRPC Middleware
Health Checking Protocol
gRPC Health Probe
Other Ecosystem Projects
Summary
Index
About the Authors
Colophon