02 03 Event-Driven Architecture
02 03 Event-Driven Architecture
Key Components
• Events: Signals that something notable has occurred.
• Event Producers: Entities that create events.
• Event Consumers: Entities that react to events.
• Event Channels: Queues or streams where events are stored temporarily.
Examples
• Event-driven architecture is particularly effective in situations where you need
high levels of scalability, responsiveness, and adaptability. Below are some
example applications where this architecture fits well:
1
Advantages
• Scalability: Can easily handle a large number of events and adapt to the
workload.
• Decoupling: Producers and consumers don't need to know about each other.
• Responsiveness: Enables real-time updates and responsiveness.
• Flexibility: Allows for easier changes and extensions to the system.
Disadvantages
• Complexity: Managing and debugging can be challenging.
• Eventual Consistency: Might not be suitable for operations that require immediate
consistency.
• Potential for Failed Events: Handling of event failures can be tricky.
2
Microservices Architecture
• Scaling:
o Both architectures are built for scalability but differ in approach.
o Microservices scale by deploying more instances of each service, whereas
Event-Driven scales by handling more events either by adding more
consumers or optimizing channels.
• Complexity:
o Microservices can lead to complexity in managing and coordinating
multiple services.
o Event-Driven architectures also add complexity but mainly in managing
events, their sequence, and eventual consistency.
• Data Consistency:
o Microservices often face challenges in maintaining data consistency across
services, generally solved by techniques like sagas or two-phase commit.
o Event-Driven architectures naturally lean towards eventual consistency,
making it a better fit for systems where immediate consistency is not a
strict requirement.
• EDA can be used in conjunction with other architectures for specific use-cases.