Book Image

Practical gRPC

By : Joshua B. Humphries, David Konsumer, David Muto, Robert Ross, Carles Sistare
Book Image

Practical gRPC

By: Joshua B. Humphries, David Konsumer, David Muto, Robert Ross, Carles Sistare

Overview of this book

While building systems that contain several components, you need a framework that is fast and has minimal network overhead. gRPC is one such open-source tool that is quickly becoming popular and gaining popularity with programmers. Practical gRPC introduces you to gRPC and explains how it compares and contrasts with similar technologies. You’ll be introduced to key technologies such as Protocol Buffers, and work your way up from basic gRPC usage, all the way through to its more advanced capabilities. You’ll learn the best practices for defining and evolving your gRPC APIs, and discover how different tools can be leveraged to get the most out of gRPC and even extend it. By the end of this book, you'll have all the information you need to get started building systems with gRPC.
Table of Contents (13 chapters)
11
11. Extending gRPC services

RPC Timeouts

In gRPC, clients and servers can specify the amount of time a request may take for both unary and streaming calls. The term used for this functionality is “timeout.” The implementation of the timeout is language specific, but for the most part operates on the same concept.

Timeouts are important to consider if you are working with an application that may take a long time to process a call. If you don’t specify a timeout on a call, it can potentially operate forever (lets say your application accidentally goes into an infinite loop), causing compute resources to eventually block.

To overcome this, you specify a timeout on your RPC calls for how long you are willing to wait for it to complete. If a timeout is not specified on a gRPC request, the call is timeout and is interpreted as infinite.

When a client specifies a timeout, it is added to the request headers at the key grpc-timeout with a numeric value and unit. For example to specify a timeout of 1...