NFJS 2015 Migrating to Microservices - SDD...

53
Software Design and Development Conference 2015 Mark Richards Hands-on Software Architect Author of Enterprise Messaging Video Series (O’Reilly) Author of Java Message Service 2nd Edition (O’Reilly) Co-author of Software Architecture Fundamentals Video Series (O'Reilly) Migrating to a Microservices Architecture

Transcript of NFJS 2015 Migrating to Microservices - SDD...

Page 1: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

Software Design and Development Conference 2015

Mark RichardsHands-on Software ArchitectAuthor of Enterprise Messaging Video Series (O’Reilly)Author of Java Message Service 2nd Edition (O’Reilly)Co-author of Software Architecture Fundamentals Video Series (O'Reilly)

Migrating to a Microservices Architecture

Page 2: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

Software Architecture Fundamentals Video Series Enterprise Messaging Video Series

Page 3: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

microservices architecture elements

agenda

migration challengesmicroservices hybrid models

migration techniques

Page 4: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

Microservices Architecture Elements

Page 5: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

microservices elements

api layer

client requests client requests client requests

Page 6: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

distributed architecture

api layer

client requests client requests client requests

microservices elements

Page 7: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

separately deployed units

api layer

client requests client requests client requests

microservices elements

Page 8: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

service component

api layer

client requests client requests client requests

microservices elements

Page 9: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

bounded context

api layer

client requests client requests client requests

microservices elements

Page 10: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

microservices hybrid models

Page 11: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

databasescope

service granularity

integration hub

microservices hybrids

Page 12: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

api layer

client requests client requests client requests

microservices hybridsservice granularity

Page 13: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

user interface layer

client requests client requests client requests

microservices hybridsservice granularity

Page 14: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

single-purpose micro-service to "portion of the application" macro-service

service granularity

macro-services resolves orchestration and transactional issues

microservices hybrids

allows for complex business processing within a service context

-

Page 15: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

single-purpose micro-service to "portion of the application" macro-service

service granularity

services become harder to develop and testdeployment pipeline requires more planningchange control becomes more difficult

microservices hybrids

-

Page 16: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

microservices hybridsdatabase scope

api layer

client requests client requests client requests

Page 17: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

microservices hybridsdatabase scope

user interface layer

client requests client requests client requests

Page 18: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

single-purpose service-based database to globally shared application database

reduces service orchestration and contract dependencies

microservices hybridsdatabase scope

improves performance due to fewer remote callsrefactoring entire database may not be feasible or possible

-

Page 19: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

single-purpose service-based database to globally shared application database

looser bounded context of servicestighter service coupling based on schema

microservices hybridsdatabase scope

schema changes become expensive and difficult

-

Page 20: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

microservices hybridsintegration hub

api layer

client requests client requests client requests

lightweight message broker

Page 21: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

user interface layer

client requests client requests client requests

microservices hybridsintegration hub

integration hub / middleware

Page 22: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

lightweight message broker to heavier integration hub

microservices hybridsintegration hub

allows for transformation of contract differences allows for non-transactional orchestration of servicesallows for protocol-agnostic heterogeneous interoperabilityallows for common processing logic across all services

-

Page 23: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

lightweight message broker to heavier integration hub

decrease in overall performanceadded complexity and costincreased need for governancedeployment pipeline requires much more planning

microservices hybridsintegration hub

services become harder to develop and test-

Page 24: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

microservices migration challenges

Page 25: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

migration challenges

distributed architecture and remote service issues

service component granularity and transactional boundaries

shared services, modules, and object hierarchies

Page 26: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

distributed architecture issues

contract creation, maintenance, versioning, and coordination

migration challenges

Page 27: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

distributed architecture issues

remote process responsiveness and server availability

migration challenges

Page 28: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

distributed architecture issuesmigration challenges

slower service invocations due to remote access protocols and distributed

components

Page 29: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

distributed architecture issuesmigration challenges

atomic transactions and transaction scope

Page 30: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

distributed architecture issuesmigration challenges

authenticating and authorizing remote connections and service invocations

Page 31: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

distributed architecture issuesmigration challenges

distributed logging facilities to provide a holistic view of a transaction

Page 32: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

service component granularitymigration challenges

module module module module module

module module module module module

module module module module module

module module module module module

coarse-grained service components address transactional issues but may not achieve your desired goals

Page 33: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

service component granularitymigration challenges

module module module module module

module module module module module

module module module module module

module module module module module

fine-grained service components may lead to too much orchestration and inter-dependency between service components

Page 34: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

module module module module module

module module module module module

module module module module module

module module module module module

business functionality groupingstransactional boundariesdeployment goalsscalability needs

service component granularitymigration challenges

Page 35: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

shared components and object hierarchiesmigration challenges

module module module

abstract

abstract

shared

inheritance structure

shared modules (utility and service classes)

Page 36: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

shared components and object hierarchiesmigration challenges

module module module

abstract

abstract

shared

inheritance structure

shared modules (utility and service classes)

LIB

LIB

Page 37: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

modulemodule module module

module

module

module module

modules can be split....

shared components and object hierarchiesmigration challenges

Page 38: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

module module

module

module

or moved into a shared library or jar file...

module

shared components and object hierarchiesmigration challenges

Page 39: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

or replicated in each service component

module module

module

module

module module

shared components and object hierarchiesmigration challenges

Page 40: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

shared lib or jar file

user interface layer

application business layer

module module

modulemodule module

module module

module

migration challengesshared components and object hierarchies

Page 41: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

migration challengesshared component techniques

jar /dll (compile or runtime)

LIB

shared library (compile time)

code replication remote services

Page 42: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

migration techniques

Page 43: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

playbook approach

current state iteration 1 iteration 2 iteration 3

each iteration should clearly illustrate the changes to the architecture each step along the way

migration techniques

Page 44: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

playbook approach

current state iteration 1 iteration 2 iteration 3

identify the purpose behind each iteration

identify the technical and business value for each iteration

keep iterations as small as possible while still providing enough technical and business value

try to minimize "staging iterations"

migration techniques

Page 45: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

form a logical or physical separation between the user interface layer and the business layer

user interface separationmigration techniques

Page 46: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

application business layer

user interface layer

CustomerData

AccountData

TradeData

ReportData

IDataModel

CustomerUI

AppClient

AccountUI TradeUI ReportUI

Customer Account Trade Report

migration techniques

Page 47: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

application business layer

user interface layer CustomerUI

AppClient

AccountUI TradeUI ReportUI

Customer Account Trade Report

model.jar

model.jarCustomerData

AccountData

TradeData

ReportData

IDataModel

migration techniques

Page 48: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

service migrationmigration techniques

Page 49: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

application business layer

user interface layer CustomerUI

AppClient

AccountUI TradeUI ReportUI

Customer Account Trade Report

model.jar

model.jar

migration techniques

Page 50: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

application business layer

user interface layer CustomerUI

AppClient

AccountUI TradeUI ReportUI

ReportTrade

model.jar

model.jar

Customer Account

model.jar

CustomerListener

Customer Account

migration techniques

Page 51: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

application business layer

user interface layer CustomerUI

AppClient

AccountUI TradeUI ReportUI

ReportTrade

model.jar

model.jar

Customer Account

model.jar

CustomerListener

migration techniques

Page 52: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

user interface layer CustomerUI

AppClient

AccountUI TradeUI ReportUImodel.jar

Customer Account

CustomerListener

model.jar

trade

TradeListener

model.jar

Report

ReportListener

model.jar

migration techniques

Page 53: NFJS 2015 Migrating to Microservices - SDD Conferencesddconf.com/brands/sdd/library/Migrating_To_Microservices.pdf · refactoring entire database may not be feasible or possible-single-purpose

Migrating to a Microservices Architecture

Independent  ConsultantHands-­‐on  So*ware  ArchitectPublished  Author  /  Conference  Speaker

Mark  Richards

h<p://www.wmrichards.comh<p://www.linkedin.com/pub/mark-­‐richards/0/121/5b9