Syed Jafer K

Its all about Trade-Offs

Learning Notes #60 – EDA vs Request Response. When to use and Trade-Offs.

While learning about EDA, in middle, had a query on how it outperforms or preferred than Request Response. In this blog i took 5 parameters to compare. Its just my opinion.

In modern software design, Event-Driven Architecture (EDA) and the Request-Response Cycle stand out as two pivotal paradigms.

Each has its own merits and demerits, making them suitable for different use cases.

Below, we delve into their differences across several key dimensions: Reactivity, Coupling, Historical State, Architectural Flexibility and Data Reuse.

1. Reactivity

  • EDA: EDA is inherently reactive. Events trigger actions, often asynchronously, allowing systems to respond to changes in near-real-time. For example, a user interaction or system event can propagate changes without requiring synchronous processing.

    Use Case: A notification system where a user action triggers an email or push notification.

  • Request-Response Cycle: The request-response model is inherently synchronous. The client sends a request, and the server processes and responds, creating a tight coupling between action and response.

    Use Case: Fetching data from an API for immediate display.

2. Coupling

  • EDA: EDA promotes loose coupling. Event producers and consumers are decoupled, communicating via events without needing direct knowledge of each other.

    Example: A microservice publishes an event (e.g., “Order Placed”) without needing to know which services (e.g., inventory or shipping) will consume it.
  • Request-Response Cycle: This model typically results in tighter coupling. The client and server are aware of each other’s endpoints and expected behavior.

    Example: A frontend directly calling a backend API endpoint for user data.

3. Historical State

  • EDA: Events can be stored in logs, creating an auditable history of actions. This approach supports event sourcing, where the system state can be reconstructed by replaying events.

    Example: An e-commerce platform maintaining a log of user actions for analytics or debugging.

  • Request-Response Cycle: This paradigm doesn’t inherently store historical state. The focus is on immediate processing and returning responses, with state persistence requiring additional mechanisms (e.g., database writes).

    Example: API responses are ephemeral unless explicitly logged.

4. Architectural Flexibility

  • EDA: Offers high flexibility. Components can be added or removed with minimal impact on others, thanks to the event-driven design.

    Example: Adding a new service to listen for a specific event without altering existing components.

  • Request-Response Cycle: Modifying or scaling this architecture often involves changes to both client and server, increasing complexity.

    Example: Updating an API endpoint might require updates to all clients consuming it.

5. Data Reuse

  • EDA: Events are reusable by design. Multiple consumers can act on the same event, enabling diverse use cases without modifying the producer. Events can be stored in Event Log Store.

    Example: A “User Signed Up” event might trigger analytics logging, email confirmation, and onboarding workflows.

  • Request-Response Cycle: Data reuse is limited to the context of the specific request. Reusability often depends on explicit API design and documentation.

    Example: A single API call fetching data for one client may not be inherently reusable for other use cases.

To know more about what is an Event, checkout this link.