SlideShare una empresa de Scribd logo
1 de 41
Descargar para leer sin conexión
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
Azure tales: a real world CQRS and
ES Deep Dive
Andrea Saltarello
Solution Architect @ Managed Designs
https://twitter.com/andysal74
https://github.com/andysal
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
Many thanks to our sponsors & partners!
GOLD
SILVER
PARTNERS
PLATINUM
POWERED BY
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
Andrea Saltarello
• Solution Architect @ Managed
Designs
• Microsoft .NET MVP since 2003
• Microsoft Regional Director
• Author, along with Dino, of .NET:
Architecting Applications for the
Enterprise, di Microsoft Press
• Basically, a software architect eager
to write code ☺
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
• CQRS/Event Sourcing recap
• CQRS/ES @ Azure: deployment blueprints
• Technology & economic considerations
Agenda
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
CQRS/ES RECAP
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
Not the way to implement Event Sourcing, but a
working way to do it nonetheless
Demo app available on Github (GPL3): it is a real open
source project of which my company sells
customizations
There’s no silver bullet
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
A few fancy dressed blokes going for a jaunt
The (Relational) Lord of the Rings
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
It really became clear to me in the last couple of years that we
need a new building block and that is the Domain Event.
[Eric Evans]
An event is something that has happened in the past.
[Greg Young]
A domain event … captures the memory of something
interesting which affects the domain
[Martin Fowler]
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
Instead of focusing on a system’s last known
state, we might note down every occurring
event: this way, we would be able to (re)build
the state the system was in at any point in time
just replaying those events
To cut a long story short: we’d end up
recording an event stream
Event Sourcing in a nutshell
JobOrderStarted InvoiceIssuedJobOrderExtended JobOrderCompleted
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
The (immutable) composition of:
• A (meaningful) name
• (Typed) Attributes
What’s an event, anyway?
InvoiceIssued
DateOfIssue
Customer
Price
ProjectStarted
DateOfStart
ProjectId
ProjectCompleted
DateOfCompletion
ProjectId
ProjectRegistered
DateOfRegistration
DateOfEstimatedCompletion
ProjectId
CustomerId
Price
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
DEMO
Event Stream
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
Still, my users are more interested in knowing a job
order’s balance or whether an invoice has been paid.
(cit.)
That is, we need a way to produce an entity state
Event Stream vs. «My application»
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
DDD’s Aggregates provide a convenient way to encapsulate event
management
Aggregate: A collection of objects that are bound together by a root
entity, otherwise known as an aggregate root. The aggregate root
guarantees the consistency of changes being made within the
aggregate.
[Wikipedia]
An aggregate is responsible for:
• encapsulating business logic pertaining to an “entity”
• generating events to have them available for saving
• replaying events in order to rebuild a specific state
Event Sourcing <3 DDD
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
DEMO
Aggregates
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
var aggr = repository.GetById<TAggr>(id); //Triggers [time travelling] event
replay
aggr.DoSomething(); //Biz logic + events
repository.Save(aggr); //Updates the event stream
Repository: Mediates between the domain and data mapping layers using a
collection-like interface for accessing domain objects. [DDD]
Aggregates vs. Events vs. Repos
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
DEMO
Time Travelling
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
Still², my users are more interested in knowing a job
order’s balance or whether an invoice has been paid.
Quickly.
Ways to achieve that:
• Snapshots can help
• CQRS to the rescue: let’s have a database storing the usual «last
known system state» and use it as a read model
Event Stream vs. «My application»
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
Acronym for Command Query Responsibility
Segregation
Basically, ad hoc application stacks for either “writing”
or reading:
• “Command” stack writes events and snapshots
• “Read” stack reads from eventually consistent, reading
purposes optimized database(s)
Enter CQRS
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
DEMO
Read Model
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
1. Application sends a command to the system
2. Command execution might alter the system’s state and
then raise events to state success/failure
3. Events are notified to interested subscribers (a.k.a.
handlers), such as:
• Workflow managers (a.k.a. «Sagas») which could execute more
commands
• Denormalizers, which will update the read model database
Note: command/event dispatch/execution will usually be
managed by a Mediator («bus»)
CQRS/ES in a nutshell
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
Application
Layer
Snapshots
Event store
Read stack
Domain Layer
Ad-hoc DBHandlers
Command Event Data
Handlers
Model ServicesB
U
S
CQRS/ES at a glance
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
DEMO
Handlers
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
BLUEPRINTS
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
Azure <3 CQRS: n-tiered
Back-endFront-end
Application
Layer
Snapshots
Event store
Read stack
Domain Layer
Ad-hoc DBHandlers
Command Event Data
Handlers
Model Services
A
S
B
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
Front end:
• VM
• Web role
• App Service
• Docker
Back end:
• Worker role
• Service Fabric
• Docker
N-tiered deploy
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
Azure <3 CQRS: full stack
App Service
Application
Layer
Snapshots
Event store
Read stack
Domain Layer
Ad-hoc DBHandlers
Command Event Data
Handlers
Model Services
A
S
B
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
• VM
• Web role
• App Service
• Docker
• Service Fabric
Full stack deploy
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
A fine-grained deploy allows each “component” to be:
• Evolved
• Deployed
• Configured (e.g.: scaled)
Independently, thus having each one only consuming
the resources it really needs but it means having more
moving parts to manage
N-tiered vs. Full stack
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
TECHNOLOGY & ECONOMIC
CONSIDERATIONS
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
App Service Cloud Services Docker Service Fabric VM
PROs:
• PaaS
PROs:
• PaaS
PROs
• Deploy
• Scaling*
• Documentation/samples
PROs:
• Fault tolerance
• Load balancing
• Deploy
PROs
• (Usually) cheapest
monthly bill
• No new skiils needed
• Unparalled option set
CONs:
• .NET 4.5.1 only(*)
CONs: (?)
• Need for an orchestrator
CONs:
• Ad-hoc SDK
CONs:
• Management
Azure Compute smackdown
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
A 2 cores, 3.5 GB RAM, 60 GB disk compute unit costs:
• 75,92 EUR/month as a VM
• 94,11 EUR/month as an AppService
• 100,39 EUR/month as a Cloud Service (*)
• 338,80** - 564,47*** EUR/month as a Service Fabric
cluster
* 490Gb disk
**3 nodes
***5 nodes
From a billing perspective
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
An effective CQRS/ES implementation usually relies on
2 structural pillars:
• A mediator bus
• An event store
Well come on and let me know…
Should I stay build or should I go (shopping)? (demi
quote)
On a technology side…
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
Rebus.net:
• is an open source, production tested bus for .NET. Source code is available
on Github, but usually Nuget packages will do.
• provides much-needed features such as:
– Fault tolerance
– Scalability
– Events’ scheduling
– Easy migration from on-premises to cloud
• requires:
– a transport protocol (e.g.: MSMQ, RabbitMQ, Azure Service Bus, Amazon Sqs, ...)
– an IoC container (e.g.: Autofac, Ninject, .NET Core ServiceProvider, StructureMap,
Unity, Windsor...)
– a storage (e.g.: MongoDB, RavenDb, SQL Server, ...)
Enter Rebus.net
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
DEMO
Configuration
Back to the Future
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
MementoFX NEventStore
https://www.nuget.org/packages?q=MementoFx
• FOSS
• DDD/ES stack
• Time travelling
• Alternative timelines
https://www.nuget.org/packages?q=NEventStore
• FOSS
• Event Store API only
• “CommonDomain” package available to support DDD
• Wide community + Slack channel
CQRS Application Frameworks
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
CosmosDB mLab VM
PROS:
• Multiple APIs (e.g.: DocumentDB,
MongoDB)
• PaaS
• Scalability/Georedundancy
PROS:
• PaaS
• Large ecosystem
PROS:
• Unparalleled configuration
options
CONS:
• Billing
CONS:
• Few instance sizes
CONS:
• Management
Event Store: a couple of options
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
• A CosmosDB database is billed on a per-collection basis, with
a 1 GB, 400 RU/sec collection costing 20.08 EUR/month
• A 3 “A2” VM MongoDB Linux cluster costs 146,82 EUR/month
(but we’d have to manage it)
• mLab’s dedicated cluster options:
From a Billing perspective
Size RAM Disk Monthly price
M1 1.7 GB 40 GB $200
M2 3.5 GB 60 GB $400
M3 7 GB 120 GB $800
M4 14 GB 240 GB $1,320
M5 28 GB 480 GB $2,450
M6 56 GB 700 GB $4,280
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
THANK YOU!
@ITCAMPRO #ITCAMP17Community Conference for IT Professionals
Q & A

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Xamarin Under The Hood - Dan Ardelean
 Xamarin Under The Hood - Dan Ardelean Xamarin Under The Hood - Dan Ardelean
Xamarin Under The Hood - Dan Ardelean
 
From Developer to Data Scientist - Gaines Kergosien
From Developer to Data Scientist - Gaines KergosienFrom Developer to Data Scientist - Gaines Kergosien
From Developer to Data Scientist - Gaines Kergosien
 
How to secure and manage modern IT - Ondrej Vysek
 How to secure and manage modern IT - Ondrej Vysek How to secure and manage modern IT - Ondrej Vysek
How to secure and manage modern IT - Ondrej Vysek
 
Blockchain for mere mortals - understand the fundamentals and start building ...
Blockchain for mere mortals - understand the fundamentals and start building ...Blockchain for mere mortals - understand the fundamentals and start building ...
Blockchain for mere mortals - understand the fundamentals and start building ...
 
Kubernetes - Cloud Native Application Orchestration - Catalin Jora
Kubernetes - Cloud Native Application Orchestration - Catalin JoraKubernetes - Cloud Native Application Orchestration - Catalin Jora
Kubernetes - Cloud Native Application Orchestration - Catalin Jora
 
Everyone Loves Docker Containers Before They Understand Docker Containers - A...
Everyone Loves Docker Containers Before They Understand Docker Containers - A...Everyone Loves Docker Containers Before They Understand Docker Containers - A...
Everyone Loves Docker Containers Before They Understand Docker Containers - A...
 
Serverless Single Page Apps with React and Redux at ItCamp 2017
Serverless Single Page Apps with React and Redux at ItCamp 2017Serverless Single Page Apps with React and Redux at ItCamp 2017
Serverless Single Page Apps with React and Redux at ItCamp 2017
 
Windows 10 Creators Update: what’s on tap for business users - Ionut Balan
Windows 10 Creators Update: what’s on tap for business users - Ionut BalanWindows 10 Creators Update: what’s on tap for business users - Ionut Balan
Windows 10 Creators Update: what’s on tap for business users - Ionut Balan
 
Migrating to Continuous Delivery with TFS 2017 - Liviu Mandras-Iura
 Migrating to Continuous Delivery with TFS 2017 - Liviu Mandras-Iura Migrating to Continuous Delivery with TFS 2017 - Liviu Mandras-Iura
Migrating to Continuous Delivery with TFS 2017 - Liviu Mandras-Iura
 
#NoAgile - Dan Suciu
 #NoAgile - Dan Suciu #NoAgile - Dan Suciu
#NoAgile - Dan Suciu
 
Modern cybersecurity threats, and shiny new tools to help deal with them - T...
 Modern cybersecurity threats, and shiny new tools to help deal with them - T... Modern cybersecurity threats, and shiny new tools to help deal with them - T...
Modern cybersecurity threats, and shiny new tools to help deal with them - T...
 
Testing your PowerShell code with Pester - Florin Loghiade
Testing your PowerShell code with Pester - Florin LoghiadeTesting your PowerShell code with Pester - Florin Loghiade
Testing your PowerShell code with Pester - Florin Loghiade
 
The Fine Art of Time Travelling - Implementing Event Sourcing - Andrea Saltar...
The Fine Art of Time Travelling - Implementing Event Sourcing - Andrea Saltar...The Fine Art of Time Travelling - Implementing Event Sourcing - Andrea Saltar...
The Fine Art of Time Travelling - Implementing Event Sourcing - Andrea Saltar...
 
Scaling face recognition with big data - Bogdan Bocse
 Scaling face recognition with big data - Bogdan Bocse Scaling face recognition with big data - Bogdan Bocse
Scaling face recognition with big data - Bogdan Bocse
 
The Vision of Computer Vision: The bold promise of teaching computers to unde...
The Vision of Computer Vision: The bold promise of teaching computers to unde...The Vision of Computer Vision: The bold promise of teaching computers to unde...
The Vision of Computer Vision: The bold promise of teaching computers to unde...
 
Building and Managing your Virtual Datacenter using PowerShell DSC - Florin L...
Building and Managing your Virtual Datacenter using PowerShell DSC - Florin L...Building and Managing your Virtual Datacenter using PowerShell DSC - Florin L...
Building and Managing your Virtual Datacenter using PowerShell DSC - Florin L...
 
BUILD with Microsoft - Radu Stefan
 BUILD with Microsoft - Radu Stefan BUILD with Microsoft - Radu Stefan
BUILD with Microsoft - Radu Stefan
 
Developing PowerShell Tools - Razvan Rusu
Developing PowerShell Tools - Razvan RusuDeveloping PowerShell Tools - Razvan Rusu
Developing PowerShell Tools - Razvan Rusu
 
What's New in Hyper-V 2016 - Thomas Maurer
What's New in Hyper-V 2016 - Thomas MaurerWhat's New in Hyper-V 2016 - Thomas Maurer
What's New in Hyper-V 2016 - Thomas Maurer
 
Nano Server - the future of Windows Server - Thomas Maurer
Nano Server - the future of Windows Server - Thomas MaurerNano Server - the future of Windows Server - Thomas Maurer
Nano Server - the future of Windows Server - Thomas Maurer
 

Destacado

Destacado (20)

QCONSF - ACID Is So Yesterday: Maintaining Data Consistency with Sagas
QCONSF - ACID Is So Yesterday: Maintaining Data Consistency with SagasQCONSF - ACID Is So Yesterday: Maintaining Data Consistency with Sagas
QCONSF - ACID Is So Yesterday: Maintaining Data Consistency with Sagas
 
Windows Containers and Docker: Why You Should Care
Windows Containers and Docker: Why You Should CareWindows Containers and Docker: Why You Should Care
Windows Containers and Docker: Why You Should Care
 
A Pattern Language for Microservices
A Pattern Language for MicroservicesA Pattern Language for Microservices
A Pattern Language for Microservices
 
.Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20...
.Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20....Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20...
.Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20...
 
Decouvrir son sujet grace à l'event storming
Decouvrir son sujet grace à l'event stormingDecouvrir son sujet grace à l'event storming
Decouvrir son sujet grace à l'event storming
 
Sortir de notre zone de confort
Sortir de notre zone de confortSortir de notre zone de confort
Sortir de notre zone de confort
 
Async await...oh wait!
Async await...oh wait!Async await...oh wait!
Async await...oh wait!
 
Ddd reboot (english version)
Ddd reboot (english version)Ddd reboot (english version)
Ddd reboot (english version)
 
Faible latence haut debit Devoxx FR 2014
Faible latence haut debit Devoxx FR 2014Faible latence haut debit Devoxx FR 2014
Faible latence haut debit Devoxx FR 2014
 
Faible latence, haut debit PerfUG (Septembre 2014)
Faible latence, haut debit PerfUG (Septembre 2014)Faible latence, haut debit PerfUG (Septembre 2014)
Faible latence, haut debit PerfUG (Septembre 2014)
 
Decouvrir CQRS (sans Event sourcing) par la pratique
Decouvrir CQRS (sans Event sourcing) par la pratiqueDecouvrir CQRS (sans Event sourcing) par la pratique
Decouvrir CQRS (sans Event sourcing) par la pratique
 
TDD is dead?!? Let's do an autospy (ncrafts.io)
TDD is dead?!? Let's do an autospy (ncrafts.io)TDD is dead?!? Let's do an autospy (ncrafts.io)
TDD is dead?!? Let's do an autospy (ncrafts.io)
 
.NET Inside - Microservices, .NET Core e Serverless
.NET Inside - Microservices, .NET Core e Serverless.NET Inside - Microservices, .NET Core e Serverless
.NET Inside - Microservices, .NET Core e Serverless
 
Docker and Windows: The State of the Union
Docker and Windows: The State of the UnionDocker and Windows: The State of the Union
Docker and Windows: The State of the Union
 
Coder sans peur du changement avec la meme pas mal hexagonal architecture
Coder sans peur du changement avec la meme pas mal hexagonal architectureCoder sans peur du changement avec la meme pas mal hexagonal architecture
Coder sans peur du changement avec la meme pas mal hexagonal architecture
 
The Velvet Revolution: Modernizing Traditional ASP.NET Apps with Docker
The Velvet Revolution: Modernizing Traditional ASP.NET Apps with DockerThe Velvet Revolution: Modernizing Traditional ASP.NET Apps with Docker
The Velvet Revolution: Modernizing Traditional ASP.NET Apps with Docker
 
Culture craft humantalks
Culture craft humantalksCulture craft humantalks
Culture craft humantalks
 
CQRS without event sourcing
CQRS without event sourcingCQRS without event sourcing
CQRS without event sourcing
 
Solving distributed data management problems in a microservice architecture (...
Solving distributed data management problems in a microservice architecture (...Solving distributed data management problems in a microservice architecture (...
Solving distributed data management problems in a microservice architecture (...
 
Building and deploying microservices with event sourcing, CQRS and Docker (Be...
Building and deploying microservices with event sourcing, CQRS and Docker (Be...Building and deploying microservices with event sourcing, CQRS and Docker (Be...
Building and deploying microservices with event sourcing, CQRS and Docker (Be...
 

Similar a Azure tales: a real world CQRS and ES Deep Dive - Andrea Saltarello

ITCamp 2011 - Mihai Nadas - Windows Azure interop
ITCamp 2011 - Mihai Nadas - Windows Azure interopITCamp 2011 - Mihai Nadas - Windows Azure interop
ITCamp 2011 - Mihai Nadas - Windows Azure interop
ITCamp
 

Similar a Azure tales: a real world CQRS and ES Deep Dive - Andrea Saltarello (20)

Azure Microservices in Practice, Radu Vunvulea, ITCamp 2016
Azure Microservices in Practice, Radu Vunvulea, ITCamp 2016Azure Microservices in Practice, Radu Vunvulea, ITCamp 2016
Azure Microservices in Practice, Radu Vunvulea, ITCamp 2016
 
Azure Microservices in Practice - Radu Vunvulea
Azure Microservices in Practice - Radu VunvuleaAzure Microservices in Practice - Radu Vunvulea
Azure Microservices in Practice - Radu Vunvulea
 
Azure SQL Database From A Developer's Perspective - Alex Mang
Azure SQL Database From A Developer's Perspective - Alex MangAzure SQL Database From A Developer's Perspective - Alex Mang
Azure SQL Database From A Developer's Perspective - Alex Mang
 
One Azure Monitor to Rule Them All? - Marius Zaharia
One Azure Monitor to Rule Them All? - Marius ZahariaOne Azure Monitor to Rule Them All? - Marius Zaharia
One Azure Monitor to Rule Them All? - Marius Zaharia
 
One Azure Monitor to Rule Them All? (IT Camp 2017, Cluj, RO)
One Azure Monitor to Rule Them All? (IT Camp 2017, Cluj, RO)One Azure Monitor to Rule Them All? (IT Camp 2017, Cluj, RO)
One Azure Monitor to Rule Them All? (IT Camp 2017, Cluj, RO)
 
ITCamp 2019 - Andrea Saltarello - Implementing bots and Alexa skills using Az...
ITCamp 2019 - Andrea Saltarello - Implementing bots and Alexa skills using Az...ITCamp 2019 - Andrea Saltarello - Implementing bots and Alexa skills using Az...
ITCamp 2019 - Andrea Saltarello - Implementing bots and Alexa skills using Az...
 
ITCamp 2019 - Emil Craciun - RoboRestaurant of the future powered by serverle...
ITCamp 2019 - Emil Craciun - RoboRestaurant of the future powered by serverle...ITCamp 2019 - Emil Craciun - RoboRestaurant of the future powered by serverle...
ITCamp 2019 - Emil Craciun - RoboRestaurant of the future powered by serverle...
 
ITCamp 2019 - Mihai Tataran - Governing your Cloud Resources
ITCamp 2019 - Mihai Tataran - Governing your Cloud ResourcesITCamp 2019 - Mihai Tataran - Governing your Cloud Resources
ITCamp 2019 - Mihai Tataran - Governing your Cloud Resources
 
ITCamp 2019 - Andrea Saltarello - Modernise your app. The Cloud Story
ITCamp 2019 - Andrea Saltarello - Modernise your app. The Cloud StoryITCamp 2019 - Andrea Saltarello - Modernise your app. The Cloud Story
ITCamp 2019 - Andrea Saltarello - Modernise your app. The Cloud Story
 
ITCamp 2018 - Damian Widera U-SQL in great depth
ITCamp 2018 - Damian Widera U-SQL in great depthITCamp 2018 - Damian Widera U-SQL in great depth
ITCamp 2018 - Damian Widera U-SQL in great depth
 
Xamarin - Under the bridge
Xamarin - Under the bridgeXamarin - Under the bridge
Xamarin - Under the bridge
 
ITCamp 2018 - Florin Loghiade - Containers in Azure - An Infrastructure persp...
ITCamp 2018 - Florin Loghiade - Containers in Azure - An Infrastructure persp...ITCamp 2018 - Florin Loghiade - Containers in Azure - An Infrastructure persp...
ITCamp 2018 - Florin Loghiade - Containers in Azure - An Infrastructure persp...
 
The fight for surviving in the IoT world
The fight for surviving in the IoT worldThe fight for surviving in the IoT world
The fight for surviving in the IoT world
 
Building an Observability Platform in 389 Difficult Steps
Building an Observability Platform in 389 Difficult StepsBuilding an Observability Platform in 389 Difficult Steps
Building an Observability Platform in 389 Difficult Steps
 
ITCamp 2011 - Mihai Nadas - Windows Azure interop
ITCamp 2011 - Mihai Nadas - Windows Azure interopITCamp 2011 - Mihai Nadas - Windows Azure interop
ITCamp 2011 - Mihai Nadas - Windows Azure interop
 
Where should I run my code? Serverless, Containers, Virtual Machines and more
Where should I run my code? Serverless, Containers, Virtual Machines and moreWhere should I run my code? Serverless, Containers, Virtual Machines and more
Where should I run my code? Serverless, Containers, Virtual Machines and more
 
Signal R 2015
Signal R 2015Signal R 2015
Signal R 2015
 
Genomic Computation at Scale with Serverless, StackStorm and Docker Swarm
Genomic Computation at Scale with Serverless, StackStorm and Docker SwarmGenomic Computation at Scale with Serverless, StackStorm and Docker Swarm
Genomic Computation at Scale with Serverless, StackStorm and Docker Swarm
 
Spring and Pivotal Application Service - SpringOne Tour - Boston
Spring and Pivotal Application Service - SpringOne Tour - BostonSpring and Pivotal Application Service - SpringOne Tour - Boston
Spring and Pivotal Application Service - SpringOne Tour - Boston
 
Cisco project ideas
Cisco   project ideasCisco   project ideas
Cisco project ideas
 

Más de ITCamp

ITCamp 2019 - Ivana Milicic - Color - The Shadow Ruler of UX
ITCamp 2019 - Ivana Milicic - Color - The Shadow Ruler of UXITCamp 2019 - Ivana Milicic - Color - The Shadow Ruler of UX
ITCamp 2019 - Ivana Milicic - Color - The Shadow Ruler of UX
ITCamp
 

Más de ITCamp (20)

ITCamp 2019 - Stacey M. Jenkins - Protecting your company's data - By psychol...
ITCamp 2019 - Stacey M. Jenkins - Protecting your company's data - By psychol...ITCamp 2019 - Stacey M. Jenkins - Protecting your company's data - By psychol...
ITCamp 2019 - Stacey M. Jenkins - Protecting your company's data - By psychol...
 
ITCamp 2019 - Silviu Niculita - Supercharge your AI efforts with the use of A...
ITCamp 2019 - Silviu Niculita - Supercharge your AI efforts with the use of A...ITCamp 2019 - Silviu Niculita - Supercharge your AI efforts with the use of A...
ITCamp 2019 - Silviu Niculita - Supercharge your AI efforts with the use of A...
 
ITCamp 2019 - Peter Leeson - Managing Skills
ITCamp 2019 - Peter Leeson - Managing SkillsITCamp 2019 - Peter Leeson - Managing Skills
ITCamp 2019 - Peter Leeson - Managing Skills
 
ITCamp 2019 - Ivana Milicic - Color - The Shadow Ruler of UX
ITCamp 2019 - Ivana Milicic - Color - The Shadow Ruler of UXITCamp 2019 - Ivana Milicic - Color - The Shadow Ruler of UX
ITCamp 2019 - Ivana Milicic - Color - The Shadow Ruler of UX
 
ITCamp 2019 - Florin Coros - Implementing Clean Architecture
ITCamp 2019 - Florin Coros - Implementing Clean ArchitectureITCamp 2019 - Florin Coros - Implementing Clean Architecture
ITCamp 2019 - Florin Coros - Implementing Clean Architecture
 
ITCamp 2019 - Florin Loghiade - Azure Kubernetes in Production - Field notes...
ITCamp 2019 - Florin Loghiade -  Azure Kubernetes in Production - Field notes...ITCamp 2019 - Florin Loghiade -  Azure Kubernetes in Production - Field notes...
ITCamp 2019 - Florin Loghiade - Azure Kubernetes in Production - Field notes...
 
ITCamp 2019 - Florin Flestea - How 3rd Level support experience influenced m...
ITCamp 2019 - Florin Flestea -  How 3rd Level support experience influenced m...ITCamp 2019 - Florin Flestea -  How 3rd Level support experience influenced m...
ITCamp 2019 - Florin Flestea - How 3rd Level support experience influenced m...
 
ITCamp 2019 - Eldert Grootenboer - Cloud Architecture Recipes for The Enterprise
ITCamp 2019 - Eldert Grootenboer - Cloud Architecture Recipes for The EnterpriseITCamp 2019 - Eldert Grootenboer - Cloud Architecture Recipes for The Enterprise
ITCamp 2019 - Eldert Grootenboer - Cloud Architecture Recipes for The Enterprise
 
ITCamp 2019 - Cristiana Fernbach - Blockchain Legal Trends
ITCamp 2019 - Cristiana Fernbach - Blockchain Legal TrendsITCamp 2019 - Cristiana Fernbach - Blockchain Legal Trends
ITCamp 2019 - Cristiana Fernbach - Blockchain Legal Trends
 
ITCamp 2019 - Andy Cross - Machine Learning with ML.NET and Azure Data Lake
ITCamp 2019 - Andy Cross - Machine Learning with ML.NET and Azure Data LakeITCamp 2019 - Andy Cross - Machine Learning with ML.NET and Azure Data Lake
ITCamp 2019 - Andy Cross - Machine Learning with ML.NET and Azure Data Lake
 
ITCamp 2019 - Andy Cross - Business Outcomes from AI
ITCamp 2019 - Andy Cross - Business Outcomes from AIITCamp 2019 - Andy Cross - Business Outcomes from AI
ITCamp 2019 - Andy Cross - Business Outcomes from AI
 
ITCamp 2019 - Alex Mang - I'm Confused Should I Orchestrate my Containers on ...
ITCamp 2019 - Alex Mang - I'm Confused Should I Orchestrate my Containers on ...ITCamp 2019 - Alex Mang - I'm Confused Should I Orchestrate my Containers on ...
ITCamp 2019 - Alex Mang - I'm Confused Should I Orchestrate my Containers on ...
 
ITCamp 2019 - Alex Mang - How Far Can Serverless Actually Go Now
ITCamp 2019 - Alex Mang - How Far Can Serverless Actually Go NowITCamp 2019 - Alex Mang - How Far Can Serverless Actually Go Now
ITCamp 2019 - Alex Mang - How Far Can Serverless Actually Go Now
 
ITCamp 2019 - Peter Leeson - Vitruvian Quality
ITCamp 2019 - Peter Leeson - Vitruvian QualityITCamp 2019 - Peter Leeson - Vitruvian Quality
ITCamp 2019 - Peter Leeson - Vitruvian Quality
 
ITCamp 2018 - Ciprian Sorlea - Million Dollars Hello World Application
ITCamp 2018 - Ciprian Sorlea - Million Dollars Hello World ApplicationITCamp 2018 - Ciprian Sorlea - Million Dollars Hello World Application
ITCamp 2018 - Ciprian Sorlea - Million Dollars Hello World Application
 
ITCamp 2018 - Ciprian Sorlea - Enterprise Architectures with TypeScript And F...
ITCamp 2018 - Ciprian Sorlea - Enterprise Architectures with TypeScript And F...ITCamp 2018 - Ciprian Sorlea - Enterprise Architectures with TypeScript And F...
ITCamp 2018 - Ciprian Sorlea - Enterprise Architectures with TypeScript And F...
 
ITCamp 2018 - Mete Atamel Ian Talarico - Google Home meets .NET containers on...
ITCamp 2018 - Mete Atamel Ian Talarico - Google Home meets .NET containers on...ITCamp 2018 - Mete Atamel Ian Talarico - Google Home meets .NET containers on...
ITCamp 2018 - Mete Atamel Ian Talarico - Google Home meets .NET containers on...
 
ITCamp 2018 - Magnus Mårtensson - Azure Global Application Perspectives
ITCamp 2018 - Magnus Mårtensson - Azure Global Application PerspectivesITCamp 2018 - Magnus Mårtensson - Azure Global Application Perspectives
ITCamp 2018 - Magnus Mårtensson - Azure Global Application Perspectives
 
ITCamp 2018 - Magnus Mårtensson - Azure Resource Manager For The Win
ITCamp 2018 - Magnus Mårtensson - Azure Resource Manager For The WinITCamp 2018 - Magnus Mårtensson - Azure Resource Manager For The Win
ITCamp 2018 - Magnus Mårtensson - Azure Resource Manager For The Win
 
ITCamp 2018 - Ionut Balan - A beginner’s guide to Windows Mixed Reality
ITCamp 2018 - Ionut Balan - A beginner’s guide to Windows Mixed RealityITCamp 2018 - Ionut Balan - A beginner’s guide to Windows Mixed Reality
ITCamp 2018 - Ionut Balan - A beginner’s guide to Windows Mixed Reality
 

Último

Último (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 

Azure tales: a real world CQRS and ES Deep Dive - Andrea Saltarello

  • 1. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals Azure tales: a real world CQRS and ES Deep Dive Andrea Saltarello Solution Architect @ Managed Designs https://twitter.com/andysal74 https://github.com/andysal
  • 2. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals Many thanks to our sponsors & partners! GOLD SILVER PARTNERS PLATINUM POWERED BY
  • 3. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals Andrea Saltarello • Solution Architect @ Managed Designs • Microsoft .NET MVP since 2003 • Microsoft Regional Director • Author, along with Dino, of .NET: Architecting Applications for the Enterprise, di Microsoft Press • Basically, a software architect eager to write code ☺
  • 4. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals • CQRS/Event Sourcing recap • CQRS/ES @ Azure: deployment blueprints • Technology & economic considerations Agenda
  • 5. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals CQRS/ES RECAP
  • 7. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals Not the way to implement Event Sourcing, but a working way to do it nonetheless Demo app available on Github (GPL3): it is a real open source project of which my company sells customizations There’s no silver bullet
  • 8. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals A few fancy dressed blokes going for a jaunt The (Relational) Lord of the Rings
  • 10. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals It really became clear to me in the last couple of years that we need a new building block and that is the Domain Event. [Eric Evans] An event is something that has happened in the past. [Greg Young] A domain event … captures the memory of something interesting which affects the domain [Martin Fowler]
  • 11. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals Instead of focusing on a system’s last known state, we might note down every occurring event: this way, we would be able to (re)build the state the system was in at any point in time just replaying those events To cut a long story short: we’d end up recording an event stream Event Sourcing in a nutshell JobOrderStarted InvoiceIssuedJobOrderExtended JobOrderCompleted
  • 12. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals The (immutable) composition of: • A (meaningful) name • (Typed) Attributes What’s an event, anyway? InvoiceIssued DateOfIssue Customer Price ProjectStarted DateOfStart ProjectId ProjectCompleted DateOfCompletion ProjectId ProjectRegistered DateOfRegistration DateOfEstimatedCompletion ProjectId CustomerId Price
  • 13. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals DEMO Event Stream
  • 14. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals Still, my users are more interested in knowing a job order’s balance or whether an invoice has been paid. (cit.) That is, we need a way to produce an entity state Event Stream vs. «My application»
  • 15. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals DDD’s Aggregates provide a convenient way to encapsulate event management Aggregate: A collection of objects that are bound together by a root entity, otherwise known as an aggregate root. The aggregate root guarantees the consistency of changes being made within the aggregate. [Wikipedia] An aggregate is responsible for: • encapsulating business logic pertaining to an “entity” • generating events to have them available for saving • replaying events in order to rebuild a specific state Event Sourcing <3 DDD
  • 16. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals DEMO Aggregates
  • 17. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals var aggr = repository.GetById<TAggr>(id); //Triggers [time travelling] event replay aggr.DoSomething(); //Biz logic + events repository.Save(aggr); //Updates the event stream Repository: Mediates between the domain and data mapping layers using a collection-like interface for accessing domain objects. [DDD] Aggregates vs. Events vs. Repos
  • 18. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals DEMO Time Travelling
  • 19. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals Still², my users are more interested in knowing a job order’s balance or whether an invoice has been paid. Quickly. Ways to achieve that: • Snapshots can help • CQRS to the rescue: let’s have a database storing the usual «last known system state» and use it as a read model Event Stream vs. «My application»
  • 20. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals Acronym for Command Query Responsibility Segregation Basically, ad hoc application stacks for either “writing” or reading: • “Command” stack writes events and snapshots • “Read” stack reads from eventually consistent, reading purposes optimized database(s) Enter CQRS
  • 21. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals DEMO Read Model
  • 22. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals 1. Application sends a command to the system 2. Command execution might alter the system’s state and then raise events to state success/failure 3. Events are notified to interested subscribers (a.k.a. handlers), such as: • Workflow managers (a.k.a. «Sagas») which could execute more commands • Denormalizers, which will update the read model database Note: command/event dispatch/execution will usually be managed by a Mediator («bus») CQRS/ES in a nutshell
  • 23. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals Application Layer Snapshots Event store Read stack Domain Layer Ad-hoc DBHandlers Command Event Data Handlers Model ServicesB U S CQRS/ES at a glance
  • 24. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals DEMO Handlers
  • 25. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals BLUEPRINTS
  • 26. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals Azure <3 CQRS: n-tiered Back-endFront-end Application Layer Snapshots Event store Read stack Domain Layer Ad-hoc DBHandlers Command Event Data Handlers Model Services A S B
  • 27. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals Front end: • VM • Web role • App Service • Docker Back end: • Worker role • Service Fabric • Docker N-tiered deploy
  • 28. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals Azure <3 CQRS: full stack App Service Application Layer Snapshots Event store Read stack Domain Layer Ad-hoc DBHandlers Command Event Data Handlers Model Services A S B
  • 29. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals • VM • Web role • App Service • Docker • Service Fabric Full stack deploy
  • 30. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals A fine-grained deploy allows each “component” to be: • Evolved • Deployed • Configured (e.g.: scaled) Independently, thus having each one only consuming the resources it really needs but it means having more moving parts to manage N-tiered vs. Full stack
  • 31. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals TECHNOLOGY & ECONOMIC CONSIDERATIONS
  • 32. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals App Service Cloud Services Docker Service Fabric VM PROs: • PaaS PROs: • PaaS PROs • Deploy • Scaling* • Documentation/samples PROs: • Fault tolerance • Load balancing • Deploy PROs • (Usually) cheapest monthly bill • No new skiils needed • Unparalled option set CONs: • .NET 4.5.1 only(*) CONs: (?) • Need for an orchestrator CONs: • Ad-hoc SDK CONs: • Management Azure Compute smackdown
  • 33. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals A 2 cores, 3.5 GB RAM, 60 GB disk compute unit costs: • 75,92 EUR/month as a VM • 94,11 EUR/month as an AppService • 100,39 EUR/month as a Cloud Service (*) • 338,80** - 564,47*** EUR/month as a Service Fabric cluster * 490Gb disk **3 nodes ***5 nodes From a billing perspective
  • 34. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals An effective CQRS/ES implementation usually relies on 2 structural pillars: • A mediator bus • An event store Well come on and let me know… Should I stay build or should I go (shopping)? (demi quote) On a technology side…
  • 35. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals Rebus.net: • is an open source, production tested bus for .NET. Source code is available on Github, but usually Nuget packages will do. • provides much-needed features such as: – Fault tolerance – Scalability – Events’ scheduling – Easy migration from on-premises to cloud • requires: – a transport protocol (e.g.: MSMQ, RabbitMQ, Azure Service Bus, Amazon Sqs, ...) – an IoC container (e.g.: Autofac, Ninject, .NET Core ServiceProvider, StructureMap, Unity, Windsor...) – a storage (e.g.: MongoDB, RavenDb, SQL Server, ...) Enter Rebus.net
  • 36. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals DEMO Configuration Back to the Future
  • 37. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals MementoFX NEventStore https://www.nuget.org/packages?q=MementoFx • FOSS • DDD/ES stack • Time travelling • Alternative timelines https://www.nuget.org/packages?q=NEventStore • FOSS • Event Store API only • “CommonDomain” package available to support DDD • Wide community + Slack channel CQRS Application Frameworks
  • 38. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals CosmosDB mLab VM PROS: • Multiple APIs (e.g.: DocumentDB, MongoDB) • PaaS • Scalability/Georedundancy PROS: • PaaS • Large ecosystem PROS: • Unparalleled configuration options CONS: • Billing CONS: • Few instance sizes CONS: • Management Event Store: a couple of options
  • 39. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals • A CosmosDB database is billed on a per-collection basis, with a 1 GB, 400 RU/sec collection costing 20.08 EUR/month • A 3 “A2” VM MongoDB Linux cluster costs 146,82 EUR/month (but we’d have to manage it) • mLab’s dedicated cluster options: From a Billing perspective Size RAM Disk Monthly price M1 1.7 GB 40 GB $200 M2 3.5 GB 60 GB $400 M3 7 GB 120 GB $800 M4 14 GB 240 GB $1,320 M5 28 GB 480 GB $2,450 M6 56 GB 700 GB $4,280
  • 40. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals THANK YOU!
  • 41. @ITCAMPRO #ITCAMP17Community Conference for IT Professionals Q & A