Skip to content

Instantly share code, notes, and snippets.

@notionquest
Last active November 18, 2019 17:28
Show Gist options
  • Save notionquest/8f42beef5c8fea4d15d34926808447d4 to your computer and use it in GitHub Desktop.
Save notionquest/8f42beef5c8fea4d15d34926808447d4 to your computer and use it in GitHub Desktop.
Reactive systems

https://projectreactor.io/ http://rsocket.io/docs/Motivations

Reactive Systems are:-

  • Responsive - The system responds in a timely manner if at all possible.
  • Resilient - The system stays responsive in the face of failure.
  • Elastic - The system stays responsive under varying workload.
  • Message Driven - Reactive Systems rely on asynchronous message-passing to establish a boundary between components that ensures loose coupling, isolation and location transparency

Http 1 Problem:-

HTTP/1.x has a problem called “head-of-line blocking,” where effectively only one request can be outstanding on a connection at a time.

Http 1.1 Problem:-

HTTP/1.1 tried to fix this with pipelining, but it didn’t completely address the problem (a large or slow response can still block others behind it). Additionally, pipelining has been found very difficult to deploy, because many intermediaries and servers don’t process it correctly.

Multiplexing addresses these problems by allowing multiple request and response messages to be in flight at the same time; it’s even possible to intermingle parts of one message with another on the wire.

RSocket Protocol:-

  • RSocket is an OSI Layer 5/6, or TCP/IP “Application Layer” protocol

  • RSocket supports bi-directional requests where both client and server can act as requester or responder.

  • Bi-directional, multiplex, message based, binary protocol based on Reactive streams back pressure

  • Cancellation - All streams (including request/response) support cancellation to allow efficient cleanup of server (responder) resources.

  • Resumability - With long-lived streams, particularly those serving subscriptions from mobile clients, network disconnects can significantly impact cost and performance if all subscriptions must be re-established.

Transport Layer Flexibility:-

Just as HTTP request/response is not the only way applications can or should communicate, TCP is not the only transport layer available, and not the best for all use cases. Thus, RSocket allows you to swap the underlying transport layer based on environment, device capabilities, and performance needs. RSocket (the application protocol) targets WebSockets, TCP, and Aeron, and is expected to be usable over any transport layer with TCP-like characteristics, such as QUIC.

RSocket Advantages:-

  • Reduce perceived latency and increase system efficiency by supporting non-blocking, duplex, async application communication with flow control over multiple transports from any language.

  • Reduce hardware footprint by:-

  • increasing CPU and memory efficiency through use of binary encoding
  • avoiding redundant work by allowing persistent connections
  • Reduce latency by:-
  • avoiding handshakes and the associated round-trip network overhead
  • allocating less memory and reducing garbage collection cost

HTTP vs RSocket

RSocket HTTP
Multiplexes messages Pipeline messages
Comm back pressure Does not comm back pressure
Supports cancelling / resume Does not support
streams
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment