An event-driven architecture uses events to trigger and communicate between decoupled services and is common in modern applications built with microservices.
Event-driven architectures have three key components:
- Event producers,
- Event routers, and
- Event consumers.
A producer publishes an event to the router, which filters and pushes the events to consumers. Producer services and consumer services are decoupled, which allows them to be scaled, updated, and deployed independently.
What is an Event?
An event is a change in state or an update. Events can either carry the state or events can be identifiers.
What can be achieved?
Cross-account, cross-region data replication:
By using an event router to transfer data between systems, you can develop, scale, and deploy services independently from other teams.
Resource state monitoring and alerting:
Monitor and receive alerts on any anomalies, changes, and updates.
Fanout and parallel processing:
If you have a lot of systems that need to operate in response to an event, you can use an event-driven architecture to fan out the event without having to write custom code to push to each consumer.
Integration of heterogeneous systems:
If you have systems running on different stacks, you can use an event-driven architecture to share information between them without coupling.
Develop with agility:
You no longer need to write custom code to poll, filter, and route events; the event router will automatically filter and push events to consumers.
Cost Saving:
Event-driven architectures are push-based, so everything happens on-demand as the event presents itself in the router.
Scaling:
By decoupling your services, they are only aware of the event router, not each other. This means that your services are interoperable, but if one service has a failure, the rest will keep running.
Amazon EventBridge
Amazon EventBridge is a serverless event bus that makes it easier to build event-driven applications at scale using events generated from your applications, integrated Software-as-a-Service (SaaS) applications, and AWS services. EventBridge delivers a stream of real-time data from event sources such as Zendesk or Shopify to targets like AWS Lambda and other SaaS applications. You can set up routing rules to determine where to send your data to build application architectures that react in real-time to your data sources with event publisher and consumer completely decoupled.
Cost Analysis
If your application published 2 million events in a month, each averaging 6KB; and you enabled archiving on your development event bus for replay and replay all of them, your charges would be calculated as follows:
- Monthly events = 2M events * $1.00/M = $2.00 per month.
- Archive Processing = 2M events * 6KB / (1024 * 1024) * $0.10/GB = $1.14
- Storage Costs = 2M events * 6KB/(1024*1024) * $0.023/GB = $0.26 per month
- Replayed Events = 2M * $1.00/M = $2.00 per month
Total Monthly EventBridge charges = $2 (event publishing) + $1.14 (Archive Processing) + $0.26 (Storage) + $2.00 (Replaying) = $5.40 per month.
Reference: https://aws.amazon.com/eventbridge/pricing/