buzz about reactive systems over the past couple of years. Along with the buzz comes the collection of relevant keyword salads like reactive streams, reactive extensions, reactive programming, functional reactive programming, etc. which we’ll look at in a moment
allows multiple individual applications to blend into one unit, reacting to their environment, while staying aware of each other. - They are Capable of responding to queries very quickly and this even in case of failure or overload.
type of system is able to ensure a constant quality of service, based on minimum and consistent response times. Resilient - The system remains available in the event of an error . Elastic - The system remains available regardless of the workload. Message Driven - The system uses message passing asynchronous between its components to ensure low coupling.
social networks, large banking systems, and popular trading platforms are implemented? Why do they quickly and reliably cope with a large number of requests to the system? How is it that they are able to: - Manage breakdowns and relies - Manage load peaks - Able to send, receive, and forward messages in an unreliable network
All components interact through messages sent and received asynchronously which creates a temporal boundary between the components, making decoupling possible over time (allowing competition) and space (allowing for distribution and mobility) • Elasticity - Decoupling in space (Load Balancing Strategy) and at peak load more consumer instances are launched • Resilience - Failure is handle locally (Replication) Upon Failure Message may be processed by another • Responsive - Achieved by having both Elasticity and Resilience
building reactive systems that emphasises formulating asynchronous programming logic as data streams, and automatic propagation of changes to values of correlated variables in the system. - It belongs to the declarative programming paradigm family where the end result is simply described without necessarily outlining the intermediate steps to get there - By design it favours Functional Programming
Streams are cheap and Ubiquitous Anything Can be a stream in Reactive Programming: :variables, user inputs, properties, caches, data structures, etc. Example: Your Twitter feed would be a data stream in the same fashion that click events are. You can listen to that stream and react accordingly.
observables. Whenever the observable emits the data all the registered observer receives the data . After which they can perform various operations like parsing the JSON response or updating the UI. If there is an error thrown from observable, the observer will receive it and react accordingly.
A message-driven architecture is the foundation of Reactive applications. A message-driven application may be event-driven, actor-based, or a combination of the two. - An event-driven system is based on events which are monitored by zero or more observers. This is different than imperative programming because the caller doesn’t need to block waiting for a response from the invoked routine. Events are not directed to a specific address, but rather watched (or listened) for.
an extension of the message-passing architecture, where messages are directed to a recipient, which happens to be an actor. Messages may cross thread boundaries or be passed to another actor’s mailbox on a different physical server. This enables elasticity — scaling out on demand — as actors can be distributed across the network, yet still communicate with each other as if they were all on the same machine
applications are focused on triggering events. Events may be encoded as messages that are placed in a queue that is monitored by zero or more observers. The big difference between event-driven and imperative style is that the caller does not block and hold onto a thread while waiting for a response. The event-loop itself may be single threaded, but concurrency is still achieved while invoked routines go about their business (and potentially block on IO themselves) while allowing the (sometimes single) threaded event-loop to process incoming requests. Instead of blocking on a request unless completely processed, the caller’s identity is passed along with the body of the request message so that — if the invoked routine chooses to do so — the caller can be called back with a response.
around asynchronous message passing between multiple actors. - An actor is a construct with the following properties: ❖ A mailbox for receiving messages. ❖ The actor’s logic, which relies on pattern matching to determine how to handle each type of message it receives. ❖ Isolated state — rather than shared state — for storing context between requests.
benefit of actor-based concurrency is that in addition to the benefits gained by an event-driven architecture, scaling computation out across network boundaries is even easier, and callback-hell is avoided because messages are directed to actors. - This is a powerful concept that makes it easy to build hyper-scalable applications that are also easy to design, build, and maintain. Rather than thinking about time and space, or deeply nested callbacks, you only need to think about how messages flow between actors.