Kehaw

gRPC对比RSocket:Part 2


本章主要介绍 RSocket 在 Java 上的一些特别之处。

Zero Copy

RSocket Java provides an API that lets developers manage the Netty ByteBuf lifecycle allowing for zero copy.

Automatic Request Batching

RSocket Java takes advantage of Reactive Stream semantics to batch requests over the network. Using this information, RSocket can determine to flush data when network buffers are full, or if it needs to flush based on the information about the stream. The result is that RSocket will send the optimal amount of data over the network based on what it observes without having to be tuned by the user.

Flyweight-Based Frames

RSocket Java uses the flyweight pattern to encode and decode frames. These flyweights do not allocate any data. Instead, they act as a lens over a ByteBuf to read without the overhead of decoding the frame.

RSocket Programming APIs

RSocket is an OSI layer 5/6 protocol, and while it can be used directly depending on the use-case, it is much easier to develop applications with a layer 7 protocol. Currently there is RPC, IPC, and soon to added GraphQL support. The most mature right now is RSocket RPC, which is a protobuf auto-marshalling layer that sits on top of RSocket to make message passing convenient. At its core it is not RPC — it is a message-passing layer that generates boilerplate methods and auto-marshals messages. It does this with a protobuf compiler. Unlike gRPC, which creates HTTP/2 messages with information in headers, RSocket RPC generates binary encoded frames. The frames have been standardized into the RSocket extension frames.

RSocket RPC shares RSocket’s concept of a requester and responder. This means that a client can connect to a server, and that server can make calls to a service the client is hosting.

All information about an interaction is encapsulated in the frames sent between requester and responder. You do not need generated code to determine how to handle the message. This means that you do not need generated code to understand RSocket RPC calls. If you do not like RPC-generated code, you can instead use IPC-style code to handle a message. The IPC code also allows you to specify what serializers to use and allows you to use send methods other than protobuf.

GraphQL support is being added to use the IPC-style code. This will support query, mutation, and subscription using GraphQL.

Kehaw

👨‍💻Ke Haw 🇨🇳👨‍👩‍👧‍👦

风吹云散去,夜色好观星
Java | 前端 | 大数据

专注于 Spring Cloud 微服务架构与数据处理,研究一切与Java相关的开发技术,包括一部分前端技术。

目前的工作主要是关于B2B大宗商品在线交易领域的数据处理。如果对本站的部分内容感兴趣,请通过邮件、Twitter联系我🤝。

Fork me on Gitee
基于Spring Security + OAuth2 + JWT 的权限认证(一) Java-Stream学习第四步:数据处理 Java-Stream学习第三步:终端操作 Java-Stream学习第二步:处理流 Java-Stream学习第一步:创建流 Electron使用串口通信 Electron下调用DLL文件 国外SaaS服务供应商都是干什么的:Part1 为什么Kafka会丢失消息 Spring Boot中使用JSR380验证框架
Description lists
Kehaw's blog
Site description
人初做事,如鸡伏卵,不舍而生气渐充;如燕营巢,不息而结构渐牢;如滋培之木,不见其长,有时而大;如有本之泉,不舍昼夜,盈科而后进,放乎四海。
Copyright
© 2014 Copyright Kehaw | All rights reserved.