gRPC
- High-performance
- Open source
- Universal RPC framework
What is gRPC?
gRPC is an open source remote procedure call
system initially developed at Google in 2015. based
on HTTP/2 protocol using Protocol Buffers
as interface description language.
In gRPC, client application can directly call a method
on a server application on a different machine as if
it were a local object, making it easier for you to
communicate between microservices.
Features
• Based on HTTP/2 protocol
• Protocol Buffer message
• Persistent connection
• No serialization required
• Bi-directional streaming
• Point to point data stream
Architecture
Sample
Protocol Buffer Interface
message EntityInfoRequest {
string entity_id = 1;
}
message EntityInfoResponse {
string id = 1;
string field_1 = 2;
string field_2 = 3;
string field_3 = 4;
bool field_4 = 5;
string created_on = 6;
}
service EntityService {
rpc getEntityInfo(EntityInfoRequest) returns (EntityInfoResponse) {}
}
Key Benefits
• gRPC based on HTTP/2. which is a Binary
protocol, but HTTP 1.1 is Textual. Binary
protocol is much efficient to parse and its
safe.
• gRPC uses Protobuf messages which is
compressed binary encoded structured data.
• gRPC is multiplexing in nature so it
overcomes the Head-of-Line Blocking
problem of HTTP1.1.
• gRPC uses header compression to reduce
overhead.
• gRPC also supports Duplex Streaming.
Primary
Use Cases
• In microservices based application infrastructure
services/servers can talk to each other using gRPC
over persistent connection to reduce overhead of
multiple TCP handshaking.
• If application required duplex streaming with high
data volume gRPC can help due to it’s binary
encoded compress protocol buffer messaging.
REST
&
gRPC
REST gRPC
Based on HTTP/1.1 Based on HTTP/2
Supports XML, JSON based
textual data format
Supports Protocol buffer based
binary data format
No duplex streaming supported Duplex streaming supported
No RPC interfaces available Based on RPC interface
Handshake for every request Persistent connection to reduce
processing time
Websockets
&
gRPC
Websockets gRPC
Based on HTTP/1.1 Based on HTTP/2
Supports XML, JSON based
textual data format
Supports Protocol buffer based
binary data format
No duplex streaming supported Duplex streaming supported
No RPC interfaces available Based on RPC interface
Pub/Sub based data streaming Point to Point data streaming
Benchmark
Data Websockets gRPC
1k messages
(1.2KB)
80ms 10ms
10k messages
(1.2KB)
125ms 41ms
100k messages
(1.2KB)
901ms 210ms
1k messages
(5KB)
146ms 56ms
10k messages
(5KB)
228ms 94ms
100k messages
(5KB)
1967ms 259ms
Conclusion
In microservices based environment related
communication gRPC would be one of the best
probable candidate among REST & Websockets &
gRPC due to it’s
• Binary data format (Protocol Buffer)
• HTTP/2 support
• Persistent connection
• Duplex streaming
Thank you!
• https://grpc.io/
• https://en.wikipedia.org/wiki/GRPC
• https://en.wikipedia.org/wiki/Protocol_Buffers

gRPC - Fastest Data Transfer Protocol

  • 1.
    gRPC - High-performance - Opensource - Universal RPC framework
  • 2.
    What is gRPC? gRPCis an open source remote procedure call system initially developed at Google in 2015. based on HTTP/2 protocol using Protocol Buffers as interface description language. In gRPC, client application can directly call a method on a server application on a different machine as if it were a local object, making it easier for you to communicate between microservices.
  • 3.
    Features • Based onHTTP/2 protocol • Protocol Buffer message • Persistent connection • No serialization required • Bi-directional streaming • Point to point data stream
  • 4.
  • 5.
    Sample Protocol Buffer Interface messageEntityInfoRequest { string entity_id = 1; } message EntityInfoResponse { string id = 1; string field_1 = 2; string field_2 = 3; string field_3 = 4; bool field_4 = 5; string created_on = 6; } service EntityService { rpc getEntityInfo(EntityInfoRequest) returns (EntityInfoResponse) {} }
  • 6.
    Key Benefits • gRPCbased on HTTP/2. which is a Binary protocol, but HTTP 1.1 is Textual. Binary protocol is much efficient to parse and its safe. • gRPC uses Protobuf messages which is compressed binary encoded structured data. • gRPC is multiplexing in nature so it overcomes the Head-of-Line Blocking problem of HTTP1.1. • gRPC uses header compression to reduce overhead. • gRPC also supports Duplex Streaming.
  • 7.
    Primary Use Cases • Inmicroservices based application infrastructure services/servers can talk to each other using gRPC over persistent connection to reduce overhead of multiple TCP handshaking. • If application required duplex streaming with high data volume gRPC can help due to it’s binary encoded compress protocol buffer messaging.
  • 8.
    REST & gRPC REST gRPC Based onHTTP/1.1 Based on HTTP/2 Supports XML, JSON based textual data format Supports Protocol buffer based binary data format No duplex streaming supported Duplex streaming supported No RPC interfaces available Based on RPC interface Handshake for every request Persistent connection to reduce processing time
  • 9.
    Websockets & gRPC Websockets gRPC Based onHTTP/1.1 Based on HTTP/2 Supports XML, JSON based textual data format Supports Protocol buffer based binary data format No duplex streaming supported Duplex streaming supported No RPC interfaces available Based on RPC interface Pub/Sub based data streaming Point to Point data streaming
  • 10.
    Benchmark Data Websockets gRPC 1kmessages (1.2KB) 80ms 10ms 10k messages (1.2KB) 125ms 41ms 100k messages (1.2KB) 901ms 210ms 1k messages (5KB) 146ms 56ms 10k messages (5KB) 228ms 94ms 100k messages (5KB) 1967ms 259ms
  • 11.
    Conclusion In microservices basedenvironment related communication gRPC would be one of the best probable candidate among REST & Websockets & gRPC due to it’s • Binary data format (Protocol Buffer) • HTTP/2 support • Persistent connection • Duplex streaming
  • 12.
    Thank you! • https://grpc.io/ •https://en.wikipedia.org/wiki/GRPC • https://en.wikipedia.org/wiki/Protocol_Buffers