javaspringspring-webfluxrsocket

How is Rsocket Asynchronous?


I am new to rsocket and currently learning its benefits over HTTP2 and other protocols. One thing I haven't understood is this:

The RSocket protocol embraces this and models all communication as multiplexed streams of messages over a single network connection, and never synchronously blocks while waiting for a response.

What does synchronicity mean here? Lets say, two calls are made to a REST endpoint over HTTP2/1.1(Using Spring's WebClient, which is non-blocking and reactive) and other over rsocket. What difference will it make?


Solution

  • RSockets protocol is designed to allow multiple streams of data to be transmitted over a single network connection concurrently. Without blocking or waiting for a response to one stream before starting another.

    Protocols like HTTP/2 and HTTP/1.1, do not allow for multiple streams of data over a single connection. They build on the concept that each request is sent and processed individually. It purely works on a one-out-one-in-next basis.

    Send a request > Wait for answer > Receive Answer > Send next request

    (This is how HTTP/1.1 works basically. HTTP/2 is a bit different, but builds on this frame)

    Using Springs WebClient can help you with some of the limitations of HTTP/2 and HTTP/1.1 by allowing for asynchronous requests. Though you should know that it still relies on the HTTP protocol to support synchronous streams, so it may not offer the same level of performance and efficiency as RSocket.