Event-Driven Architecture (EDA) is a design approach where systems react to events or changes in state.
- Enables systems to process events asynchronously.
- Allows systems to share information without being aware of each other.
- Makes it easier to increase number of services to handle increased workloads.
- Improves decoupling and independence between services.
- Resilient and flexible microservices.
- When you need to process data asynchronously
- Email Notification
- Media Processing
- Log processing
- Real-Time Analytics
- When we need to have a scalable system
- Eventual consistency across data
- No need to know the details or protocols of other services.
- Loosely coupled components
Events are immutable and mostly lightweight information about the state change.
-
Immutability: Once an event is created, it cannot be changed.
-
Lightweight: Events are usually designed to be small in size, containing just enough information (usually a payload) to describe a change in state or an action that occurred.
-
Event Sourcing: Events are often used as a source of truth, meaning the state of the system can be reconstructed by replaying a sequence of events.
-
Durability: Events are often persisted in a durable event log, ensuring they are not lost even in case of system failures.