gRPC有四种类型:
1. UNARY: 单一的请求响应;
2. CLIENT STREAMING: 客户端流式发送,服务端单一响应;
3. SERVER STREAMING: 客户端单一请求,服务端流式响应;
4. BIDIRECTIONAL STREAMING: 双工流式请求响应
gRPC | REST |
---|---|
HTTP/2 | most used HTTP/1.1 |
Protoco buffer | JSON |
strict, clearly defined in proto file | loose and optional |
auto generate code | using OpenAPI and Swagger |
1. 微服务: 提供低延时和高吞吐量通信
2. 多语言服务:提供多种编程语言的代码生产工具
3. 点对点实时通信: 全双工流式传输提供支持
Is gRPC better than REST? Where to use it?