📌 Summary: alternative RSocket library for high performance network applications on JVM

February 1, 2023
RSocket Mstreams java

Summary

Project consists of API modules for each vendor library - Message-Streams, and respective runtime implementations - RSocket-JVM.

Message-Streams includes RPC: code-generation based remote procedure call system on top of Protocol Buffers.

Message-Streams sources are available on github, and binaries are published on MavenCentral.

RSocket is low latency/high throughput L5 network protocol intended for high-performance services communication. It is transport agnostic and may run on top of any reliable byte stream transport.

Fast alternative RSocket on JVM

Several problems were present in official RSocket/RSocket-java library:

Message Streams with flow control

Protocol offers rich set of interactions modelled as composable streams of binary messages, with flow control, error handling and cancellation as first-class concepts:

fire-and-forget (1:0), request-response (1:1), request-stream (1:n), request-channel (n:n).

Interactions are exposed to end user with MessageStreams API.

Traditional streaming

GRPC-stubs (StreamObserver) API support allows drop-in replacement of GRPC-java in services for significantly better throughput.

interface MessageStreams {
  void requestResponse(Message message, StreamObserver<Message> responseObserver);
  void requestStream(Message message, StreamObserver<Message> responseObserver);
  StreamObserver<Message> requestChannel(StreamObserver<Message> responseObserver);
  void fireAndForget(Message message, StreamObserver<Message> responseObserver);
}  

Reactive streams

Reactive Streams conformance makes protocol compatible with project-reactor, smallrye-mutiny and rxjava3

interface MessageStreams {
  Publisher<Message> requestResponse(Message message);
  Publisher<Message> requestStream(Message message);
  Publisher<Message> requestChannel(Publisher<Message> messages);
  Publisher<Void> fireAndForget(Message message);
}

This library demonstrates throughput of up to millions of messages per second / per vCPU with every interaction - more details below.

RSocket-JVM

Library relies on shared protocol core with minimal dependencies (only netty-buffer) for use with vendor libraries on JVM.

RSocket-JVM is currently comprised of JDK only RSocket-futures for request-response (CompletableFuture), traditional streaming with RSocket-GRPC (GRPC-stub), several flavors of reactive: RSocket-rxjava (rxjava3), RSocket-reactor (project-reactor) and RSocket-mutiny (smallrye-mutiny).

Notable features:

         message size,bytes    8(same payload)        8             128            512

request-response                     2.2m            1.7m           1.6m          1.3m
request-stream                       3.5m            3.2m           3.2m          3.2m
request-channel                      4.8m            3.2m           3.1m          2.4m

Table 1. Single vCPU RSocket throughput (project-reactor, non-tls, TCP EPOLL with linux 5.4.0, jdk11), millions of messages per second.

GRPC compatibility

jauntsdn/RSocket and jauntsdn/RSocket-RPC is compatible with GRPC: protocol design allows its streams to accommodate http2 streams. Compatibility was verified with RSocket-GRPC transport, observed performance characteristics were identical to official grpc-java only setup.

RPC for application services

jauntsdn/RSocket-RPC is RPC system based on Message-Streams & Protocol Buffers. It relies on code generation with protobuf C++ plugin extensions and is compatible with GRPC.

Notable features:

The result is significantly higher performance: millions of messages per second per core, with each interaction.

         message size,bytes          8             128            512

request-response                    1.45m          1.0m          0.55m
request-stream                      3.3m           2.4m          0.9m
request-channel                     3.5m           2.4m          1.25m

Table 2. Single vCPU RSocket-RPC throughput (project-reactor, non-tls, TCP EPOLL with linux 5.4.0, jdk11), millions of messages per second.

Multiple network transports

RSocket is transport agnostic, and runs on top of any reliable byte stream transport. jauntsdn/RSocket project hosts several transports, shared & directly usable by each RSocket-JVM vendor specific library:

Load estimation

Network/service latency based load estimation for RSocket & RSocket-RPC with requests leasing, which enables low-cost yet efficient load balancers.

Source code/binaries

Message-Streams (RSocket-JVM API) sources are available on github, and binaries are published on MavenCentral.

Jaunt-RSocket-RPC, Spring-RSocket, GRPC: quantitative and qualitative comparison

September 3, 2021
RSocket Mstreams java

Alternative RSocket-RPC: fast application services communication and transparent GRPC bridge

May 20, 2021
RSocket Mstreams java grpc

RSocket-JVM: streamlining implementation for each vendor platform

April 22, 2021
RSocket Mstreams java