Preliminary investment required before refactoring your monolith into microservices, and a series of steps, recipes and patterns to help you succeed when refactoring your application & your data into a microservices-style architecture.
10. –WernerVogels
“For us service orientation means encapsulating the
data with the business logic that operates on the data,
with the only access through a published service
interface. No direct database access is allowed from
outside the service, and there’s no data sharing
among the services.”
17. REFACTORYOUR DATA
• Domain-Driven Design
Customers
Products OrdersCategories
Customers
Orders
Tickets Assignee
Address
Bounded Context
Bounded Context
Microservices is about boundaries and so is DDD.
18. REFACTORYOUR DATA
• Duplicate vs Pull
Order
Service
API
Email
Service
API
Payment
Service
API
Message
Broker
Pull
OrderOrder
Template
Publish
Subscribe
Publish
19. REFACTORYOUR DATA
id name email
1 Mark mark@email.com
2 John john@email.com
3 Siobhan siobhan@email.com
CUSTOMERS
id customer_id amount
1 2 125.33
2 3 77.81
ORDER
CREATE TABLE orders (
id INT PRIMARY KEY,
customer_id INT NOT NULL,
...
CONSTRAINT fk_inv_customer_id
FOREIGN KEY (customer_id)
REFERENCES customers (id)
ON DELETE CASCADE);
• Forget Relational Integrity
20. REFACTORYOUR DATA
id name email new_column
1 Mark mark@email.com
2 John john@email.com
3 Siobhan siobhan@email.co
m
ALTER TABLE ADD new_column VARCHAR(255);
Order
Service
API
[{
"id": 1,
"name": "Mark",
"email": "mark@email.com",
"new_column": "my default"
}, {
"id": 2,
...
}]
JSON
25. TAKE-AWAYS
• Start small, look at this as an iterative problem.
• There isn't one right answer.
• Easier to scale.
• Failure will always happen.
• Don't over refactor.