how to split your system into microservices

68
How to Split Your System into Microservices Eberhard Wolff @ewolff Fellow

Upload: eberhard-wolff

Post on 06-Jan-2017

336 views

Category:

Software


5 download

TRANSCRIPT

Page 1: How to Split Your System into Microservices

How to Split Your System into

MicroservicesEberhard Wolff

@ewolffFellow

Page 2: How to Split Your System into Microservices

http://continuous-delivery-buch.de/

Page 3: How to Split Your System into Microservices

http://microservices-buch.de/ http://microservices-book.com/

Page 4: How to Split Your System into Microservices

http://microservices-book.com/primer.html

FREE!!!!

Page 5: How to Split Your System into Microservices
Page 6: How to Split Your System into Microservices

Microservices: Definition

> No consistent definition

> Microservices are modules

> Independent deployment units

> E.g. Docker container

> Microservice owned by one team

Page 7: How to Split Your System into Microservices

Microservices: Definition

Server /Container

Server / Container

MicroService

MicroService

Page 8: How to Split Your System into Microservices

Microservices aim for decoupling

Page 9: How to Split Your System into Microservices

Why is the Split so Important?

> Microservices implement a part of the logic

> Allow isolated development of features

> …and independent teams

> If split is wrong, you won’t achieve goals.

> …and there is just more complexity.

> But there are even more goals!

Page 10: How to Split Your System into Microservices

Why Microservices?

Strong Modularization

Scaling Agile

Sustainable development Replaceable ServicesContinuous Delivery

Free choice of technology

Handle Legacy efficient

Independent Scaling

Robustness

Small teams develop and deploy independently

Add services – not code

Small Services

Failure limited to single Microservice

Page 11: How to Split Your System into Microservices

Why Microservices?Scaling Agile

Sustainable development

Continuous Delivery

Free choice of technology

Handle Legacy efficient

Independent Scaling

Robustness

Organization

DeploymentUnits

Technology

Page 12: How to Split Your System into Microservices

There are many reasons for

microservices.

Page 13: How to Split Your System into Microservices

There are many scenarios for

microservices.

Page 14: How to Split Your System into Microservices

Scenario and reason influence the split.

Page 15: How to Split Your System into Microservices

Bounded Context

Page 16: How to Split Your System into Microservices
Page 17: How to Split Your System into Microservices

UBIQUITOUSLANGUAGE

VALUEOBJECT

ENTITY

Page 18: How to Split Your System into Microservices

Address

VALUEOBJECT

ENTITYor

Page 19: How to Split Your System into Microservices

529 pages

Page 20: How to Split Your System into Microservices

529 pagesPart IV

Page 21: How to Split Your System into Microservices

529 pagesPart IVChapter 14

Page 22: How to Split Your System into Microservices

A domain modelis only usefulin a BOUNDED CONTEXT.

Page 23: How to Split Your System into Microservices

There is nouniversal data modelin a large system.

Page 24: How to Split Your System into Microservices

Addressfor a customer

VALUEOBJECT

ENTITYor

Page 25: How to Split Your System into Microservices

Addressfor calculating the

drones’ routes

VALUEOBJECT

ENTITYor

Page 26: How to Split Your System into Microservices

Microservice =Bounded Context

Page 27: How to Split Your System into Microservices

Create some Bounded Contexts!

Sir, yes, sir!

Page 28: How to Split Your System into Microservices
Page 29: How to Split Your System into Microservices
Page 30: How to Split Your System into Microservices
Page 31: How to Split Your System into Microservices

Why would you build a universal data model if that is

neither possible nor useful??

Page 32: How to Split Your System into Microservices

Bounded Context: Challenge

> Not a way to design a great architecture

> …but consequence of good domain architecture

> i.e. clearly separated domains will lead to separated BOUNDED CONTEXTS

> …containing logic and data

> How can you find BOUNDED CONTEXTS?

Page 33: How to Split Your System into Microservices

Bounded Context: Challenge

> Coarse-grained

> Ideal: implement a functionality in one unit

> Ideal: Independence

> Might have relationships

> …limiting independence

Page 34: How to Split Your System into Microservices

Divide by Use Cases

> Microservice should implement a use case

> …ideally without calling other microservices

> Divide use cases among microservices

> …then decide about the BOUNDED CONTEXT

Page 35: How to Split Your System into Microservices

BrowsingRegistration

Creating Microservices

User Registration Search Products by Keywords

Browse Products by Category

Checkout

Payment

Define ShipmentUpdate Profile

Basic customerdata

Preferences

Recommendations

Billing address

Paymentinformation

All these services have data about the customer!!

Page 36: How to Split Your System into Microservices

Bounded ContextScaling Agile

Sustainable development

Continuous Delivery

Free choice of technology

Handle Legacy efficient

Independent Scaling

Robustness

Organization

DeploymentUnits

Technology

Page 37: How to Split Your System into Microservices

What about other scenarios??

Page 38: How to Split Your System into Microservices

Existing Architecture

Product Customer Warehouse

ProductService

CustomerService

WarehouseService

iOS Android PoS Web

Page 39: How to Split Your System into Microservices

Let’s create some Bounded Contexts!

Page 40: How to Split Your System into Microservices

Existing Architecture

Product Customer Warehouse

ProductService

CustomerService

WarehouseService

iOS Android PoS Web

Browsing�

� �

�� �

���

Page 41: How to Split Your System into Microservices

Bounded Contexts

> Browsing distributed in many artifacts

> Change to Browsing might influence all of them

> …or not

> BOUNDED CONTEXTS would be desirable

Page 42: How to Split Your System into Microservices

Migrate to Bounded Context

Product Customer Warehouse

ProductService

CustomerService

WarehouseService

iOS Android PoS Web

Browsing�

� �

�� �

���

Browsing

Page 43: How to Split Your System into Microservices

IntroducingBounded Contexts

> …would change the architecture completely

> …might be very hard

> …and risky

> Is it worth it?

> Is it even doable?

> Might also change the organization

Page 44: How to Split Your System into Microservices

Add services

Product Customer Warehouse

ProductService

CustomerService

WarehouseService

iOS Android PoS Web

Page 45: How to Split Your System into Microservices

Add services

Product Customer Warehouse

ProductService

CustomerService

WarehouseService

iOS Android PoS Web

News-letter

Web

Page 46: How to Split Your System into Microservices

Add Service

> Might replace the old system stepwise

> Immediate benefits

> Low risk

> Major reason for microservices

Page 47: How to Split Your System into Microservices

Cut existing services

Product Customer Warehouse

ProductService

CustomerService

WarehouseService

iOS Android PoS Web

Page 48: How to Split Your System into Microservices

Existing ArchitectureScaling Agile

Sustainable development

Continuous Delivery

Free choice of technology

Handle Legacy efficient

Independent Scaling

Robustness

Organization

DeploymentUnits

Technology

Page 49: How to Split Your System into Microservices

Existing Architecture

> ...has an impact on the target architecture

> What good is an architecture you cannot migrate into?

> Might overrule everything else

> Even BOUNDED CONTEXT

Page 50: How to Split Your System into Microservices

BrowsingRegistration

External Systems

User Registration Search Products by Keywords

Browse Products by Category

Checkout

Payment

Define ShipmentUpdate Profile Browse Products by Category

PaymentProvider

LogisticPartner

Page 51: How to Split Your System into Microservices

BrowsingRegistration

External Systems

User Registration Search Products by Keywords

Browse Products by Category

Checkout

Update Profile Browse Products by Category

PaymentProvider

LogisticPartner

Payment Shipping

Page 52: How to Split Your System into Microservices

External Systems> Limit integration for each external system to

one Microservice

> External system might belong to a domain

> …or BOUNDED CONTEXT

> ...or not

> Simplifies integration

> Easier to achieve robustness

Page 53: How to Split Your System into Microservices

External SystemsScaling Agile

Sustainable development

Continuous Delivery

Free choice of technology

Handle Legacy efficient

Independent Scaling

Robustness

Organization

DeploymentUnits

Technology

Page 54: How to Split Your System into Microservices

We expect a lot more

registrations!

Page 55: How to Split Your System into Microservices

BrowsingRegistration

External Systems

User Registration Search Products by Keywords

Browse Products by Category

Checkout

Payment

Define ShipmentUpdate Profile Browse Products by Category

Page 56: How to Split Your System into Microservices

BrowsingRegistration

External Systems

Search Products by Keywords

Browse Products by Category

Checkout

Payment

Define ShipmentBrowse Products by Category

Regis-tration

UpdateProfile

Page 57: How to Split Your System into Microservices

Technical Reasons

> Independent scalability is just one technical reason

> There are many more

> Might be OK to share database in this scenario

> Might even split read and write

Page 58: How to Split Your System into Microservices

CQRS

> Command – Query Responsibility Segregation

> Commands change data

> Query provide data

> Implement in separate microservices

Page 59: How to Split Your System into Microservices

CommandQueue

Command

Command

Command

CommandHandler

QueryHandler

CommandStore

Database Read Replica

Page 60: How to Split Your System into Microservices

Technical ReasonsScaling Agile

Sustainable development

Continuous Delivery

Free choice of technology

Handle Legacy efficient

Independent Scaling

Robustness

Organization

DeploymentUnits

Technology

Page 61: How to Split Your System into Microservices

Registration

Requirements

Browsing Checkout

Marketing Sales Fulfillment Finance

Page 62: How to Split Your System into Microservices

Requirements

> One microservice should implement one stream of requirements

> Otherwise: coordinate priorities

> …and therefore less independence

Page 63: How to Split Your System into Microservices

Registration

Requirements

Browsing Payment

Marketing Sales FulfillmentFinance

Shipping

Page 64: How to Split Your System into Microservices

RequirementsScaling Agile

Sustainable development

Continuous Delivery

Free choice of technology

Handle Legacy efficient

Independent Scaling

Robustness

Organization

DeploymentUnits

Technology

Page 65: How to Split Your System into Microservices

Conclusion

Page 66: How to Split Your System into Microservices

Microservices= Bounded Context

Page 67: How to Split Your System into Microservices

Split

BoundedContext

Migration

ExternalSystems

TechnicalReasons

Require-ments

Page 68: How to Split Your System into Microservices

EMail [email protected] to get:Slides+ Microservices Primer+ Sample Microservices Book+ Sample of Continuous Delivery Book

Powered by Amazon Lambda & Microservices