Câu hỏi phỏng vấn Reactive Systems
Câu hỏi

Explain Message-Driven v...

Câu trả lời

Message-Driven vs Event-Driven Approaches

Message-Driven Approach

Definition:
Message-driven architecture is a style where communication among system components is achieved through asynchronous message passing. Each component has a unique address, and messages are sent to these specific addresses. The components await the arrival of messages and react to them, otherwise lying dormant.

Key Characteristics:

  • Asynchronous Communication: Messages are sent and received independently, allowing for parallel processing and higher throughput.
  • Loose Coupling: Components are decoupled, meaning they do not need to know each other's location, state, or availability.
  • Location Transparency: Components can communicate regardless of their physical location.
  • Resilience: The queuing of messages allows systems to handle transient failures and maintain operation.
  • Flow Control: Message queues can be monitored and managed to apply back-pressure, ensuring the system operates within its resource limits.

Advantages:

  • Scalability: Components can be scaled independently.
  • Fault Tolerance: Systems can handle failures gracefully by retrying, buffering, or persisting messages.
  • Flexibility: Components can evolve independently without direct dependencies.

Example:
In a message-driven system, Component A sends a message to Component B's address. Component A does not wait for a response and continues its operation. Component B processes the message when it is ready, ensuring non-blocking communication.

Event-Driven Approach

Definition:
Event-driven architecture (EDA) is a style where the flow of the program is determined by events such as user actions, sensor outputs, or message passing from other programs. Events are significant changes in the state of a system's component, and components listen for and respond to these events.

Key Characteristics:

  • Asynchronous Inputs: Components react to events as they occur, without polling or querying each other.
  • Event Broadcasting: Events are broadcasted to any interested listeners, rather than being directed to a specific recipient.
  • Modularization: Logic handlers are broken down into smaller pieces, making the code easier to understand and maintain.
  • Scalability: New components can be added or modified without disrupting the overall system.

Advantages:

  • High Responsiveness: Components can react in real-time to events.
  • Extensibility: The system can easily adapt to changes by adding new event listeners.
  • Maintainability: Modularized logic handlers simplify the codebase.

Example:
In an event-driven system, Component A emits an event to a well-known location. Any component that is listening for this event can react to it. Component A d...

expert

expert

Gợi ý câu hỏi phỏng vấn

senior

What Does It Mean to be Resilient for a Reactive System?

expert

What Does It Mean to be Message Driven for a Reactive System?

middle

What Does It Mean to be Responsive for a Reactive System?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào