gRPC is a high performance, open source framework developed by Google to handle remote procedure calls (RPCs). gRPC is Google’s approach to a client-server application. It lets client and server applications communicate transparently, simplifying the process for developers to build connected systems. Released in August 2016, gRPC has been adopted by enterprises, startups and open source projects worldwide.
gRPC runs in any environment, connecting services in and across data centers with pluggable support for tracing, health checking, load balancing and authentication. gRPC can also be used to connect mobile devices, Mobile apps and browsers to backend services.
Developers use gRPC in the last mile of computing in mobile and web clients because it can generate libraries for Android and iOS. Additionally, it uses standards-based HTTP/2 as transport so it can cross firewalls and proxies easily.
Supported programming languages
gRPC clients and servers can run and communicate with each other in various environments, including a user’s desktop and servers inside Google. Furthermore, gRPC clients can be written in any of gRPC’s supported languages, including:
For instance, a developer can easily create a gRPC server in Java with clients in Python, Ruby or Go. Additionally, since the latest Google application program interfaces (APIs) have gRPC versions of their interfaces, developers can build Google functionality into their applications.
Benefits of using gRPC
gRPC, like other RPC systems, revolves around the idea of defining a service, such as identifying the methods that can be remotely called with their parameters and return types. However, gRPC lets developers use more sophisticated technologies that are efficient and scalable, such as HTTP/2 and streams. Since it is technology-agnostic, it can be used by and interact with server and clients from several different programming languages.
gRPC is also built upon protocol buffers, also known as protobufs. Protobufs are Google’s tool for sequencing structured data, which allows for communication and data storage that can be predicted and analyzed.
Types of gRPC
gRPC lets developers define four types of service methods:
- Unary RPC – The client sends one request to the server and gets one response back, the same as with a normal function call.
- Server streaming – The client sends a request to the server and receives a stream of messages back. The client reads from the returned stream until there are no messages left. Here, gRPC guarantees message ordering within an individual RPC call.
- Client streaming – The opposite of server streaming, the client writes a sequence of messages and sends them to the server, using a provided stream. Once the client has finished writing the messages, it waits for the server to read them and return its responses. Once again, gRPC guarantees message ordering within an individual RPC call.
- Bidirectional streaming – Both sides send a sequence of messages via a read-write stream. The two streams work independently of each other and, as such, the clients and servers can read and write in any order. For instance, the server reads a message then writes a response. Or the server waits to receive all the client messages before writing its responses. gRPC preserves the order of messages in each stream.