SlideShare a Scribd company logo
designing distributed scalable
and reliable systems
Mauro Servienti
CTO @ Mastreeno, LTD
mauro.servienti@mastreeno.com
@mauroservienti
//milestone.topics.it
//github.com/mauroservienti
NServiceBus trainer/support
RavenDB trainer
Microsoft MVP – Visual C#
Side note: such little time…and I’m
Italian :-)
• We have a tons of things to say;
• We have a tons of slides (ok, my fault :-P);
• My English is the worst thing you’ll ever hear
:-)
• If you, guys, can delay questions, leaving them
for the break, it will be much easier :-)
– Especially for me :-P
Resources
• Slides on SlideShare:
//slideshare.net/mauroservienti
• Samples on GitHub:
//github.com/mauroservienti
– Repository: Conferences
– Branches:
• Full-Stack-Sample
• 2014/SkillsMatter-InTheBrain-Distributed
TENETS
Articles of faith…
None of the following is true
• Network is reliable;
• Latency is near to zero or irrelevant;
• Bandwidth is unlimited;
• Network is secure;
• Topology doesn’t change;
• Transport cost is irrelevant;
• Network is homogeneous;
DEFINITIONS
Let’s get in touch…
Consistency
The rate of agreement of observers looking at a
system at a given point in time.
The more the observers agree on what they see
the more the system is consistent.
Coupling
The rate of dependency among parts of a
system.
The more changing a portion of the system
impacts on other portions of the system the
more the system is coupled.
Temporal Coupling
It’s a special form of coupling.
The more non-availability of a portion of the
system impacts on other parts the more the
system is temporally coupled.
Scalability
the ability of a system to handle a growing
amount of work in a capable manner
Scalability is generally difficult to define
and in any particular case it is necessary to
define the specific requirements for
scalability
The more we scale the
more we cannot rely on
consistency
“ACD/C”
Scaling can be achieved understanding that we
need to choose and accept consequences of our
decisions, our pillars should be:
- Asynchronous;
- Cached;
- Distributed;
- And not Consistent;
CONSINSTENCY?
Are you kidding me :-)
A strange world :-)
• A new order comes in;
• The whole company is informed that a new order
we’ll be processed and we need to:
– Understand if items are in stock;
– Understand if we need to produce/buy something;
• At the same time production is trying to
understand how to schedule the new order but is
waiting for the warehouse that is currently used
by the sales department to understand if the
order can be shipped within the next week;
DEADLOCK
The real world…
• The obvious and only consequence of trying
to scale a monolith is the collapse of the
entire system;
• The real world:
– Does not know at all what transactions are
(especially distributed);
– Has a really low, if not null, coupling among parts;
– Has no temporal coupling at all;
Transaction boundaries
• We cannot any more rely on transactions to
guarantee consistency, e.g.:
1. Update the shopping chart;
2. Checkout;
3. Create the order;
4. Create the shipment request at FedEx;
• “Simply” 1, 2, 3 and 4 can live in different systems on
different machines with different databases;
– And given our tenets we now have a problem
– And a solution... :-)
EVENTUAL
CONSISTENCY
The rate of the agreement
• Will be low or really low;
• Every communication must bring with itself its
version (or timestamp) in order to be able to sort
stuff;
• Parts of the system are now free to move
independently:
– They can evolve due to the low coupling;
– Be available or not, depending on their needs,
because there is no temporal coupling;
• Parts…parts…parts…and parts
BOUNDED
CONTEXT
Bounded Context
• BCs, easily identified by/via the Ubiquitous
Language perfectly map the concept of part or
the one of transaction boundary;
• Within the BC the level of consistency is
expected to be much higher than cross BCs;
• BCs can be isolated and should be able to live
by their own;
• BCs generally are a unit of deployment;
MESSAGES
We have async and distributed parts…but…how they talk to each other?
asynchronous
We cannot rely on RPC calls
the other part is not guaranteed to be there
when we need it.
asynchronous
QueueSender Receiver
Now
Some time in the future
distributed
We need an atomic piece of information
we cannot rely on ordering
we cannot rely on receiving the information at
the same place (is distributed);
distributed
QueueSender Receiver
C
Receiver
Receiver
B
A
B
A
Broken!
C
non-coupled
We need the message as small as possible
The more the exchanged vocabulary is large the
more coupling we have
Changing the vocabulary is hard, think twice
about it
IT’S A LONG WAY TO THE TOP IF
YOU WANNA ROCK & ROLL…
Do we really need to go to that root?
without context
problems
are
empty talks
Context & Requirements
• Requirements set the boundary of the
problem;
– A problem not identified by a requirement does
not exists;
• Much more: requirements set the boundary of
the solution;
– A solution is valid when within the requirements
otherwise it is over-engineering;
DO WE NEED TO SCALE-OUT?
The question should be…
“keep it simple”
• redesign the system from
scratch;
• move everything to RavenDB;
• Introduce Elastic Search;
• Add a Redis cache on Linux
• 6 months, £££££
• can fail
• Replace disks on the SQL
machine with 2 fast SSD(s)
• 1hr, £
• Observe the next 6 months :-)
A “small” e-commerce based on the traditional 3-layer
architecture: Pages response time is slow;
“re-design”
• Single batch per request
• Trying to scale this fails
• Multi-batch per request
• Re-designing the system
guarantees to scale
A delivery system (e.g. your favorite retailer): want to
increase the amount of order handled per unit of time
A new hope <cit.>
Moving away from a traditional architecture brings
a lot of challenges to the table:
• Everything will be async;
• Non availability of a system must be managed;
• Handling async failures;
• Handling of synchronized access to shared
resources;
• How to correlate messages;
• How to handle versioning and upgrades;
• And more…
NServiceBus
Please welcome:
Concepts
• Message
– An atomic piece of information that has a semantical
meaning in the business;
• Component
– Something that can handle a message;
• Service
– A set of components grouped by context;
• Endpoint
– A set of services grouped by:
• SLA(s);
• Infrastructure concerns;
• Etc..;
Concepts #2
• Command: A message that semantically
identifies something to be done (imperative):
– "CreateNewUser";
• Event: A message that semantically identifies
something happened and immutable (past):
– "NewUserCreated";
• Subscription: The notion that an endpoint is
interested in an event;
DEMO
Transport
• Transport(s): The technology used to connect
systems and transport the message:
– MSMQ
– RabbitMQ
– SQL Server
– Azure ServiceBus & Azure Queues
• Serialization: the way messages are"serialized" in
order to be transported on the choosen
transport;
– it is transparent to the transport;
Advanced Concepts
• Saga: An orchestrator for a long running
workflow, with the ability to store the saga
state across requests and handling
concurrency;
• Timeout: The way a Saga can take
autonomous decisions;
• Retries: First level and Second level retry
engine to handle transient failures;
• Error & Audit: error and auditing management
SCALE OUT & HIGH AVAILABILITY
In an eventual consistent world
Mail & Mail Servers
When we send an email message:
• Our relation with the mail server is consistent?
Yes;
• Cross-servers relation is consistent? Yes;
• Relationship between the last server and the
recipient is consistent? Yes;
The entire system is consistent? No
But we have some guarantees:
• Every single hop/node/BC is consistent;
• If something along the way fails we will have,
with the same logic, an information back that
our request is failed or succeeded;
• Do we need distributed transactions? No :-)
• The message is fully enough to guarantee
consistency, in the long run.
DEMO
Publish/Subscribe
• Request/Response is generally considered an
anti-pattern;
• Events are the easiest way to drive the world:
– SomethingHappened;
• DoSomethingToMoveOn;
• Lots of possible listener and lots of possible
publishers:
– CorrelationID
DEMO
QUESTIONS?
We are all set :-)

More Related Content

What's hot (19)

PPTX
Making communication across boundaries simple with Azure Service Bus
Particular Software
 
PDF
Dark launching with Consul at Hootsuite - Bill Monkman
Ambassador Labs
 
PPTX
Kafka at scale facebook israel
Gwen (Chen) Shapira
 
PDF
Troubleshooting Kafka's socket server: from incident to resolution
Joel Koshy
 
PDF
The Zen of High Performance Messaging with NATS (Strange Loop 2016)
wallyqs
 
PPTX
Nyc kafka meetup 2015 - when bad things happen to good kafka clusters
Gwen (Chen) Shapira
 
PDF
High-Speed Reactive Microservices
Rick Hightower
 
PDF
KubeCon + CloudNative Con NA 2021 | A New Generation of NATS
NATS
 
PDF
How Clarifai uses NATS and Kubernetes for Machine Learning
Apcera
 
PPTX
Spring Boot+Kafka: the New Enterprise Platform
VMware Tanzu
 
PDF
Simple Solutions for Complex Problems
Apcera
 
PPTX
Netflix Data Pipeline With Kafka
Steven Wu
 
PPTX
Reducing Microservice Complexity with Kafka and Reactive Streams
jimriecken
 
PDF
Go Reactive: Building Responsive, Resilient, Elastic & Message-Driven Systems
Jonas Bonér
 
PPTX
Introduction to Apache Kafka
Jeff Holoman
 
PDF
Micro on NATS - Microservices with Messaging
Apcera
 
PPTX
Introduction to NServiceBus
Adam Fyles
 
PPTX
NATS for Modern Messaging and Microservices
Apcera
 
PDF
Select Stars: A SQL DBA's Introduction to Azure Cosmos DB (SQL Saturday Orego...
Bob Pusateri
 
Making communication across boundaries simple with Azure Service Bus
Particular Software
 
Dark launching with Consul at Hootsuite - Bill Monkman
Ambassador Labs
 
Kafka at scale facebook israel
Gwen (Chen) Shapira
 
Troubleshooting Kafka's socket server: from incident to resolution
Joel Koshy
 
The Zen of High Performance Messaging with NATS (Strange Loop 2016)
wallyqs
 
Nyc kafka meetup 2015 - when bad things happen to good kafka clusters
Gwen (Chen) Shapira
 
High-Speed Reactive Microservices
Rick Hightower
 
KubeCon + CloudNative Con NA 2021 | A New Generation of NATS
NATS
 
How Clarifai uses NATS and Kubernetes for Machine Learning
Apcera
 
Spring Boot+Kafka: the New Enterprise Platform
VMware Tanzu
 
Simple Solutions for Complex Problems
Apcera
 
Netflix Data Pipeline With Kafka
Steven Wu
 
Reducing Microservice Complexity with Kafka and Reactive Streams
jimriecken
 
Go Reactive: Building Responsive, Resilient, Elastic & Message-Driven Systems
Jonas Bonér
 
Introduction to Apache Kafka
Jeff Holoman
 
Micro on NATS - Microservices with Messaging
Apcera
 
Introduction to NServiceBus
Adam Fyles
 
NATS for Modern Messaging and Microservices
Apcera
 
Select Stars: A SQL DBA's Introduction to Azure Cosmos DB (SQL Saturday Orego...
Bob Pusateri
 

Viewers also liked (13)

PDF
From Monolith to Docker Distributed Applications
Carlos Sanchez
 
PPTX
Introduction to NserviceBus
Mauro Servienti
 
PPTX
Reactive Architecture
Assaf Gannon
 
PDF
CV Ruberto Luca Matteo: ICT SOlution Architect
Luca Matteo Ruberto
 
PPTX
EIP with Apache Camel
Andrea Torino Rodriguez
 
PPT
Design principles of scalable, distributed systems
Tinniam V Ganesh (TV)
 
PPTX
Modern Software Architectures: Building Solutions for Web, Cloud, and Mobile
Dan Mohl
 
PDF
The Modern Software Architect
Niels Bech Nielsen
 
PPTX
Micro Service Architecture
Eduards Sizovs
 
PPTX
Software Architecture Patterns
Assaf Gannon
 
PDF
Intro to functional programming
Assaf Gannon
 
PDF
Dockercon State of the Art in Microservices
Adrian Cockcroft
 
PDF
Principles of microservices velocity
Sam Newman
 
From Monolith to Docker Distributed Applications
Carlos Sanchez
 
Introduction to NserviceBus
Mauro Servienti
 
Reactive Architecture
Assaf Gannon
 
CV Ruberto Luca Matteo: ICT SOlution Architect
Luca Matteo Ruberto
 
EIP with Apache Camel
Andrea Torino Rodriguez
 
Design principles of scalable, distributed systems
Tinniam V Ganesh (TV)
 
Modern Software Architectures: Building Solutions for Web, Cloud, and Mobile
Dan Mohl
 
The Modern Software Architect
Niels Bech Nielsen
 
Micro Service Architecture
Eduards Sizovs
 
Software Architecture Patterns
Assaf Gannon
 
Intro to functional programming
Assaf Gannon
 
Dockercon State of the Art in Microservices
Adrian Cockcroft
 
Principles of microservices velocity
Sam Newman
 
Ad

Similar to designing distributed scalable and reliable systems (20)

PPTX
Magento Developer Talk. Microservice Architecture and Actor Model
Igor Miniailo
 
PPTX
The Big Picture - Integrating Buzzwords
Alessandro Giorgetti
 
PPTX
Designing distributed systems
Malisa Ncube
 
PPTX
Scaling Systems: Architectures that grow
Gibraltar Software
 
PDF
Scalable and Available, Patterns for Success
Derek Collison
 
PPTX
Let's talk about... Microservices
Alessandro Giorgetti
 
PPTX
Azure architecture design patterns - proven solutions to common challenges
Ivo Andreev
 
PPTX
Events & Microservices
Yamen Sader
 
PDF
Events and microservices
Saul Caganoff
 
PDF
Architecting systems for continuous delivery
Marcel de Vries
 
KEY
Event Driven Architecture
andreaskallberg
 
PPTX
Designing for the Cloud Tutorial - QCon SF 2009
Stuart Charlton
 
PPTX
Enterprise Software Development Patterns
Josh Lane
 
PDF
Event Driven-Architecture from a Scalability perspective
Jonas Bonér
 
PPTX
Designing distributed, scalable and reliable systems using NServiceBus
Mauro Servienti
 
PDF
Timeless design in a cloud-native world
Uwe Friedrichsen
 
PPTX
Should you be using an event driven architecture - IDA IT (short version)
Jeppe Cramon
 
DOCX
RabbitMQ in Microservice Architecture.docx
Shakuro
 
PDF
Building High Fidelity Data Streams (QCon London 2023)
Sid Anand
 
KEY
Dropping ACID - Building Scalable Systems That Work
Chris Patterson
 
Magento Developer Talk. Microservice Architecture and Actor Model
Igor Miniailo
 
The Big Picture - Integrating Buzzwords
Alessandro Giorgetti
 
Designing distributed systems
Malisa Ncube
 
Scaling Systems: Architectures that grow
Gibraltar Software
 
Scalable and Available, Patterns for Success
Derek Collison
 
Let's talk about... Microservices
Alessandro Giorgetti
 
Azure architecture design patterns - proven solutions to common challenges
Ivo Andreev
 
Events & Microservices
Yamen Sader
 
Events and microservices
Saul Caganoff
 
Architecting systems for continuous delivery
Marcel de Vries
 
Event Driven Architecture
andreaskallberg
 
Designing for the Cloud Tutorial - QCon SF 2009
Stuart Charlton
 
Enterprise Software Development Patterns
Josh Lane
 
Event Driven-Architecture from a Scalability perspective
Jonas Bonér
 
Designing distributed, scalable and reliable systems using NServiceBus
Mauro Servienti
 
Timeless design in a cloud-native world
Uwe Friedrichsen
 
Should you be using an event driven architecture - IDA IT (short version)
Jeppe Cramon
 
RabbitMQ in Microservice Architecture.docx
Shakuro
 
Building High Fidelity Data Streams (QCon London 2023)
Sid Anand
 
Dropping ACID - Building Scalable Systems That Work
Chris Patterson
 
Ad

More from Mauro Servienti (20)

PPTX
Welcome to the (state) machine @ ExploreDDD 2019
Mauro Servienti
 
PPTX
Designing a ui for microservices @ .NET Day Switzerland 2019
Mauro Servienti
 
PPTX
Welcome to the (state) machine @ Xe One Day Enterprise Applications
Mauro Servienti
 
PPTX
All our aggregates are wrong @ NDC Copenhagen 2019
Mauro Servienti
 
PPTX
Be like water, my friend @ Agile for Innovation 2019
Mauro Servienti
 
PPTX
Microservices architecture is it the right choice to design long-living syste...
Mauro Servienti
 
PPTX
Titles, abstracts, and bio matter... oh my! @ Global Diversity CFP Day 2019
Mauro Servienti
 
PPTX
Living organizations, particular software @ do IT Better Parma
Mauro Servienti
 
PPTX
Welcome to the (state) machine @ Crafted Software
Mauro Servienti
 
PPTX
PO is dead, long live the PO - Italian Agile Day 2018
Mauro Servienti
 
PPTX
Design a UI for your Microservices @ Do IT Better
Mauro Servienti
 
PPTX
Microservices and pineapple on pizza what do they have in common - dos and ...
Mauro Servienti
 
PPTX
All our aggregates are wrong (ExploreDDD 2018)
Mauro Servienti
 
PPTX
Designing a ui for microservices
Mauro Servienti
 
PPTX
Po is dead, long live the po
Mauro Servienti
 
PPTX
Shipping code is not the problem, deciding what to ship it is!
Mauro Servienti
 
PPTX
GraphQL - Where are you from? Where are you going?
Mauro Servienti
 
PPTX
Dall'idea al deploy un lungo viaggio che passa per git flow e semver
Mauro Servienti
 
PPTX
Progettare una UI per i Microservices
Mauro Servienti
 
PPTX
The road to a Service Oriented Architecture is paved with messages
Mauro Servienti
 
Welcome to the (state) machine @ ExploreDDD 2019
Mauro Servienti
 
Designing a ui for microservices @ .NET Day Switzerland 2019
Mauro Servienti
 
Welcome to the (state) machine @ Xe One Day Enterprise Applications
Mauro Servienti
 
All our aggregates are wrong @ NDC Copenhagen 2019
Mauro Servienti
 
Be like water, my friend @ Agile for Innovation 2019
Mauro Servienti
 
Microservices architecture is it the right choice to design long-living syste...
Mauro Servienti
 
Titles, abstracts, and bio matter... oh my! @ Global Diversity CFP Day 2019
Mauro Servienti
 
Living organizations, particular software @ do IT Better Parma
Mauro Servienti
 
Welcome to the (state) machine @ Crafted Software
Mauro Servienti
 
PO is dead, long live the PO - Italian Agile Day 2018
Mauro Servienti
 
Design a UI for your Microservices @ Do IT Better
Mauro Servienti
 
Microservices and pineapple on pizza what do they have in common - dos and ...
Mauro Servienti
 
All our aggregates are wrong (ExploreDDD 2018)
Mauro Servienti
 
Designing a ui for microservices
Mauro Servienti
 
Po is dead, long live the po
Mauro Servienti
 
Shipping code is not the problem, deciding what to ship it is!
Mauro Servienti
 
GraphQL - Where are you from? Where are you going?
Mauro Servienti
 
Dall'idea al deploy un lungo viaggio che passa per git flow e semver
Mauro Servienti
 
Progettare una UI per i Microservices
Mauro Servienti
 
The road to a Service Oriented Architecture is paved with messages
Mauro Servienti
 

Recently uploaded (20)

PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PDF
July Patch Tuesday
Ivanti
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
July Patch Tuesday
Ivanti
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 

designing distributed scalable and reliable systems

  • 2. Mauro Servienti CTO @ Mastreeno, LTD [email protected] @mauroservienti //milestone.topics.it //github.com/mauroservienti NServiceBus trainer/support RavenDB trainer Microsoft MVP – Visual C#
  • 3. Side note: such little time…and I’m Italian :-) • We have a tons of things to say; • We have a tons of slides (ok, my fault :-P); • My English is the worst thing you’ll ever hear :-) • If you, guys, can delay questions, leaving them for the break, it will be much easier :-) – Especially for me :-P
  • 4. Resources • Slides on SlideShare: //slideshare.net/mauroservienti • Samples on GitHub: //github.com/mauroservienti – Repository: Conferences – Branches: • Full-Stack-Sample • 2014/SkillsMatter-InTheBrain-Distributed
  • 6. None of the following is true • Network is reliable; • Latency is near to zero or irrelevant; • Bandwidth is unlimited; • Network is secure; • Topology doesn’t change; • Transport cost is irrelevant; • Network is homogeneous;
  • 8. Consistency The rate of agreement of observers looking at a system at a given point in time. The more the observers agree on what they see the more the system is consistent.
  • 9. Coupling The rate of dependency among parts of a system. The more changing a portion of the system impacts on other portions of the system the more the system is coupled.
  • 10. Temporal Coupling It’s a special form of coupling. The more non-availability of a portion of the system impacts on other parts the more the system is temporally coupled.
  • 11. Scalability the ability of a system to handle a growing amount of work in a capable manner Scalability is generally difficult to define and in any particular case it is necessary to define the specific requirements for scalability
  • 12. The more we scale the more we cannot rely on consistency
  • 13. “ACD/C” Scaling can be achieved understanding that we need to choose and accept consequences of our decisions, our pillars should be: - Asynchronous; - Cached; - Distributed; - And not Consistent;
  • 15. A strange world :-) • A new order comes in; • The whole company is informed that a new order we’ll be processed and we need to: – Understand if items are in stock; – Understand if we need to produce/buy something; • At the same time production is trying to understand how to schedule the new order but is waiting for the warehouse that is currently used by the sales department to understand if the order can be shipped within the next week;
  • 17. The real world… • The obvious and only consequence of trying to scale a monolith is the collapse of the entire system; • The real world: – Does not know at all what transactions are (especially distributed); – Has a really low, if not null, coupling among parts; – Has no temporal coupling at all;
  • 18. Transaction boundaries • We cannot any more rely on transactions to guarantee consistency, e.g.: 1. Update the shopping chart; 2. Checkout; 3. Create the order; 4. Create the shipment request at FedEx; • “Simply” 1, 2, 3 and 4 can live in different systems on different machines with different databases; – And given our tenets we now have a problem – And a solution... :-)
  • 20. The rate of the agreement • Will be low or really low; • Every communication must bring with itself its version (or timestamp) in order to be able to sort stuff; • Parts of the system are now free to move independently: – They can evolve due to the low coupling; – Be available or not, depending on their needs, because there is no temporal coupling; • Parts…parts…parts…and parts
  • 22. Bounded Context • BCs, easily identified by/via the Ubiquitous Language perfectly map the concept of part or the one of transaction boundary; • Within the BC the level of consistency is expected to be much higher than cross BCs; • BCs can be isolated and should be able to live by their own; • BCs generally are a unit of deployment;
  • 23. MESSAGES We have async and distributed parts…but…how they talk to each other?
  • 24. asynchronous We cannot rely on RPC calls the other part is not guaranteed to be there when we need it.
  • 26. distributed We need an atomic piece of information we cannot rely on ordering we cannot rely on receiving the information at the same place (is distributed);
  • 28. non-coupled We need the message as small as possible The more the exchanged vocabulary is large the more coupling we have Changing the vocabulary is hard, think twice about it
  • 29. IT’S A LONG WAY TO THE TOP IF YOU WANNA ROCK & ROLL… Do we really need to go to that root?
  • 31. Context & Requirements • Requirements set the boundary of the problem; – A problem not identified by a requirement does not exists; • Much more: requirements set the boundary of the solution; – A solution is valid when within the requirements otherwise it is over-engineering;
  • 32. DO WE NEED TO SCALE-OUT? The question should be…
  • 33. “keep it simple” • redesign the system from scratch; • move everything to RavenDB; • Introduce Elastic Search; • Add a Redis cache on Linux • 6 months, £££££ • can fail • Replace disks on the SQL machine with 2 fast SSD(s) • 1hr, £ • Observe the next 6 months :-) A “small” e-commerce based on the traditional 3-layer architecture: Pages response time is slow;
  • 34. “re-design” • Single batch per request • Trying to scale this fails • Multi-batch per request • Re-designing the system guarantees to scale A delivery system (e.g. your favorite retailer): want to increase the amount of order handled per unit of time
  • 35. A new hope <cit.> Moving away from a traditional architecture brings a lot of challenges to the table: • Everything will be async; • Non availability of a system must be managed; • Handling async failures; • Handling of synchronized access to shared resources; • How to correlate messages; • How to handle versioning and upgrades; • And more…
  • 37. Concepts • Message – An atomic piece of information that has a semantical meaning in the business; • Component – Something that can handle a message; • Service – A set of components grouped by context; • Endpoint – A set of services grouped by: • SLA(s); • Infrastructure concerns; • Etc..;
  • 38. Concepts #2 • Command: A message that semantically identifies something to be done (imperative): – "CreateNewUser"; • Event: A message that semantically identifies something happened and immutable (past): – "NewUserCreated"; • Subscription: The notion that an endpoint is interested in an event;
  • 39. DEMO
  • 40. Transport • Transport(s): The technology used to connect systems and transport the message: – MSMQ – RabbitMQ – SQL Server – Azure ServiceBus & Azure Queues • Serialization: the way messages are"serialized" in order to be transported on the choosen transport; – it is transparent to the transport;
  • 41. Advanced Concepts • Saga: An orchestrator for a long running workflow, with the ability to store the saga state across requests and handling concurrency; • Timeout: The way a Saga can take autonomous decisions; • Retries: First level and Second level retry engine to handle transient failures; • Error & Audit: error and auditing management
  • 42. SCALE OUT & HIGH AVAILABILITY In an eventual consistent world
  • 43. Mail & Mail Servers When we send an email message: • Our relation with the mail server is consistent? Yes; • Cross-servers relation is consistent? Yes; • Relationship between the last server and the recipient is consistent? Yes;
  • 44. The entire system is consistent? No But we have some guarantees: • Every single hop/node/BC is consistent; • If something along the way fails we will have, with the same logic, an information back that our request is failed or succeeded; • Do we need distributed transactions? No :-) • The message is fully enough to guarantee consistency, in the long run.
  • 45. DEMO
  • 46. Publish/Subscribe • Request/Response is generally considered an anti-pattern; • Events are the easiest way to drive the world: – SomethingHappened; • DoSomethingToMoveOn; • Lots of possible listener and lots of possible publishers: – CorrelationID
  • 47. DEMO