Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Practical gRPC
Practical gRPC

Practical gRPC: Build highly-connected systems with a framework that can run on any platform

By Joshua B. Humphries , David Konsumer , David Muto , Robert Ross , Carles Sistare
£32.99 £22.99
Book Nov 2019 169 pages 1st Edition
eBook
£32.99 £22.99
Print
£41.99
Subscription
£13.99 Monthly
eBook
£32.99 £22.99
Print
£41.99
Subscription
£13.99 Monthly

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Nov 28, 2019
Length 169 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781839211744
Category :
Table of content icon View table of contents Preview book icon Preview Book

Practical gRPC

Chapter 1. Introduction

This book aims to provide a practical approach to learning and using gRPC. It attempts to catalog and teach not only the basics of gRPC, which you could also find in countless blog posts and the gRPC home page itself, but also to show the more interesting (perhaps less well-documented) aspects of gRPC. The book even demonstrates some of the gRPC pitfalls, and what you need to know to overcome them.

The first few chapters in this book introduce gRPC, describing what it is and how it compares and contrasts to other technologies in the same space. We’ll also dive into how to actually use and apply it. Next, the book will venture into more advanced techniques. These advanced chapters will arm you with the tools to use gRPC to the fullest, so you can truly harness its features for solving problems and building software systems. There are also more practical concerns covered, like best practices for evolving your RPC interfaces and schemas. The later chapters in the book will detour into related technologies, some that complement gRPC in production environments and some that aid developers in building and testing applications that use gRPC.

Computer networks and distributed computing

The earliest ideas for connecting multiple computers to form a network came about in the 1960’s. Shortly after, the ARPANET (the precursor to the Internet) was created. In the 1970’s, email was invented, which became the most widely used distributed application on the ARPANET. In these early days, the power of the network was mostly for sharing information by sending data from one computer to another on the other side of the country. Distributed computing became its own field of computer science in the 1970’s. So the study of how multiple computers could be used to solve larger problems than a single computer could solve was of great interest. This fledgling Internet connected the computing resources of numerous universities and government organizations, creating a large pool of compute power.

The ARPANET eventually grew into the Internet we know today, connecting millions of computers all across the globe. It powered the rise of the World Wide Web in the 1990’s, and today the Internet is a utility, much like electricity or water. It is available almost everywhere in the USA and also in most of the world. With more recent innovations in mobile computing and embedded systems, the Internet has become an integral component in modern life, not just in business.

Request-response protocols

Numerous networking protocols have been developed for sharing information from one point of the Internet to the other. Almost all of the protocols use the TCP/IP Internet protocol suite. This has enabled the free flow of information across the globe, and it has also had an immeasurable impact on modern business and commerce, which rely greatly on computer networks and distributed computing.

clients and servers

This diagram shows a very simple but typical arrangement. In enterprise settings, the two halves will likely be on the same network, or perhaps a VPN is used to securely connect clients to the servers. For eCommerce, SaaS (Software as a Service) and other Internet offerings, the servers might be hosted in the provider’s datacenter or even with a third-party provider like Amazon Elastic Compute Cloud (EC2), Google Cloud Platform, or Microsoft Azure. The main components of interest here are clients, on the left, and servers, on the right.

A client is a program that initiates communication-usually by creating a TCP connection. It may be an end-user program, initiating communication to request information or resources that it presents to a user. In web applications, for example, the client is a web browser such as Chrome or Firefox.

A server is a program that accepts these client connections and in turn processes their requests. There are many kinds of servers. The diagram shows an application server, so named because it serves data to the client application. (It is also called a web server if it uses HTTP as the communication protocol). As shown in the diagram, the application server may involve other computers in order to serve responses. In that case, the server also acts as a client. In the diagram, the application server acts as a database client, requesting information from the database server.

Most networking protocols follow this pattern: a client creates a network connection to the server and sends requests. The server accepts requests, performs some processing, and then sends responses. This request-response flow was conceived in the early days of networking in the 1960’s and has been foundational to distributed computing ever since.

Remote Procedure Calls

RPC stands for Remote Procedure Calls. It is a programming model built on top of request-response network protocols. Issuing an RPC in a client amounts to invoking a procedure from application code. For a server, servicing an RPC amounts to implementing a procedure with a particular signature.

In the client, the objects that expose these procedures are called stubs. When application code invokes a procedure on a stub, the stub translates the arguments into bytes and then sends a request to the server, the contents of which are the serialized arguments. When it gets back a response from the server, it translates the bytes into a result value, which is then returned back to the application code that called it.

In the server, the objects that expose these procedures are service implementations. The server machinery receives the request, translates the bytes back into procedure arguments, and then invokes a procedure on the service implementation, passing it those arguments. The service implementation performs its business logic and then returns a result, either a value on success or an error code on failure. (In some RPC implementations, servers can return both values and an error code). The server machinery then translates this result into bytes, which then become the response that is sent back to the client.

RPC flow

RPC is not a new programming idiom: proposals for remote procedure call semantics were written in the 70’s, and practical RPC implementations appeared in the 80’s, such as the Network File System (NFS).

gRPC is a cross-platform RPC system that supports a wide variety of programming languages. It excels at providing high performance and ease of use, to greatly simplify the construction of all types of distributed systems.

Summary

This chapter introduced the domain in which gRPC is used (distributed computing), and provided a brief overview of how this domain has evolved over time.

In the next chapter, we will go into greater detail as to what exactly gRPC is, and how it compares to similar technologies.

Left arrow icon Right arrow icon

Key benefits

  • Get to grips with the mechanics of gRPC, including the underlying HTTP/2 protocol as well as data serialization and deserialization
  • Discover how gRPC compares and contrasts with similar technologies
  • Get the key to solving problems and building complex systems with gRPC

Description

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.

What you will learn

Understand how Protocol Buffers are used to serialize structured data Explore ways to establish reliable communication between microservices Understand why gRPC is more fruitful than JSON and REST Become familiar with smooth error handling tricks using gRPC Decipher gRPC code written in different languages Discover how to connect a client to a server using advanced gRPC techniques

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Nov 28, 2019
Length 169 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781839211744
Category :

Table of Contents

13 Chapters
Preface Chevron down icon Chevron up icon
1. Introduction Chevron down icon Chevron up icon
2. What is gRPC? Chevron down icon Chevron up icon
3. What are Protocol Buffers? Chevron down icon Chevron up icon
4. gRPC basics Chevron down icon Chevron up icon
5. Star Friends Chevron down icon Chevron up icon
6. Streaming gRPC calls Chevron down icon Chevron up icon
7. Advanced gRPC Chevron down icon Chevron up icon
8. HTTP2 overview Chevron down icon Chevron up icon
9. Load balancing Chevron down icon Chevron up icon
10. Service evolution with gRPC Chevron down icon Chevron up icon
11. Extending gRPC services Chevron down icon Chevron up icon
12. Debugging gRPC Chevron down icon Chevron up icon

Customer reviews

Filter icon Filter
Top Reviews
Rating distribution
Empty star icon Empty star icon Empty star icon Empty star icon Empty star icon 0
(0 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 0%
1 star 0%

Filter reviews by


No reviews found
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.