Made up of decoupled event processing components that asynchronously receive and process events. This architectural style can be used standalone or embedded with other architectural styles.
There is a difference between the architectural style of pure “Event-Driven” and events and event sourcing in general. Therefore, for more information specific to events and not the specific architectural style. See Integration Architecture > events.
Majority of processes in any architectural style are request-driven, using the request-based model. In the event-based model, systems react to an event that happens. We are inverting the responsibility for systems to act accordingly.
If we think about it, the event-model is all around us in nature and physics. When you throw a ball against the wall, the ball moves through the air as reaction to the event of force being exercised on the ball. We could mistake the idea that we “tell the ball” what to do, but rather through our understanding of physics (or experience) we know that the ball will respond with flying through the air, if we put pressure on it. Actually, in nature there is little that is genuinely “request-based”, even a “response” is a reaction to an event that indicated a “request”. The philosophical part aside, the request-based model demands a synchronous interaction, event-based is intentionally asynchronous.
Most common topologies are Broker and Mediator topology. They architecture characteristics and implementation strategy differs between these topologies, therefore it is important to understand the difference between them.
This is also known as The Choreography Pattern.
Used when you require a high degree of responsiveness and dynamic control over the processing of an event.
This topology has no central event mediator, messages flow across the event processor components in a chain-like broadcasting fashion. Works great when you have relative simple event processing flow that doesn’t require event orchestration and coordination There are 4 primary architecture components:
Event Processors advertise to the rest of the system the results of their processing as Processing events.
This is also known as The Orchestration Pattern.
Used when you require control over the workflow of an event process. Partially addresses the shortcomings of the broker topology.
There are 5 primary architecture components:
Event Processors do not advertise to the rest of the system, and only communicates back to the event mediator. Therefore “events” in this topology are more like “commands”.
It is common that there are multiple event mediators, each event mediator scoped to a specific domain, business process, or other logical grouping.
Mediator Delegation Model: One advice is to use a simple event mediator, and based on the contents of the event, it might forward this to a more complex event mediator if warranted. Therefore one must understand well the types of events being processed to choose the right type of event mediator.
Examples
Trade off between workflow control and error handling capability versus high performance and scalability. Performance and scalability are good in general for event-driven architecture, the broker topology does is slightly better than the mediator topology.
Broker/Choreography | Mediator/Orchestration | |
---|---|---|
Advantages | Highly decoupled events processors High scalability High Responsiveness High Performance High fault tolerance |
Workflow control Error handling Recoverability Restart capabilities Better data consistency |
Disadvantages | Workflow control Error handling Recoverability Restart capabilities Data inconsistency |
More coupling of event processors Lower Scalability Lower performance Lower fault tolerance Modeling complex workflows |
A key question that emerges is using “event-driven” versus “request-reply” based models.
Request-Based: Recommended for well-structured, data-driven (e.g. fetch user profile) requests when certainty and control over the workflow is needed.
Changes to a particular domain usually impact many event processors, mediators, and other messaging artifacts, hence why event-driven architecture is not domain partitioned.
A key characteristic is the asynchronous nature of event-driven architectures. With a simple “acknowledgement” one can create a responsive experience to the end user without having to fix the performant nature if it was request-based. Working asynchronous does come with a challenge, which is error handling. Error handling in an async environment is more challenging thant with request-based. Cause if an error happens, how do you get back to the end user to inform them and take proper action?
The Workflow Event Pattern (see Reactive Architecture) is one way to address error handling in asynchronous setting which addresses resiliency and responsiveness concerns. It works like the following:
Data loss is when a message is dropped or never makes it to its final destination. In a typical scenario there are 3 areas of potential data loss.
Another unique characteristic of event-driven architecture style is the ability to broadcast knowledge/events/messages without the need to know who is listening which is great for decoupling.
Sometimes synchronous communication is required which requires request-reply patterns. This is accomplished with request-reply messaging (aka psydosynchronous communication). Note that there 2 popular ways to implement this by using Correlation ID or temporary queues.
Event-driven architectural style can be used in conjunction with other architectural styles. Adding event-driven to any architectural style helps remove bottlenecks, provides a back pressure point in the event requests getting backed up, and provides a level of user responsiveness not found in other architectural styles.
Examples:
Characteristic | Rating |
---|---|
Partitioning Type | Technical |
Number of quanta | 1 to many |
Deployability | ⭐⭐⭐ |
Elasticity | ⭐⭐⭐ |
Evolutionary | ⭐⭐⭐⭐⭐ |
Fault Tolerance | ⭐⭐⭐⭐⭐ |
Modularity | ⭐⭐⭐⭐ |
Overall cost | ⭐⭐⭐ |
Performance | ⭐⭐⭐⭐⭐ |
Reliability | ⭐⭐⭐ |
Scalability | ⭐⭐⭐⭐⭐ |
Simplicity | ⭐ |
Testability | ⭐⭐ |