Overview of Event-Driven Architecture (EDA)
Event-Driven Architecture (EDA) :
Event-Driven Architecture is a software development approach in which services (operations) of the software are triggered by events. And that is why this approach is known as Event-Driven Architecture.
Well, then what does an event mean? When a user takes an action in the application built using the EDA approach, a state change happens and a reaction is generated that is called an event.
Here are some examples,
- A new user fills the form and clicks the signup button then an account is created, which is an event.
- You click the subscribe button on a YouTube channel and you become their subscriber. This subscription is an event.
- You press the send button after typing a message and a sending process is an event.
Components of EDA :
EDA has 4 components as below.
- Event –
A state change happened by a user’s action.
- Service/event handler –
Services typically react to the events, and reaction can be a process or a generation of events accordingly.
- Event Loop –
The event loop handles and ensures the smooth flow of interactions between events and services.
- Event Flow Layers –
Event flow layers are classified into three. They are, Event producer, event consumer. event channel/router.
How does EDA work ?
When an event producer detects a state change, it produces an event and represents event as a message. In this stage, producer doesn’t know the event consumer. It just sends the event to the router. The router then processes event and performs required response to the event. After that, router informs event consumer and sends the event to the consumer. The output of the event is result of event consumption.
Here, the layers are loosely connected. So the event sender doesn’t have to know the event consumer. And also the consumer doesn’t have to know the producer of events. This arrangement leads to interoperability.
Benefits of Event-Driven Architecture :
- Scalability –
The flexibility of an application developed in this approach enables scaling up and down based on the needs. It can also handle an enormous amount of data needed for analytics.
- Interoperability –
The loosely coupled layers/services of EDA enables instant access to big and varied volumes of data. And when the producer sends an event for consumer even if the consumer is down, the event persists on router and then consumer can consume event. It enhances flexibility and robustness of the application.
- Cut down operational costs –
In Event-Driven Architecture, everything happens in response to an event. So the network bandwidth consumption, CPU utilization, and encryptions are comparatively lower than traditional architecture – Request Driven model.
- Auditing is made easier –
The event channel or router is an intermediate that audits application and defines guidelines. These guidelines can set data access control and encrypt events on both the producer and consumer layers.
- Asynchronicity –
Event-Driven Architecture is asynchronous without blocking. That means if an event triggers a service and starts reacting to the event, then this will not block other services from being running or reacting. This aspect makes Event-Driven Architecture more flexible and adaptable. Services in this architecture are not connected to are not dependent on each other. So this has higher fault tolerance as well.
When we will go for Event Driven Architecture :
- Parallel Processing –
When there is a need that multiple systems will run to operate in response to an event in that case we can use Event-Driven Architecture. So, that the respective router will push the events to systems and each system can be process the event differently for different purposes.
- Resource State Monitoring –
Event-Driven Architecture is helpful when there is a need of continuous tracking and monitoring of resources in that case EDA can monitor and alert any changes or updates in the resources.
- Heterogeneous System –
If the system running on multiple stacks, in that case Event-Driven Architecture can be used to share information between them. The event router will take the responsibility of interoperability among the systems.
Implementing Event-Driven Architecture is highly beneficial yet it’s very complex to implement mainly because of its asynchronous operation distribution. Other than that architecture is flexible, can be replaced easily and it’s highly responsive. With the right expertise, anybody can reap benefits from Event-Driven Architecture.