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?
CodePudding user response:
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.
CodePudding user response:
In the context of communication protocols like RSocket and HTTP, synchronous blocking refers to a situation in which a client must wait for a response from the server before it can continue with other tasks. This can be inefficient, especially in high-concurrency scenarios where many clients are trying to communicate with the server at the same time.
In contrast, non-blocking, reactive protocols like RSocket and HTTP2 allow for multiple, concurrent requests to be handled by the server without blocking. This can improve the overall performance and scalability of the system, since clients can continue processing data or handling other requests while they are waiting for a response from the server.
The main difference between RSocket and HTTP2 in this regard is that RSocket is a binary protocol that is specifically designed for high-performance, low-latency communication, while HTTP2 is an update to the HTTP1.1 protocol that adds support for multiplexing and other features to improve performance. As a result, RSocket may offer better performance and scalability compared to HTTP2 in certain scenarios. However, the best choice of protocol will depend on the specific requirements of your application.