SlideShare a Scribd company logo
1 of 14
How to build more reliable,
robust and scalable distributed
systems
Lars-Erik Kindblad
Senior Consultant
Twitter: @kindblad
E-mail: le@kindblad.com
The Book Shop
 Place order should:
1. Save the order in a database
2. Charge the customer’s credit
card
3. Send a confirmation e-mail to
the customer
The typical way – request/response

Place order

Browser

1. Add order

OrderService

OrderController
2. Charge credit card

PaymentService
3. Send mail

NotificationService

Also called synchronous remote procedure call
Problem #1 – the order is lost

Failures:
Network
Webservice
Database++

Place order
1. Add order

Browser

OrderController
Error page

Error

OrderService

Exception
2. Charge credit card

PaymentService
3. Send mail

NotificationService

 Order is lost
 User will receive an error
 User might leave – lost sale
 User might retry
Problem #2 – no transactional management
Place order
1. Add order

Browser

OrderService

OrderController
Error page
Exception

2. Charge credit card

PaymentService
3. Send mail

Error

 Order is stored
 Payment is processed
 E-mail is not sent
 User receives an error and might retry:
 Order might be stored twice in the database
 Credit card might be charged multiple times

NotificationService
Solution – one-way messaging

Add PlaceOrder
message

Place order

Browser

OrderController

Queue

Asynchronous

The message:

PlaceOrder message 4
First-In
Queue
PlaceOrder message 3
PlaceOrder message 2
PlaceOrder message 1
First-Out
The message must also be processed
Queue

1. Connect

2. Receive message PlaceOrder

PlaceOrder

Worker

3. PlaceOrder
Message Handler

4. Add order

OrderService
5. Charge credit card

PaymentService
6. Send mail

NotificationService
Benefits
 Very fast on the frontend – put the message on the queue
 The order is never lost
 Automatically retries during errors
4. Rollback. Put the message
back on the queue
and retry

Queue

1. Connect

2. Receive message
PlaceOrder
PlaceOrder

Worker

3. PlaceOrder
Error
Message Handler
We still have poor transactional management
1. Add order

Handle PlaceOrder

OrderService
2. Charge credit card

PaymentService
3. Send mail
Exception

Error

NotificationService

 Order is created
 Credit card is charged
 E-mail sending fails
 The message is put back on the queue and will be retried
 Order is duplicated and credit card will be charged twice
Solution
 Split into many messages - one message per transactional boundary
Place order

OrderController

Browser

1. Add PlaceOrder message
All the services must
be idempotent to be
100% reliable

PlaceOrder message

2. Handle PlaceOrder

Add PayOrder message

PayOrder message

Queue

OrderService

3. Handle PayOrder
Add SendMail

SendMail message

4. Handle SendMail

NotificationService

If this fails the
message is put back
on the queue and will
be retried

PaymentService
Scaling
 Request/Response
 Needs to process unpredictable many requests

 Messaging
 Needs to store unpredictable number of messages
 The workers only process a predictable number of messages, even during peaks

 Scale up
 Concurrently process multiple messages

 Scale out
 Use multiple workers
Messaging challenges
1. ID generation


The order ID is first available in the worker

2. Eventual consistency


The PlaceOrder message might not have been picked up yet
NServiceBus
 Lightweight messaging framework for .NET
 Great choice for implementing one-way messaging + publish/subscribe
 Open Source but not free
 Available at http://particular.net/
About Capgemini
With more than 120,000 people in 40 countries, Capgemini is one
of the world's foremost providers of consulting, technology and
outsourcing services. The Group reported 2011 global revenues
of EUR 9.7 billion.
Together with its clients, Capgemini creates and delivers
business and technology solutions that fit their needs and drive
the results they want. A deeply multicultural organization,
Capgemini has developed its own way of working, the
Collaborative Business ExperienceTM, and draws on Rightshore ®,
its worldwide delivery model.
Rightshore® is a trademark belonging to Capgemini

www.capgemini.com

The information contained in this presentation is proprietary.
© 2012 Capgemini. All rights reserved.

More Related Content

What's hot

An Introduction To The DMARC SMTP Validation Requirements
An Introduction To The DMARC SMTP Validation RequirementsAn Introduction To The DMARC SMTP Validation Requirements
An Introduction To The DMARC SMTP Validation RequirementsGabriella Davis
 
What to consider when monitoring microservices
What to consider when monitoring microservicesWhat to consider when monitoring microservices
What to consider when monitoring microservicesParticular Software
 
The Sametime Mobile Experience
The Sametime Mobile ExperienceThe Sametime Mobile Experience
The Sametime Mobile ExperienceGabriella Davis
 
Becoming A Connections Administrator
Becoming A Connections AdministratorBecoming A Connections Administrator
Becoming A Connections AdministratorGabriella Davis
 
Working With Sametime For Mobile Devices
Working With Sametime For Mobile DevicesWorking With Sametime For Mobile Devices
Working With Sametime For Mobile DevicesGabriella Davis
 
Making communication across boundaries simple with Azure Service Bus
Making communication across boundaries simple with Azure Service BusMaking communication across boundaries simple with Azure Service Bus
Making communication across boundaries simple with Azure Service BusParticular Software
 
An introduction to configuring Domino for Docker
An introduction to configuring Domino for DockerAn introduction to configuring Domino for Docker
An introduction to configuring Domino for DockerGabriella Davis
 
HCL Domino V12 Key Security Features Overview
HCL Domino V12 Key Security Features Overview HCL Domino V12 Key Security Features Overview
HCL Domino V12 Key Security Features Overview hemantnaik
 
Traveler management, security and performance
Traveler management, security and performanceTraveler management, security and performance
Traveler management, security and performanceGabriella Davis
 
Apache ActiveMQ - Enterprise messaging in action
Apache ActiveMQ - Enterprise messaging in actionApache ActiveMQ - Enterprise messaging in action
Apache ActiveMQ - Enterprise messaging in actiondejanb
 
NServiceBus - building a distributed system based on a messaging infrastructure
NServiceBus - building a distributed system based on a messaging infrastructureNServiceBus - building a distributed system based on a messaging infrastructure
NServiceBus - building a distributed system based on a messaging infrastructureMauro Servienti
 
IBM Notes Traveler Best Practices
IBM Notes Traveler Best PracticesIBM Notes Traveler Best Practices
IBM Notes Traveler Best Practicesjayeshpar2006
 
A detailed Tibco EMS presentation
A detailed Tibco EMS presentationA detailed Tibco EMS presentation
A detailed Tibco EMS presentationCblsolutions.com
 
SharePoint Saturday Kansas City - Kerberos Survival Guide
SharePoint Saturday Kansas City - Kerberos Survival GuideSharePoint Saturday Kansas City - Kerberos Survival Guide
SharePoint Saturday Kansas City - Kerberos Survival GuideJ.D. Wade
 
Help! My Travelers complain about performance, what to do ??
Help! My Travelers complain about performance, what to do ??Help! My Travelers complain about performance, what to do ??
Help! My Travelers complain about performance, what to do ??ICON UK EVENTS Limited
 
Upgrading to Sametime 9.0.1
Upgrading to Sametime 9.0.1Upgrading to Sametime 9.0.1
Upgrading to Sametime 9.0.1Gabriella Davis
 

What's hot (20)

An Introduction To The DMARC SMTP Validation Requirements
An Introduction To The DMARC SMTP Validation RequirementsAn Introduction To The DMARC SMTP Validation Requirements
An Introduction To The DMARC SMTP Validation Requirements
 
What to consider when monitoring microservices
What to consider when monitoring microservicesWhat to consider when monitoring microservices
What to consider when monitoring microservices
 
The Sametime Mobile Experience
The Sametime Mobile ExperienceThe Sametime Mobile Experience
The Sametime Mobile Experience
 
Becoming A Connections Administrator
Becoming A Connections AdministratorBecoming A Connections Administrator
Becoming A Connections Administrator
 
Working With Sametime For Mobile Devices
Working With Sametime For Mobile DevicesWorking With Sametime For Mobile Devices
Working With Sametime For Mobile Devices
 
Making communication across boundaries simple with Azure Service Bus
Making communication across boundaries simple with Azure Service BusMaking communication across boundaries simple with Azure Service Bus
Making communication across boundaries simple with Azure Service Bus
 
An introduction to configuring Domino for Docker
An introduction to configuring Domino for DockerAn introduction to configuring Domino for Docker
An introduction to configuring Domino for Docker
 
HCL Domino V12 Key Security Features Overview
HCL Domino V12 Key Security Features Overview HCL Domino V12 Key Security Features Overview
HCL Domino V12 Key Security Features Overview
 
Traveler management, security and performance
Traveler management, security and performanceTraveler management, security and performance
Traveler management, security and performance
 
Apache ActiveMQ - Enterprise messaging in action
Apache ActiveMQ - Enterprise messaging in actionApache ActiveMQ - Enterprise messaging in action
Apache ActiveMQ - Enterprise messaging in action
 
Learn what is TIBCO EMS
Learn what is TIBCO EMSLearn what is TIBCO EMS
Learn what is TIBCO EMS
 
NServiceBus - building a distributed system based on a messaging infrastructure
NServiceBus - building a distributed system based on a messaging infrastructureNServiceBus - building a distributed system based on a messaging infrastructure
NServiceBus - building a distributed system based on a messaging infrastructure
 
IBM Notes Traveler Best Practices
IBM Notes Traveler Best PracticesIBM Notes Traveler Best Practices
IBM Notes Traveler Best Practices
 
Ems
EmsEms
Ems
 
A detailed Tibco EMS presentation
A detailed Tibco EMS presentationA detailed Tibco EMS presentation
A detailed Tibco EMS presentation
 
Quickr
QuickrQuickr
Quickr
 
test
testtest
test
 
SharePoint Saturday Kansas City - Kerberos Survival Guide
SharePoint Saturday Kansas City - Kerberos Survival GuideSharePoint Saturday Kansas City - Kerberos Survival Guide
SharePoint Saturday Kansas City - Kerberos Survival Guide
 
Help! My Travelers complain about performance, what to do ??
Help! My Travelers complain about performance, what to do ??Help! My Travelers complain about performance, what to do ??
Help! My Travelers complain about performance, what to do ??
 
Upgrading to Sametime 9.0.1
Upgrading to Sametime 9.0.1Upgrading to Sametime 9.0.1
Upgrading to Sametime 9.0.1
 

Similar to How to build more reliable, robust and scalable distributed systems

Online payment system
Online payment systemOnline payment system
Online payment systemmyangel27
 
Netcore Falconide Triggred and Transactional Emails
Netcore Falconide Triggred and Transactional EmailsNetcore Falconide Triggred and Transactional Emails
Netcore Falconide Triggred and Transactional EmailsNetcore Solutions
 
The electronic payment systems
The electronic payment systemsThe electronic payment systems
The electronic payment systemsVishal Singh
 
How to managed e discovery services
How to managed e discovery servicesHow to managed e discovery services
How to managed e discovery serviceselijaht
 
Email Migration- Essential Questions to Ask Before Migrating Email
Email Migration- Essential Questions to Ask Before Migrating EmailEmail Migration- Essential Questions to Ask Before Migrating Email
Email Migration- Essential Questions to Ask Before Migrating Emailmanoharparakh
 
BA 65 Hour 5 ~ Creating an Ecommerce Site
BA 65 Hour 5 ~ Creating an Ecommerce SiteBA 65 Hour 5 ~ Creating an Ecommerce Site
BA 65 Hour 5 ~ Creating an Ecommerce Sitedpd
 
Easy Mobile Payments
Easy Mobile PaymentsEasy Mobile Payments
Easy Mobile PaymentsPayPal
 
Mastery Webinar Series: Strategies to Simplify Email Data Management
Mastery Webinar Series: Strategies to Simplify Email Data ManagementMastery Webinar Series: Strategies to Simplify Email Data Management
Mastery Webinar Series: Strategies to Simplify Email Data ManagementVaultastic
 
Sms to emails
Sms to emailsSms to emails
Sms to emailsAvinash
 
15 Challenges of On-Premise or Self-Hosted Email For Business.docx
15 Challenges of On-Premise or Self-Hosted Email For Business.docx15 Challenges of On-Premise or Self-Hosted Email For Business.docx
15 Challenges of On-Premise or Self-Hosted Email For Business.docxMailSafi
 
General Internet Services
General Internet ServicesGeneral Internet Services
General Internet ServicesCeliaBSeaton
 
5 email data management strategies and choosing the right one
5 email data management strategies and choosing the right one5 email data management strategies and choosing the right one
5 email data management strategies and choosing the right oneVaultastic
 
Difference between Client Polling vs Server Push vs Websocket vs Long Polling
Difference between Client Polling vs Server Push vs Websocket vs Long PollingDifference between Client Polling vs Server Push vs Websocket vs Long Polling
Difference between Client Polling vs Server Push vs Websocket vs Long Pollingjeetendra mandal
 
Messaging is not just for investment banks!
Messaging is not just for investment banks!Messaging is not just for investment banks!
Messaging is not just for investment banks!elliando dias
 

Similar to How to build more reliable, robust and scalable distributed systems (20)

Online payment system
Online payment systemOnline payment system
Online payment system
 
Netcore Falconide Triggred and Transactional Emails
Netcore Falconide Triggred and Transactional EmailsNetcore Falconide Triggred and Transactional Emails
Netcore Falconide Triggred and Transactional Emails
 
The electronic payment systems
The electronic payment systemsThe electronic payment systems
The electronic payment systems
 
How to managed e discovery services
How to managed e discovery servicesHow to managed e discovery services
How to managed e discovery services
 
Email Migration- Essential Questions to Ask Before Migrating Email
Email Migration- Essential Questions to Ask Before Migrating EmailEmail Migration- Essential Questions to Ask Before Migrating Email
Email Migration- Essential Questions to Ask Before Migrating Email
 
Edi in action
Edi in actionEdi in action
Edi in action
 
BA 65 Hour 5 ~ Creating an Ecommerce Site
BA 65 Hour 5 ~ Creating an Ecommerce SiteBA 65 Hour 5 ~ Creating an Ecommerce Site
BA 65 Hour 5 ~ Creating an Ecommerce Site
 
BrightPay and Modulr: Webinar for Accountants
BrightPay and Modulr: Webinar for AccountantsBrightPay and Modulr: Webinar for Accountants
BrightPay and Modulr: Webinar for Accountants
 
Easy Mobile Payments
Easy Mobile PaymentsEasy Mobile Payments
Easy Mobile Payments
 
Mastery Webinar Series: Strategies to Simplify Email Data Management
Mastery Webinar Series: Strategies to Simplify Email Data ManagementMastery Webinar Series: Strategies to Simplify Email Data Management
Mastery Webinar Series: Strategies to Simplify Email Data Management
 
Sms to emails
Sms to emailsSms to emails
Sms to emails
 
15 Challenges of On-Premise or Self-Hosted Email For Business.docx
15 Challenges of On-Premise or Self-Hosted Email For Business.docx15 Challenges of On-Premise or Self-Hosted Email For Business.docx
15 Challenges of On-Premise or Self-Hosted Email For Business.docx
 
Drive Supplier Payment Automation
Drive Supplier Payment AutomationDrive Supplier Payment Automation
Drive Supplier Payment Automation
 
General Internet Services
General Internet ServicesGeneral Internet Services
General Internet Services
 
Email As A Datasource
Email As A DatasourceEmail As A Datasource
Email As A Datasource
 
5 email data management strategies and choosing the right one
5 email data management strategies and choosing the right one5 email data management strategies and choosing the right one
5 email data management strategies and choosing the right one
 
Ecommerce_Ch5.ppt
Ecommerce_Ch5.pptEcommerce_Ch5.ppt
Ecommerce_Ch5.ppt
 
Difference between Client Polling vs Server Push vs Websocket vs Long Polling
Difference between Client Polling vs Server Push vs Websocket vs Long PollingDifference between Client Polling vs Server Push vs Websocket vs Long Polling
Difference between Client Polling vs Server Push vs Websocket vs Long Polling
 
E com ms megha
E com ms meghaE com ms megha
E com ms megha
 
Messaging is not just for investment banks!
Messaging is not just for investment banks!Messaging is not just for investment banks!
Messaging is not just for investment banks!
 

More from Lars-Erik Kindblad

Application Architecture April 2014
Application Architecture April 2014Application Architecture April 2014
Application Architecture April 2014Lars-Erik Kindblad
 
Unit Tests are Overrated (NDCOslo 2013)
Unit Tests are Overrated (NDCOslo 2013)Unit Tests are Overrated (NDCOslo 2013)
Unit Tests are Overrated (NDCOslo 2013)Lars-Erik Kindblad
 
Publish & Subscribe to events using an Event Aggregator
Publish & Subscribe to events using an Event AggregatorPublish & Subscribe to events using an Event Aggregator
Publish & Subscribe to events using an Event AggregatorLars-Erik Kindblad
 
The Single Responsibility Principle
The Single Responsibility PrincipleThe Single Responsibility Principle
The Single Responsibility PrincipleLars-Erik Kindblad
 
Avoid code duplication! Principles & Patterns
Avoid code duplication! Principles & PatternsAvoid code duplication! Principles & Patterns
Avoid code duplication! Principles & PatternsLars-Erik Kindblad
 
Application Architecture by Lars-Erik Kindblad, Capgemini
Application Architecture by Lars-Erik Kindblad, CapgeminiApplication Architecture by Lars-Erik Kindblad, Capgemini
Application Architecture by Lars-Erik Kindblad, CapgeminiLars-Erik Kindblad
 
Inversion of Control - Introduction and Best Practice
Inversion of Control - Introduction and Best PracticeInversion of Control - Introduction and Best Practice
Inversion of Control - Introduction and Best PracticeLars-Erik Kindblad
 
Introduction to FluentData - The Micro ORM
Introduction to FluentData - The Micro ORMIntroduction to FluentData - The Micro ORM
Introduction to FluentData - The Micro ORMLars-Erik Kindblad
 
Dependency Injection vs Service Locator - Best Practice
Dependency Injection vs Service Locator - Best PracticeDependency Injection vs Service Locator - Best Practice
Dependency Injection vs Service Locator - Best PracticeLars-Erik Kindblad
 

More from Lars-Erik Kindblad (13)

Application Architecture April 2014
Application Architecture April 2014Application Architecture April 2014
Application Architecture April 2014
 
Application Architecture
Application ArchitectureApplication Architecture
Application Architecture
 
Unit Tests are Overrated (NDCOslo 2013)
Unit Tests are Overrated (NDCOslo 2013)Unit Tests are Overrated (NDCOslo 2013)
Unit Tests are Overrated (NDCOslo 2013)
 
Publish & Subscribe to events using an Event Aggregator
Publish & Subscribe to events using an Event AggregatorPublish & Subscribe to events using an Event Aggregator
Publish & Subscribe to events using an Event Aggregator
 
The Single Responsibility Principle
The Single Responsibility PrincipleThe Single Responsibility Principle
The Single Responsibility Principle
 
Avoid code duplication! Principles & Patterns
Avoid code duplication! Principles & PatternsAvoid code duplication! Principles & Patterns
Avoid code duplication! Principles & Patterns
 
Application Architecture by Lars-Erik Kindblad, Capgemini
Application Architecture by Lars-Erik Kindblad, CapgeminiApplication Architecture by Lars-Erik Kindblad, Capgemini
Application Architecture by Lars-Erik Kindblad, Capgemini
 
The Fluent Interface Pattern
The Fluent Interface PatternThe Fluent Interface Pattern
The Fluent Interface Pattern
 
Inversion of Control - Introduction and Best Practice
Inversion of Control - Introduction and Best PracticeInversion of Control - Introduction and Best Practice
Inversion of Control - Introduction and Best Practice
 
Layered Software Architecture
Layered Software ArchitectureLayered Software Architecture
Layered Software Architecture
 
Introduction to FluentData - The Micro ORM
Introduction to FluentData - The Micro ORMIntroduction to FluentData - The Micro ORM
Introduction to FluentData - The Micro ORM
 
Dependency Injection vs Service Locator - Best Practice
Dependency Injection vs Service Locator - Best PracticeDependency Injection vs Service Locator - Best Practice
Dependency Injection vs Service Locator - Best Practice
 
Data Access - Best Practice
Data Access - Best PracticeData Access - Best Practice
Data Access - Best Practice
 

Recently uploaded

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
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 MenDelhi Call girls
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
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 MenDelhi Call girls
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 

Recently uploaded (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
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
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
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
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 

How to build more reliable, robust and scalable distributed systems

  • 1. How to build more reliable, robust and scalable distributed systems Lars-Erik Kindblad Senior Consultant Twitter: @kindblad E-mail: le@kindblad.com
  • 2. The Book Shop  Place order should: 1. Save the order in a database 2. Charge the customer’s credit card 3. Send a confirmation e-mail to the customer
  • 3. The typical way – request/response Place order Browser 1. Add order OrderService OrderController 2. Charge credit card PaymentService 3. Send mail NotificationService Also called synchronous remote procedure call
  • 4. Problem #1 – the order is lost Failures: Network Webservice Database++ Place order 1. Add order Browser OrderController Error page Error OrderService Exception 2. Charge credit card PaymentService 3. Send mail NotificationService  Order is lost  User will receive an error  User might leave – lost sale  User might retry
  • 5. Problem #2 – no transactional management Place order 1. Add order Browser OrderService OrderController Error page Exception 2. Charge credit card PaymentService 3. Send mail Error  Order is stored  Payment is processed  E-mail is not sent  User receives an error and might retry:  Order might be stored twice in the database  Credit card might be charged multiple times NotificationService
  • 6. Solution – one-way messaging Add PlaceOrder message Place order Browser OrderController Queue Asynchronous The message: PlaceOrder message 4 First-In Queue PlaceOrder message 3 PlaceOrder message 2 PlaceOrder message 1 First-Out
  • 7. The message must also be processed Queue 1. Connect 2. Receive message PlaceOrder PlaceOrder Worker 3. PlaceOrder Message Handler 4. Add order OrderService 5. Charge credit card PaymentService 6. Send mail NotificationService
  • 8. Benefits  Very fast on the frontend – put the message on the queue  The order is never lost  Automatically retries during errors 4. Rollback. Put the message back on the queue and retry Queue 1. Connect 2. Receive message PlaceOrder PlaceOrder Worker 3. PlaceOrder Error Message Handler
  • 9. We still have poor transactional management 1. Add order Handle PlaceOrder OrderService 2. Charge credit card PaymentService 3. Send mail Exception Error NotificationService  Order is created  Credit card is charged  E-mail sending fails  The message is put back on the queue and will be retried  Order is duplicated and credit card will be charged twice
  • 10. Solution  Split into many messages - one message per transactional boundary Place order OrderController Browser 1. Add PlaceOrder message All the services must be idempotent to be 100% reliable PlaceOrder message 2. Handle PlaceOrder Add PayOrder message PayOrder message Queue OrderService 3. Handle PayOrder Add SendMail SendMail message 4. Handle SendMail NotificationService If this fails the message is put back on the queue and will be retried PaymentService
  • 11. Scaling  Request/Response  Needs to process unpredictable many requests  Messaging  Needs to store unpredictable number of messages  The workers only process a predictable number of messages, even during peaks  Scale up  Concurrently process multiple messages  Scale out  Use multiple workers
  • 12. Messaging challenges 1. ID generation  The order ID is first available in the worker 2. Eventual consistency  The PlaceOrder message might not have been picked up yet
  • 13. NServiceBus  Lightweight messaging framework for .NET  Great choice for implementing one-way messaging + publish/subscribe  Open Source but not free  Available at http://particular.net/
  • 14. About Capgemini With more than 120,000 people in 40 countries, Capgemini is one of the world's foremost providers of consulting, technology and outsourcing services. The Group reported 2011 global revenues of EUR 9.7 billion. Together with its clients, Capgemini creates and delivers business and technology solutions that fit their needs and drive the results they want. A deeply multicultural organization, Capgemini has developed its own way of working, the Collaborative Business ExperienceTM, and draws on Rightshore ®, its worldwide delivery model. Rightshore® is a trademark belonging to Capgemini www.capgemini.com The information contained in this presentation is proprietary. © 2012 Capgemini. All rights reserved.