Serverless EventSourcing on Azure vs AWS

Sebastian Kubiak
intive Developers
Published in
4 min readOct 17, 2022

EventSourcing with CQRS offers several benefits over the traditional CRUD method, including better security and performance. In this post, we will look at Serverless EventSourcing with Azure and AWS services and understand the difference between the architecture of both cloud providers.

CQRS is typically used with EventSourcing design patterns. Now, what is EventSourcing? State change can be stored using events. These events can be stored in an events log where they are persisted in the order they appear. The application's state can be recreated using this event log, and we can also do selective queries on it. This is called event sourcing. We can say that data storage as a series of events is called EventSourcing.

Serverless EventSourcing services by AWS and Azure

There are several benefits of going serverless, including no server management, pay-as-you-go pricing, flexibility to scale and automation at a higher level, etc. And event-driven architecture helps you to react to action immediately.

Here we will cover the difference between AWS and Azure Serverless EventSourcing Architecture and the services required. The event sourcing pattern in AWS can be implemented with Amazon Kinesis Data Streams, AWS Lambda, DynamoDB, API Gateway, and Amazon EventBridge. In Azure, Azure Functions and Azure Cosmos DB can be used to implement EventSourcing Architecture.

1. Amazon Kinesis Data Streams

It is a serverless streaming data service by AWS that enables the user to capture, process, and store data smoothly streams at any scale. Amazon Kinesis Data Streams can be quickly paired with AWS Lambda to process requests in event-driven architectures. Also, it can store terabytes of data from daily application logs for live dashboards and real-time analytics.

2. AWS Lambda

Lambda is an event-driven and serverless computing service by AWS which lets you run code without managing the server. It can be triggered with 200+ AWS services and can process data at any scale.

3. Amazon API Gateway

API Gateway enables developers to create, publish, secure, monitor, and manage APIs for data access and backend functionalities.

4. Amazon DynamoDB

DynamoDB is a NoSQL database by AWS that can securely deliver nearly unlimited throughput and storage and is easy to integrate with other AWS services like Lambda.

5. Amazon EventBridge

It is a serverless event bus designed to store and scale using events generated from the application. It delivers real-time data from event sources to AWS Lambda and other SaaS services.

First, we can set up Amazon API Gateway to receive and forward incoming requests to AWS Lambda. Lambda will later load these incoming requests into the Kinesis event stream. Lambda will also store the events from the incoming stream in DynamoDB, where all events will be stored.

EventBridge requires no extra setup, including unawareness of event targets from event sources. You can define filtering rules and API destinations directly. Some of the use cases of EventBridge are:

  • SaaS applications’ customization with AI and ML
  • Monitoring and auditing of services
  • Accelerate the speed of architecture

For Microsoft Azure, Cosmos DB, Azure Functions and Event Grid are used to design a serverless EventSourcing Architect.

  1. Azure Functions

It is an event-driven serverless compute service by Azure that is ideally used to build and deploy without additional setup and operation. It works like AWS lambda and can be triggered by other Azure services.

2. Azure Cosmos DB

It is a fully managed NoSQL database by Microsoft with fast response time and instant scalability to store extensive data at any scale.

3. Azure Event Grid

Azure Event Grid builds and manages event-driven architectures and applications with high availability, performance, and dynamic scale. It has inbuilt support for other Azure services, and you can filter specific events to route on different endpoints.

Serverless EventSourcing on Azure vs AWS

AWS EventBridge vs Azure Event Grid

Both services are pretty similar at various points. Though unlike AWS EventBridge, Event Grid does not support external partners. Azure charges for each operation/call to service, and in EventBridge, only published operations to the service are charged. No extra charges for event rules and delivery. Azure offers the first 100000 operations free and later €0.60 per 1 million operations. AWS charges $1 per million operations, and events published by AWS Services are free. EventBridge and Event Grid are only available in one region, and no cross-region data replication is available. EventBridge offers a message history feature to retrieve previous messages, but Azure does not support that.

AWS DynamoDB vs Azure Cosmos DB

DynamoDB costs are lower than other databases, including Cosmos DB. DynamoDB is also easy to use and set up, whereas Cosmos DB has SQL-like queries but is comparatively more complex. Both of them are easy to integrate with their core services.

AWS Lambda and Azure functions

Lambda only supports uploaded code in a .zip file where Azure Functions integrate with VS, Github, and Bitbucket. Lambda runs on Linux, Functions runs on Windows, and both support multiple language support. The pricing model is similar for both services.

Conclusion

AWS provides more flexibility in EventSourcing, as it offers a broader range of services that can be used to build an EventSourcing architecture. However, Azure provides a more managed approach and offers a complete solution for EventSourcing that is easier to use and set up.

--

--

Sebastian Kubiak
intive Developers

See the license agreement, skip reading, click "I agree". Install. Programming but this time funny