SlideShare a Scribd company logo
Microservice Architecture
Design Principles
Sanjoy Roy
sanjoykr78@gmail.com
Let’s take the inspiration from biological
cells before talking about Microservice:
• They are small and single purpose
• They are many of them but they work in
concert with one another
• Each cell is able to respond to its
environment
• They communicate with each other using
messages
• They can replicate
• They keep outside out
• Death is natural and expected
Microservice architecture
advocates creating a system from
a collection of small, isolated
services, each of which owns their
data, and is independently
isolated, scalable and resilient to
failure.
Divide and Conquer
A divide and conquer algorithm works by
recursively breaking down a problem into two
or more sub-problems of the same (or
related) type (divide), until these become
simple enough to be solved directly
(conquer). The solutions to the sub-problems
are then combined to give a solution to the
original problem.
In Microservice Architecture we use
Divide and Conquer:
the decomposition of the system into
discrete and isolated subsystems
communicating over well-defined
protocols.
Microservice
Single Responsibility Replaceable
Organized around business
capabilities
Single Responsibility Principle
Single Responsibility Principle (SRP)
states that a class or component should
“only have one reason to change.”
Do One Thing, and Do It Well
This is the Unix philosophy: Write
programs that do one thing and do it well.
Write programs to work together.
—Doug McIlroy
“Micro” should refer to scope of
responsibility.
A service has only one single reason to
exist and should provide a single
composable piece of functionality.
A service should do one thing
and do it well.
Focus should be on business capability.
What about state?
Microservices are often stateful
entities:
they encapsulate state and behavior.
Product
Service
Customer
Service
Order
Service
Payment
Service
Search
Service
DB
This is still a monolith.
Oracle Couchbase Oracle
Customer
Service
Customer
Service
Customer
Service
Customer
Service
Product
Service
Product
Service
Product
Service
Product
Service
Order
Service
Order
Service
Order
Service
Bounded Context Bounded Context Bounded Context
A microservice owns its data.
Business Capability Business Capability Business Capability
Decentralized Data Management
• Each microservice manages it’s own database: either different
instances of same database technology or completely different
database system (polyglot persistence)
• Eventual consistency
Microservices encapsulate state and behaviour.
Model each service as a Bounded Context.
Each service usually defines its own domain, each with
its own Ubiquitous Language.
State
(Data)
Behaviour
(Business Rules)
Business Capability
Search
Service
Search
Service
Search
Cache Couchbase
Product
Service
Product
Service
Product
Service
Product
Service
Bounded Context
Bounded Context
Client
Business Capability Business Capability
Isolation
Isolation is a prerequisite for resilience and elasticity
Embrace Share Nothing Architecture
Failure Isolation (Bulkheading)
Isolation between services makes it natural to adopt Continuous
Delivery
Isolation also makes it easier to scale each service, as well as
allowing them to be monitored, debugged and tested
independently
Isolation is a prerequisite for autonomy
An autonomous service can only promise its own behaviour by
publishing its protocol/API.
All information needed to resolve a conflict or to repair under
failure scenarios are available within the service itself, removing
the need for communication and coordination.
APIs need to be well-defined and composable.
Autonomous Service
Communicate through APIs
Service B
Couchbase
Service A
Oracle
API
invoke expose
Contract
Shared
understanding
API Client/Server Guidelines
 REST level-3 with HAL+json
 Use proper HTTP techniques
 Base design on application states and transitions
 Forward compatibility over versioning
 Drive documentation from code
 Don’t write smart clients
Autonomy through Messaging
Service A
(Pub)
Service B
(Sub)
Service C
(Sub)
Message Bus1 2 3
• Only publish business events and IDs – avoid mutable
data
• Implement proper error handling
• Beware of added complexity
Message Publisher Guidelines
• Cater for duplicate message delivery through
idempotency
• Don’t rely on ordering
• 1C late-commit pattern over 2PC
• Implement proper error handling
• Beware of added complexity
Message Receiver Guidelines
Microservice benefits
• Strong module boundaries
• Independent deployment
• Technology diversity
• Failure isolation
• Improves time to market
• Reduced cost of change
and costs
• Distribution
• Eventual consistency
• Operational complexity
General Microservice Architecture Principles
• Small and focused on a specific business capability
• Eventual consistency
• availability is more important than global and instant consistency
• Polyglot persistence
• Pick most appropriate data and consistency model
• Async communication over sync
• Failure resilient
• Avoid SPOFs
Thank you

More Related Content

What's hot (20)

PDF
Microservice Architecture
tyrantbrian
 
PPTX
Introduction to microservices
Paulo Gandra de Sousa
 
PPTX
Monoliths and Microservices
Bozhidar Bozhanov
 
PPTX
Introduction to Microservices
Roger van de Kimmenade
 
PPTX
Introduction To Microservices
Lalit Kale
 
PDF
Why Microservice
Kelvin Yeung
 
PPTX
Micro services Architecture
Araf Karsh Hamid
 
PPTX
Microservice vs. Monolithic Architecture
Paul Mooney
 
PDF
Microservice Architecture
Nguyen Tung
 
PPTX
Microservices Architecture & Testing Strategies
Araf Karsh Hamid
 
PPSX
Microservices Testing Strategies JUnit Cucumber Mockito Pact
Araf Karsh Hamid
 
PPTX
Saga about distributed business transactions in microservices world
Mikalai Alimenkou
 
PPTX
02 api gateway
Janani Velmurugan
 
PPTX
Microservices
SmartBear
 
PDF
Microservice architecture
Žilvinas Kuusas
 
PDF
APIs in a Microservice Architecture
WSO2
 
PPTX
Introduction to microservices
Anil Allewar
 
PDF
Understanding MicroSERVICE Architecture with Java & Spring Boot
Kashif Ali Siddiqui
 
DOCX
Micro services vs Monolith Architecture
MohamedElGohary71
 
PDF
Designing loosely coupled services
Chris Richardson
 
Microservice Architecture
tyrantbrian
 
Introduction to microservices
Paulo Gandra de Sousa
 
Monoliths and Microservices
Bozhidar Bozhanov
 
Introduction to Microservices
Roger van de Kimmenade
 
Introduction To Microservices
Lalit Kale
 
Why Microservice
Kelvin Yeung
 
Micro services Architecture
Araf Karsh Hamid
 
Microservice vs. Monolithic Architecture
Paul Mooney
 
Microservice Architecture
Nguyen Tung
 
Microservices Architecture & Testing Strategies
Araf Karsh Hamid
 
Microservices Testing Strategies JUnit Cucumber Mockito Pact
Araf Karsh Hamid
 
Saga about distributed business transactions in microservices world
Mikalai Alimenkou
 
02 api gateway
Janani Velmurugan
 
Microservices
SmartBear
 
Microservice architecture
Žilvinas Kuusas
 
APIs in a Microservice Architecture
WSO2
 
Introduction to microservices
Anil Allewar
 
Understanding MicroSERVICE Architecture with Java & Spring Boot
Kashif Ali Siddiqui
 
Micro services vs Monolith Architecture
MohamedElGohary71
 
Designing loosely coupled services
Chris Richardson
 

Similar to Microservice architecture design principles (20)

PDF
MuCon 2015 - Microservices in Integration Architecture
Kim Clark
 
PPTX
Software Architectures, Week 3 - Microservice-based Architectures
Angelos Kapsimanis
 
PPTX
Magento Developer Talk. Microservice Architecture and Actor Model
Igor Miniailo
 
PDF
CWIN17 Utrecht / cg u services - frank van der wal
Capgemini
 
PDF
Containing your microservice sprawl
LibbySchulze
 
PPTX
Alex Thissen (Xpirit) - Een verschuiving in architectuur: op weg naar microse...
AFAS Software
 
PPTX
Iot cloud service v2.0
Vinod Wilson
 
PPTX
Microsoft Microservices
Chase Aucoin
 
PPTX
Microservice Architecture Software Architecture Microservice Design Pattern
jeetendra mandal
 
PPTX
Over view of software artitecture
ABDEL RAHMAN KARIM
 
PPTX
Microservice's in detailed
Mohammed Fazuluddin
 
PDF
Microservices: Where do they fit within a rapidly evolving integration archit...
Kim Clark
 
PPTX
Microservices Architecture & Testing Strategies
Araf Karsh Hamid
 
PDF
Pitfalls & Challenges Faced During a Microservices Architecture Implementation
Cognizant
 
PPTX
Microservices architecture
Faren faren
 
PPTX
Best Practices Building Cloud Scale Apps with Microservices
Jim (张建军) Zhang
 
PPTX
A Microservice Journey
Christian Posta
 
PDF
DEVNET-1142 Decomposing Monolithic Applications to Microservices
Cisco DevNet
 
PPTX
cloud-computing presentation using various methods
annupriya1295
 
PDF
Microservices
Thiago Lopes
 
MuCon 2015 - Microservices in Integration Architecture
Kim Clark
 
Software Architectures, Week 3 - Microservice-based Architectures
Angelos Kapsimanis
 
Magento Developer Talk. Microservice Architecture and Actor Model
Igor Miniailo
 
CWIN17 Utrecht / cg u services - frank van der wal
Capgemini
 
Containing your microservice sprawl
LibbySchulze
 
Alex Thissen (Xpirit) - Een verschuiving in architectuur: op weg naar microse...
AFAS Software
 
Iot cloud service v2.0
Vinod Wilson
 
Microsoft Microservices
Chase Aucoin
 
Microservice Architecture Software Architecture Microservice Design Pattern
jeetendra mandal
 
Over view of software artitecture
ABDEL RAHMAN KARIM
 
Microservice's in detailed
Mohammed Fazuluddin
 
Microservices: Where do they fit within a rapidly evolving integration archit...
Kim Clark
 
Microservices Architecture & Testing Strategies
Araf Karsh Hamid
 
Pitfalls & Challenges Faced During a Microservices Architecture Implementation
Cognizant
 
Microservices architecture
Faren faren
 
Best Practices Building Cloud Scale Apps with Microservices
Jim (张建军) Zhang
 
A Microservice Journey
Christian Posta
 
DEVNET-1142 Decomposing Monolithic Applications to Microservices
Cisco DevNet
 
cloud-computing presentation using various methods
annupriya1295
 
Microservices
Thiago Lopes
 
Ad

More from Sanjoy Kumar Roy (8)

PPTX
Arch CoP - Domain Driven Design.pptx
Sanjoy Kumar Roy
 
PPTX
Visualizing Software Architecture Effectively in Service Description
Sanjoy Kumar Roy
 
PPTX
Hypermedia API and how to document it effectively
Sanjoy Kumar Roy
 
PPTX
An introduction to OAuth 2
Sanjoy Kumar Roy
 
PPTX
Transaction
Sanjoy Kumar Roy
 
PPTX
Lessons learned in developing an agile architecture to reward our customers.
Sanjoy Kumar Roy
 
PPTX
An introduction to G1 collector for busy developers
Sanjoy Kumar Roy
 
PPT
Major Java 8 features
Sanjoy Kumar Roy
 
Arch CoP - Domain Driven Design.pptx
Sanjoy Kumar Roy
 
Visualizing Software Architecture Effectively in Service Description
Sanjoy Kumar Roy
 
Hypermedia API and how to document it effectively
Sanjoy Kumar Roy
 
An introduction to OAuth 2
Sanjoy Kumar Roy
 
Transaction
Sanjoy Kumar Roy
 
Lessons learned in developing an agile architecture to reward our customers.
Sanjoy Kumar Roy
 
An introduction to G1 collector for busy developers
Sanjoy Kumar Roy
 
Major Java 8 features
Sanjoy Kumar Roy
 
Ad

Recently uploaded (20)

PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PDF
Market Insight : ETH Dominance Returns
CIFDAQ
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
PDF
Generative AI vs Predictive AI-The Ultimate Comparison Guide
Lily Clark
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PDF
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PPTX
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PDF
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
PDF
TrustArc Webinar - Navigating Data Privacy in LATAM: Laws, Trends, and Compli...
TrustArc
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PPTX
Farrell_Programming Logic and Design slides_10e_ch02_PowerPoint.pptx
bashnahara11
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
Market Insight : ETH Dominance Returns
CIFDAQ
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
Generative AI vs Predictive AI-The Ultimate Comparison Guide
Lily Clark
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
TrustArc Webinar - Navigating Data Privacy in LATAM: Laws, Trends, and Compli...
TrustArc
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Farrell_Programming Logic and Design slides_10e_ch02_PowerPoint.pptx
bashnahara11
 

Microservice architecture design principles