SlideShare une entreprise Scribd logo
1  sur  45
“Hitchhiker” systems
A deeper look
Duncan Jones
💬 @Merrion
Agenda
• Sources of cost
• Introduction to “event sourcing”
• Example code
• Introduction to Azure Event Grid
• Overview of an example system architecture
• Example code
• Lessons learned
• Q & A
Caveats
Sources of cost
Fixed costs Overprovisioning
Introduction to “event sourcing”
Opened
Account
Deposited
Money
Withdrew Money Closed Account
$10.00 $10.00Margaret
00002
Event Type Action
Opened
Account
Skip
Deposited
Money
Increase balance by $
Withdrew
Money
Decrease balance by $
Event sourcing on Azure functions
code example
Open a new account
Each account number must be unique
Initial deposit amount (optional)
Beneficiary name (optional)
Open a new account
https://retailbankazurefunctionapp.azurewebsites.net/api/OpenAccount/A001B123
456C
DOMAIN ENTITY TYPE INSTANCE
Open a new account
Open a new account
Open a new account
Open a new account
Open a new account
Make a deposit
Target account for the deposit must exist
Deposit amount
Source of the deposit (optional)
Make a deposit
Make a deposit
Get the balance
The account number to get the balance from must exist
As of date (optional)
Get the balance
TYPE OF PROJECTION TO RUN
Balance projection
Get the balance
SEQUENCE NUMBER OF LAST EVENT PROCESSED
Get the balance
Make a withdrawal
Target account number for the withdrawal must exist
Balance must be greater than or equal to the withdrawal amount
Withdrawal amount
Concurrency crocodile!
Make a withdrawal
Make a withdrawal
Make a withdrawal
Introduction to Event Grid
Always on
At-least once delivery
Overview of an example system architecture
League Race
Runner
Query
Query
Query
Command
Command
Command
Handling a command
Handling a command
Durable Function Orchestration
Handling a command
Durable Function Orchestration
Command
Validations
Handling a command
Durable Function Orchestration
Append
Event(s)
Command orchestrator
Trigger
Orchestration
Validate
Parameters
Append
Event
Send
Notifications
Command orchestrator
Trigger
Orchestration
Validate
Parameters
Append
Event
Send
Notifications
Command orchestrator
Trigger
Orchestration
Validate
Parameters
Append
Event
Send
Notifications
Command orchestrator
Trigger
Orchestration
Validate
Parameters
Append
Event
Send
Notifications
Handling a query
Handling a query
Durable Function Orchestration
Run
Projection(s)
Handling a query
Durable Function Orchestration
Return
Results
Query orchestrator
Trigger
Orchestration
Validate
Parameters
Request
Projections
Run
Projections
Send Results
Query orchestrator
Trigger
Orchestration
Validate
Parameters
Request
Projections
Run
Projections
Send Results
Notifications and inter-domain
communication
Lessons learned
Don’t assume. Measure!
Invest time in design
Read your writes
Questions?
@Merrion
Costs
<
Azure functions
Blob storage
Event Grid
<£1 / day
Code and architecture recap
Event Grid function triggers
Query orchestration Command orchestration
Event streams and projections
Fan-out
https://github.com/MerrionComputing/AzureFunctions-TheLongRun-Leagues
https://github.com/MerrionComputing/EventsSourcing-on-Azure-Functions
Event sourcing with Azure functions

Contenu connexe

Similaire à Hitchhiker systems deepdive

LITE 2016 – Using the Financial Reporting Feature [Nate Smith & Adam Medley]
LITE 2016 – Using the Financial Reporting Feature [Nate Smith & Adam Medley]LITE 2016 – Using the Financial Reporting Feature [Nate Smith & Adam Medley]
LITE 2016 – Using the Financial Reporting Feature [Nate Smith & Adam Medley]getadministrate
 
Reactive Microservices with AWS Lambda (SRV201-R1) - AWS re:Invent 2018
Reactive Microservices with AWS Lambda (SRV201-R1) - AWS re:Invent 2018Reactive Microservices with AWS Lambda (SRV201-R1) - AWS re:Invent 2018
Reactive Microservices with AWS Lambda (SRV201-R1) - AWS re:Invent 2018Amazon Web Services
 
Learn Adobe analytics basics - Conversion variables
Learn Adobe analytics basics - Conversion variablesLearn Adobe analytics basics - Conversion variables
Learn Adobe analytics basics - Conversion variablesArunkumar Sundaram
 
LevelsConf 2018 Event Sourcing - Dasith Wijesiriwardena
LevelsConf 2018 Event Sourcing - Dasith WijesiriwardenaLevelsConf 2018 Event Sourcing - Dasith Wijesiriwardena
LevelsConf 2018 Event Sourcing - Dasith WijesiriwardenaDasith Wijesiriwardena
 
JCon 2017: Let your microservices flow
JCon 2017: Let your microservices flowJCon 2017: Let your microservices flow
JCon 2017: Let your microservices flowBernd Ruecker
 
AWS ReInvent 2020: SEC313 - A security operator’s guide to practical AWS Clou...
AWS ReInvent 2020: SEC313 - A security operator’s guide to practical AWS Clou...AWS ReInvent 2020: SEC313 - A security operator’s guide to practical AWS Clou...
AWS ReInvent 2020: SEC313 - A security operator’s guide to practical AWS Clou...Brian Andrzejewski
 
Developing functional domain models with event sourcing (oakjug, sfscala)
Developing functional domain models with event sourcing (oakjug, sfscala)Developing functional domain models with event sourcing (oakjug, sfscala)
Developing functional domain models with event sourcing (oakjug, sfscala)Chris Richardson
 
Introduction to Domain driven design (LaravelBA #5)
Introduction to Domain driven design (LaravelBA #5)Introduction to Domain driven design (LaravelBA #5)
Introduction to Domain driven design (LaravelBA #5)guiwoda
 
Oracle grants accounting 11
Oracle grants accounting 11Oracle grants accounting 11
Oracle grants accounting 11Naveen Reddy
 
Oracle grants accounting 11
Oracle grants accounting 11Oracle grants accounting 11
Oracle grants accounting 11Naveen Reddy
 
Improving application design with a rich domain model (springone 2007)
Improving application design with a rich domain model (springone 2007)Improving application design with a rich domain model (springone 2007)
Improving application design with a rich domain model (springone 2007)Chris Richardson
 
HTML5 Gaming Payment Platforms
HTML5 Gaming Payment PlatformsHTML5 Gaming Payment Platforms
HTML5 Gaming Payment PlatformsJonathan LeBlanc
 
2012 SVCodeCamp: In App Payments with HTML5
2012 SVCodeCamp: In App Payments with HTML52012 SVCodeCamp: In App Payments with HTML5
2012 SVCodeCamp: In App Payments with HTML5Jonathan LeBlanc
 
PayPal Dev Con 2009 Driving Business
PayPal Dev Con 2009 Driving BusinessPayPal Dev Con 2009 Driving Business
PayPal Dev Con 2009 Driving BusinessAduci
 
Dominant assurance contracts using Ethereum
Dominant assurance contracts using EthereumDominant assurance contracts using Ethereum
Dominant assurance contracts using Ethereumaatkin1971
 
Testing In App Billing
Testing In App BillingTesting In App Billing
Testing In App BillingRyan Harter
 
Introduction to Event Sourcing,CQRS and Axon
Introduction to Event Sourcing,CQRS and AxonIntroduction to Event Sourcing,CQRS and Axon
Introduction to Event Sourcing,CQRS and AxonPetar Zrinščak
 
Building and deploying microservices with event sourcing, CQRS and Docker (QC...
Building and deploying microservices with event sourcing, CQRS and Docker (QC...Building and deploying microservices with event sourcing, CQRS and Docker (QC...
Building and deploying microservices with event sourcing, CQRS and Docker (QC...Chris Richardson
 

Similaire à Hitchhiker systems deepdive (20)

LITE 2016 – Using the Financial Reporting Feature [Nate Smith & Adam Medley]
LITE 2016 – Using the Financial Reporting Feature [Nate Smith & Adam Medley]LITE 2016 – Using the Financial Reporting Feature [Nate Smith & Adam Medley]
LITE 2016 – Using the Financial Reporting Feature [Nate Smith & Adam Medley]
 
Reactive Microservices with AWS Lambda (SRV201-R1) - AWS re:Invent 2018
Reactive Microservices with AWS Lambda (SRV201-R1) - AWS re:Invent 2018Reactive Microservices with AWS Lambda (SRV201-R1) - AWS re:Invent 2018
Reactive Microservices with AWS Lambda (SRV201-R1) - AWS re:Invent 2018
 
Learn Adobe analytics basics - Conversion variables
Learn Adobe analytics basics - Conversion variablesLearn Adobe analytics basics - Conversion variables
Learn Adobe analytics basics - Conversion variables
 
LevelsConf 2018 Event Sourcing - Dasith Wijesiriwardena
LevelsConf 2018 Event Sourcing - Dasith WijesiriwardenaLevelsConf 2018 Event Sourcing - Dasith Wijesiriwardena
LevelsConf 2018 Event Sourcing - Dasith Wijesiriwardena
 
JCon 2017: Let your microservices flow
JCon 2017: Let your microservices flowJCon 2017: Let your microservices flow
JCon 2017: Let your microservices flow
 
AWS ReInvent 2020: SEC313 - A security operator’s guide to practical AWS Clou...
AWS ReInvent 2020: SEC313 - A security operator’s guide to practical AWS Clou...AWS ReInvent 2020: SEC313 - A security operator’s guide to practical AWS Clou...
AWS ReInvent 2020: SEC313 - A security operator’s guide to practical AWS Clou...
 
Developing functional domain models with event sourcing (oakjug, sfscala)
Developing functional domain models with event sourcing (oakjug, sfscala)Developing functional domain models with event sourcing (oakjug, sfscala)
Developing functional domain models with event sourcing (oakjug, sfscala)
 
Introduction to Domain driven design (LaravelBA #5)
Introduction to Domain driven design (LaravelBA #5)Introduction to Domain driven design (LaravelBA #5)
Introduction to Domain driven design (LaravelBA #5)
 
Introduction to-ddd
Introduction to-dddIntroduction to-ddd
Introduction to-ddd
 
Oracle grants accounting 11
Oracle grants accounting 11Oracle grants accounting 11
Oracle grants accounting 11
 
Oracle grants accounting 11
Oracle grants accounting 11Oracle grants accounting 11
Oracle grants accounting 11
 
Improving application design with a rich domain model (springone 2007)
Improving application design with a rich domain model (springone 2007)Improving application design with a rich domain model (springone 2007)
Improving application design with a rich domain model (springone 2007)
 
CQRS and Event Sourcing
CQRS and Event SourcingCQRS and Event Sourcing
CQRS and Event Sourcing
 
HTML5 Gaming Payment Platforms
HTML5 Gaming Payment PlatformsHTML5 Gaming Payment Platforms
HTML5 Gaming Payment Platforms
 
2012 SVCodeCamp: In App Payments with HTML5
2012 SVCodeCamp: In App Payments with HTML52012 SVCodeCamp: In App Payments with HTML5
2012 SVCodeCamp: In App Payments with HTML5
 
PayPal Dev Con 2009 Driving Business
PayPal Dev Con 2009 Driving BusinessPayPal Dev Con 2009 Driving Business
PayPal Dev Con 2009 Driving Business
 
Dominant assurance contracts using Ethereum
Dominant assurance contracts using EthereumDominant assurance contracts using Ethereum
Dominant assurance contracts using Ethereum
 
Testing In App Billing
Testing In App BillingTesting In App Billing
Testing In App Billing
 
Introduction to Event Sourcing,CQRS and Axon
Introduction to Event Sourcing,CQRS and AxonIntroduction to Event Sourcing,CQRS and Axon
Introduction to Event Sourcing,CQRS and Axon
 
Building and deploying microservices with event sourcing, CQRS and Docker (QC...
Building and deploying microservices with event sourcing, CQRS and Docker (QC...Building and deploying microservices with event sourcing, CQRS and Docker (QC...
Building and deploying microservices with event sourcing, CQRS and Docker (QC...
 

Plus de Duncan Jones

Introduction to DDD
Introduction to DDDIntroduction to DDD
Introduction to DDDDuncan Jones
 
Introduction to Domain Driven Design
Introduction to Domain Driven DesignIntroduction to Domain Driven Design
Introduction to Domain Driven DesignDuncan Jones
 
Serverless cqrs using azure event grid
Serverless cqrs using azure event gridServerless cqrs using azure event grid
Serverless cqrs using azure event gridDuncan Jones
 
Event sourcing continued
Event sourcing continuedEvent sourcing continued
Event sourcing continuedDuncan Jones
 
Event sourcing - from wtf to why to wow
Event sourcing - from wtf to why to wowEvent sourcing - from wtf to why to wow
Event sourcing - from wtf to why to wowDuncan Jones
 
Event sourcing from wtf to why to wow
Event sourcing   from wtf to why to wowEvent sourcing   from wtf to why to wow
Event sourcing from wtf to why to wowDuncan Jones
 
Crud or event sourcing
Crud or event sourcingCrud or event sourcing
Crud or event sourcingDuncan Jones
 
cqrs and event sourcing on Windows Azure
cqrs and event sourcing on Windows Azurecqrs and event sourcing on Windows Azure
cqrs and event sourcing on Windows AzureDuncan Jones
 
event sourcing - from wtf to why to wow
event sourcing - from wtf to why to wowevent sourcing - from wtf to why to wow
event sourcing - from wtf to why to wowDuncan Jones
 
Printing-a-NET-developers-guide-Part1
Printing-a-NET-developers-guide-Part1Printing-a-NET-developers-guide-Part1
Printing-a-NET-developers-guide-Part1Duncan Jones
 
Cqrs and the cloud
Cqrs and the cloudCqrs and the cloud
Cqrs and the cloudDuncan Jones
 

Plus de Duncan Jones (16)

State o' yer WAN
State o' yer WANState o' yer WAN
State o' yer WAN
 
Boxcar computing
Boxcar computingBoxcar computing
Boxcar computing
 
Boxcar computing
Boxcar computingBoxcar computing
Boxcar computing
 
Introduction to DDD
Introduction to DDDIntroduction to DDD
Introduction to DDD
 
Introduction to Domain Driven Design
Introduction to Domain Driven DesignIntroduction to Domain Driven Design
Introduction to Domain Driven Design
 
Serverless cqrs using azure event grid
Serverless cqrs using azure event gridServerless cqrs using azure event grid
Serverless cqrs using azure event grid
 
Event sourcing continued
Event sourcing continuedEvent sourcing continued
Event sourcing continued
 
Event sourcing - from wtf to why to wow
Event sourcing - from wtf to why to wowEvent sourcing - from wtf to why to wow
Event sourcing - from wtf to why to wow
 
3 myths of it
3 myths of it3 myths of it
3 myths of it
 
Event sourcing from wtf to why to wow
Event sourcing   from wtf to why to wowEvent sourcing   from wtf to why to wow
Event sourcing from wtf to why to wow
 
Crud or event sourcing
Crud or event sourcingCrud or event sourcing
Crud or event sourcing
 
cqrs and event sourcing on Windows Azure
cqrs and event sourcing on Windows Azurecqrs and event sourcing on Windows Azure
cqrs and event sourcing on Windows Azure
 
event sourcing - from wtf to why to wow
event sourcing - from wtf to why to wowevent sourcing - from wtf to why to wow
event sourcing - from wtf to why to wow
 
CQRS on Azure
CQRS on AzureCQRS on Azure
CQRS on Azure
 
Printing-a-NET-developers-guide-Part1
Printing-a-NET-developers-guide-Part1Printing-a-NET-developers-guide-Part1
Printing-a-NET-developers-guide-Part1
 
Cqrs and the cloud
Cqrs and the cloudCqrs and the cloud
Cqrs and the cloud
 

Dernier

Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 

Dernier (20)

Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 

Hitchhiker systems deepdive

Notes de l'éditeur

  1. Good afternoon and thank you very much for lending me your time. My name is Duncan Jones and my twitter handle (probably the easiest way to contract me) is @Merrion My thesis is something I am calling “Hitchhiker” systems which is to say systems optimised towards lowering cost
  2. First I need to discuss where cost comes from, in the context of cloud computing. Then a very high level overview of event sourcing because the solution I have put together makes extensive use of this (and I will explain why at the same time). I will also show some code to illuminate how I am doing this Then the environment in which this is to be hosted – using the Azure Event Grid, Durable Serverless functions and Azure storage. Then I will walk through an example of the way the architecture hangs together Finally I’ll wrap up with lessons learned and Q&A – hopefully questions form you, probably questions from me and maybe even questions from the crocodile.
  3. The system I am describing here is best suited to non critical or occasional/burst use scenarios rather than enterprise critical systems and is tuned toward minimising cost rather than maximised performance. If you are having talks with venture capital firms or describing yourself as “the uber of blah” then this may not be ideally suited for you. Also, what I am describing is more of an experiment rather than a definitive textbook example. To manage expectations, what I am looking for is an equivalent to what Blogs did for micropublishing in applications.
  4. There are two main sources of cost that we need to address with regard to cloud hosted systems: The first is always-on systems, for example virtual machines, for which a cost arises regardless of use. The second is overprovisioning, where we have to reserve more processing power than we are using so that we are able to ramp-up to match rapidly increasing demand. Azure serverless functions address these two sources of cost “out of the box”
  5. Event sourcing is a way of storing data, not as the current state of the entity (as in active state) but rather as a sequential history of all the events that have occurred to an entity. This history is implemented as an append only event stream. It places the onus on getting “state” onto the system that is reading the data which has to run a projection over the event stream. This is done by (and is the responsibility of) the process that needs that state, either to report it or to use it in a business decision. This allows us to eliminate one of the “always on” fixed costs – the state consistency management system (or database to use the more common term).
  6. So let me show you what the code looks like in practice (Don’t worry – I’m not going to “live code” it. Even the people who pay me to code don’t actually enjoy watching it happen)
  7. We will start with opening a new account. The rules are :- An account can only be created once - therefore if an event stream already exists for the account, do not create a new one or append an account opened event.
  8. When the serverless function is triggered the account number is taken from the URL and is used to instantiate a new eventstream variable for that bank account. Each event stream is uniquely identified by a combination of the domain, entity type and unique identifier of that entity.
  9. 1) To enforce the constraint that an account must be new we can first check the event stream does not exist, but also we can pass in a constraint that when writing the first event the event stream must be new.
  10. In addition, the same function is able to append more than one event onto the event stream if that makes business sense Here I am adding a deposit event if the account is opened with an initial deposit and a beneficiary set event if the beneficiary name is provided to the open new account function
  11. The event stream created is stored in the Azure blob storage under a path made of Domain name -> Entity Type
  12. Each blob also has metadata set for the properties of the event stream
  13. The data for each event are in JSON and wrapped in the event context (Projections only access the data inside the event instance but the outer wrapper is useful for debugging etc)
  14. Next we need to make a deposit. Depositing money is the simplest of all operations - we simply need to be sure that the account exists.
  15. Making a deposit is the simplest function – we simply populate a money deposited event and append it to the event stream for the given bank account. We check the bank account exists first in case the user has incorrectly entered their account number
  16. The deposit event is appended to the stream. Importantly the state (current balance etc.) of the bank account is not stored in the event
  17. Getting the balance our of the event stream To get the balance of the account we need to run a projection over the bank account event stream which handles the money deposited event and the money withdrawn event to give the balance as at a given point.
  18. To run a projection we need to specify the domain, entity type and instance identity of the event stream we are going to run the projection over, and also we need to specify the class of the projection to run.
  19. The projection is a very simple piece of code that says what events it will handle (by implementing the IHandleEventType interface) and then has a method to be called each time an instance of that event type is encountered in the event stream. In this case a money deposited event increases the account balance and a money withdrawn event decreases it.
  20. The projection is run and when it has processed all the events in the event stream the value is returned. 1) Every projection also has a Current Sequence Number property that tells you the number of the last event in the stream that it read
  21. Resulting event stream
  22. Next making a withdrawal Withdrawing money requires running the balance projection to make sure that the account has the funds available to withdraw and only if it does, post the withdrawal event. We need to make sure no events have happened between us getting the balance and applying the withdrawal even as if they have we could have a concurrency error. When posting the withdrawal event we pass in the sequence number returned by the projection and if any other events have been written to the event stream since then an error is thrown and our withdrawal event is not appended.
  23. The withdrawal function has both an event stream parameter and a projection parameter, both pointing at the same event stream.
  24. By passing in the sequence number we got from the projection we can tell the AppendEvent method to throw an exception if the actual top sequence of the event stream is higher than that when it comes to write the event – this prevents a concurrency error if another thread appends a withdrawal while you are so doing.
  25. The result of this is that we are prevented from withdrawing more money than we have in the account.
  26. Event grid is how notifications, commands and queries are passed around my putative system. Event grid is “always listening” – if it receives a notification it can trigger an invocation (“wake up”) of the azure function(s) subscribing to it. Event grid will retry sending to a subscription if the send does not succeed – if they fail for 24 hours then the message will be put in a “deal letter” location. Events will be delivered at least once – but possibly more than once, so you should code defensively for that possibility
  27. The demonstration system is for organising an amateur running organisation. It is split into three domains – the league domain being anything to do with the overall organisation of leagues, The race domain being to do with an individual race, The runner domain being relating to the runner and their interaction with the organisation. Importantly there is no privileged communication between the domains – the interface available to each other is the same interface publicly available outside.
  28. A command is issued to the system through an event grid topic. This triggers the azure function that is bound to that event grid topic (the “handler”) and passes the parameters from the “data” member to it.
  29. This triggered function starts a durable function orchestration and also creates an event stream for the command so that the business-meaning of the command operation can be tracked
  30. Each step in the command handler is performed in sequence as durable function activities which write their progress / results back to the event stream of the command. The individual steps can run projections over the command itself to check if the command is in a state at which that individual step can execute
  31. When the command is performing an update it will append events to the event streams of those entities that it is updating. There may be more than entity impacted by a command. Finally if any notification targets were passed into the command handler a notification event is sent to them. (This could be for UI updating or function chaining etc.)
  32. The orchestration function has an [OrchestrationTrigger] attribute and durable orchestration through which the details of what kicked off the orchestration can be found
  33. The orchestration calls out to Activity methods which do the actual work of each step
  34. Events are appended to the appropriate EventStream in order to record what the command has done – effectively what has changed
  35. An independent sub orchestration is fired off that does all the work to do with notifying other domains of this command’s action
  36. A query is triggered in a similar manner but in addition to the parameters you also pass in a return address to which the results of the query should be returned.
  37. The projections that need to be executed in order to answer the query can be execute din parallel by using the fan-out pattern of durable functions and when they complete they write their results back to the event stream of the query handler
  38. These results are then collated in whatever way is required and the output is sent to every response target that was passed in with the query request.
  39. Projection requests are written to the query event stream so we can see what work has been done and what is outstanding in running the query Projections themselves can then be run in parallel by using durable functions “fan-out” mechanism. Once all the projections are complete any totting up steps could run.
  40. Projection requests are written to the query event stream so we can see what work has been done and what is outstanding in running the query Projections themselves can then be run in parallel by using durable functions “fan-out” mechanism. Once all the projections are complete any totting up steps could run.
  41. Domains communicate directly with each other by these commands and queries Domains can also raise notifications that other domains or indeed other processes can subscribe to. (These notifications are tagged with the “as of date” and “as of sequence number” information so that the subscriber can determine if it has already received this notification before.)
  42. Because serverless computing is no less susceptible to the “sunk cost fallacy” it is worth investing time in design before getting started coding. It is a mistake to allow the rapid spin-up time of serverless functions as an excuse not to do some design work. I would recommend looking at things like event storming as a way to do this. If you are dealing with a system that needs to be able to survive being spun down without the worry of data loss requires being rigorous about reading your won writes – i.e. making sure any state change is persisted before it is used.
  43. Event Grid for the reliable messaging between domains (and with the outside world) – this allows us to stitch together domains with publish-subscribe, which means we can easily extend the system. Serverless function hosting for dynamic scaling. Durable Function Orchestration for the long running processes that handle the commands and queries. Durable functions fan out/fan in for processes that can run in parallel. Event sourcing to save on the overhead required by using a database.