赞
踩
gRPC is a high-performance open-source feature-rich RPC framework
gRPC is originally developed by Google
Now it is a part of the Cloud Native Computing Foundation - CNCF
RPC stands for Remote Procedure Calls
it is a protocol that allows a program to
execute a procedure of another program located in other computer
without the deveoper explicity coding the details for the remote interaction
in the client code ,it looks like we’re just calling a function of the server code directly
Client has a fenerated stub that provides the same methods as the server
the stub calls gRPC framework under the hood to exchange information over netwoek
Client and server user stubs to interact with each other, so they only need to implement their core service logic
API contracts description
Server and client stubs are generated by the
Protocol Buffer compiler
gRPC plugins of each language
Human-readable Interface Degintion Language(IDL)
Programming languages interoperable:
Binary data representation
Smaller size
Faster to transport
More efficient to serialize / deserialize
Strongly typed contract
Conventions for API evolation
Alternative options
Google faltbuffers
Microsoft bond
10 officially supported languages
pure implementation:Go,Java,NodeJs
Wrap C-gRPC core:C/C++,C#,Objective-C Python ,Ruby,Dart,PHP
Many other unofficial libraries: Swift,Rust ,TypeScript,Haskell,etc.
GRPC Uses HTTP/2 as its transfer protocol
Binary framing
More performant and robust
Lighter to transpot, safer to decode
Great combination with Protocol Buffer
Header compression using HPACK
multiplexing
Send multiple requests and responses in parallel over a single TCP connection
reduce latency and improve network utilization
Server push
One client request ,multiple responses
Reduce round-trip latency
single TCP connection carries multiple bidirectional streams
Each stream has a unique ID and caries multiple bidirectional messages
Each message (request/response) is broken down into multiple binary frames
Frame is the smallest unit that carries different types of data: HEADERS, SETTINGS, PRIORITY,DATA,etc.
Frame from different streams are interleaved and then reassembled on the other side
Microservice
Low latency and high throughput communication
Strong API contract
Polyglot environments
Point-to-point realtime communication
Network constrained environments
install Java Development Kit
install Intellij IDEA
Setup a new Gradle project
install pluhins for protobuf and gRPC
Config automatic code generation upon build
Use Protobuf options to customise generated hava codes
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。