Microservices
An introduction
Microservice as a concept
What is a microservice?
What is a microservice?
What is a microservice?
What is a microservice?
a service that fit in one page of code...
What is a microservice?
a service that fit in one page of code...
a service that represents a bounded context of a system domain...
What is a microservice?
a service that fit in one page of code...
a service that represents a bounded context of a system domain...
a fine grained service...
What is a microservice?
a service that fit in one page of code...
a service that represents a bounded context of a system domain...
a fine grained service...
a very small service...
What is a microservice?
Microservice in software
architecture / design
And the microservice architectural style?
And the microservice architectural style?
"The microservice architectural style is an approach to developing a
single application as a suite of small services, each running in its own
process and communicating with lightweight mechanisms, often an
HTTP resource API"
And the microservice architectural style?
And the microservice architectural style?
Why do we need Microservices?
Why? A Background - Monolithic apps
UI DB
Why? A Background
● Monolithic applications: One large application to handle everything !
● Good aspects:
○ easy communication between components
○ easy to develop
Why? A Background
● Monolithic applications: One large application to handle everything !
● Good aspects:
○ easy communication between components
○ easy to develop
● Bad aspects:
○ hard coupling between components
○ long term commitment to a technology stack
○ you need to escalate the entire block
○ component crash affects the entire application
UI DB
Monolithic apps - Error handling
UI DB
Monolithic apps - Error handling
UI DB
load
balance
Monolithic apps - Scalability
UI DB
Monolithic apps - Scalability
How can I address these issues?
UI DB
What if we divide to conquer?
UI DB
What if we divide to conquer?
UI DB
What if we divide to conquer?
UI DB
What if we divide to conquer?
UI DB
What if we divide to conquer?
UI DB
What if we divide to conquer?
Microservices
● Good aspects:
○ decoupled services/components grouped by domain bounded contexts
○ error tolerance can be achieved more easily
○ data can be distributed through the components too
○ each component can use a different technology stack
UI DB
Customers Payments
Products
LogisticsCustomer Care
Splitting into domain bounded contexts
UI DB
Customers
Customer Care
Products Payments
Logistics
Splitting into domain bounded contexts
UI
Payments
DB
Customers
Customer Care
Products
Payments
Logistics
Products
DB
Logistics
DB
...
Splitting the data
UI
Payments
DB
Customers
Customer Care
Products
Payments
Logistics
Products
DB
Logistics
DB
...
Splitting the technology stack
UI
Payments
DB
Customers
Customer Care
Products
Payments
Logistics
Products
DB
Logistics
DB
...
Splitting the technology stack
Microservices
● Good aspects:
○ decoupled services/components grouped by domain boundaries
○ error tolerance can be achieved more easily
○ data can be distributed through the components too
○ each component can use a different technology stack
● Bad aspects:
○ the overall complexity of the app increases
○ it's difficult to move responsibilities across components through refactorings
○ integration testing may be hard
○ component communications have more latency and need to have a well defined interface
UI
Payments
DB
Customers
Customer Care
Products
Payments
Logistics
Products
DB
Logistics
DB
...
Distributed computing - Keep in mind !
1. CAP Theorem (Consistency, Availability and Partition Tolerance)
2. Distributed System Fallacies
○ 1. The network is reliable.
○ 2. Latency is zero.
○ 3. Bandwidth is infinite.
○ 4. The network is secure.
○ 5. Topology doesn't change.
○ 6. There is one administrator.
○ 7. Transport cost is zero.
○ 8. The network is homogeneous.
Final considerations / suggestions
● Start as a monolith app, organizing the code in modules
● Keep refactoring the code to keep the module cohesion
● While the first monolith problems begin to appear, split into small services
● Be aware that microservices isn't a silver bullet
○ When you embrace this approach you also embrace a lot of distributed systems challenges and benefits
Hmm… And do you really applied
this concept?
Our first app that started as a
monolith !
Our newest app structured using the
microservice architecture !
Thanks !
danielbpdias@gmail.com
https://github.com/danielbdias
https://www.slideshare.net/DanielDias10
https://github.com/danielbdias/nodebr-meetup-ddd-demo

Microservices: an introduction