Patterns - Messaging, Publisher-subscriber, dynamic routing
Discussion on Messaging pattern Context: Some distributed systems are composed of services that were developed independently. To form a coherent system, however, these services must interact reliably, without incurring overly tight dependencies on one another. Problem Integrating independently developed services, each having its own business logic and values, into a coherent application requires…
Messaging, Publisher-Subscriber, and Dynamic Routing are three common patterns used in distributed systems to enable reliable and efficient communication between services.
In the Messaging pattern, services exchange data asynchronously via a message bus. The sender and receiver encode messages containing request data and types, allowing them to communicate without needing to know each other's data types statically. This decouples services, enabling them to interact without concerns about networking and service location. However, the lack of statically typed interfaces makes it challenging to validate system behavior beforehand and adds extra time and space for message processing.
The Publisher-Subscriber pattern allows components in an application to operate independently while still disseminating information to other components when necessary. A notification mechanism informs components about state changes or events affecting their computation. Components only need to know when another component is in a specific state, not which specific component it is.
This decouples applications and allows components to remain independent. However, the publisher can cause unnecessary overhead if subscribers are interested only in a specific type of event, resulting in filtering events and potential performance issues.
Lastly, the Dynamic Routing pattern is useful for building complex business processes from simple services. Routing messages through a distributed system based on filtering rules is inefficient because each message is inspected by every filter and router, whether or not it can be processed. A message router with filtering rules and knowledge about processing destination paths ensures messages are delivered only to processing endpoints capable of handling them.
This approach eliminates the need for services to deal with networking concerns or know each other's location, optimizes communication, and allows services to dynamically become available or unavailable. However, dynamic routing introduces performance overhead, a single point of failure, and potentially complex behavior when rules conflict.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to