Skip to content
Pedlar Logo
Pedlar
GithubLinkedIn

Event Sourcing with Microsoft Azure (Event Sourcing Part 2)

system design, azure1 min read

Introduction

In Part 1 we identified what Event Sourcing is and some common use cases. In this article we'll explore what Azure resources you can use for an building out an Event Sourcing solution and why they were chosen.

Azure Resources

For the data store we'll use Azure Cosmos DB.

For the application we'll use Azure Functions.

Why Cosmos DB:

  • Serverless mode for handling unpredictable traffic (can scale up and down)
  • It's great for append only operations
  • It's also great for read or write only
  • Flexible schema (schemaless)
  • Charges only for storage when it's inactive

Why Azure Function:

  • Serverless mode for handling unpredictable traffic
  • Designed to react to events, using event bindings
  • Low total cost of operation (TCO) as it only charges when in use

How to subscribe to Events

Using the Cosmos DB Trigger for Azure Functions. It's like an RSS feed for the data and it outputs an ordered list of documents. Azure Functions have bindings which allows them to listen to the Change Feed.

Event Sourcing Tips & Gotchas

  • Eventual Consistency
  • Event format vital
  • Order of events vital
  • Create snapshots for long streams
  • Idempotent consumers

Serverless Tips & Gotchas

  • Single region for Cosmos DB in serverless mode
  • Data storage for only 50 gb per container
  • Good for spiky traffic
  • No real time scenarios