DEV Community


Posted on

Event Driven patterns

Advantages of using an event driven pattern

  • You can produce and event without messing with the independent services
  • You can add new event consumers without affecting the ones that already exist

Disadvantages of using an event driven pattern

  • No state log, you have to debug the system to figure out what is happening

Event Notification System

In this kind of system, the only thing that you need to know, is that the event actually happened.

This response can be very generic, like, "something changed"

State transfer

When an event is triggered and something change, you have to update the state of the application in your system, so, this envolves a bit more traffic, because the services have to check for the state changes that event triggered.

We can fix that problem by putting more information on the event, so the services have a clue of what has actually changed.

We get the old state, change it, and create new state with only the information that is important to the service that needs to deal with this event.

After we have that information, we won't need to call the service where the information came from, because we already have what we need.

If the previous service goes down, that's not a problem because we already have the information we need.

Eventual consistency

We have all that state transfer advantages, but now we have an eventual consistency, which means that with all the services trying to trigger the events from the producer, we will have a delay to get our data readable.

Discussion (0)