Building Microservice Architectures(Neal Ford)

Share Embed Donate


Short Description

f...

Description

BUILDING MICROSERVICE ARCHITECTURES @neal4d nealford.com

what problem de!nitions

characteristics

AGENDA

engineering

what problem de!nitions

characteristics

AGENDA

engineering

Conway’’s Law Conway “organizations which design systems ... are constrained to produce designs which are copies of the communication structures of these organizations” —Melvin Conway 

Organized Around Business Capabilities

The Inverse Conway Maneuver Domain/Architecture Isomorphism

Coupling Metrics

code artifact

afferent

 

efferent

x i t

X-Ray xray.inf.usi.ch/xray.php

Class Dependency

Package Dependency

Azureus Packages

Azureus Packages Filtered

Package level coupling from a real monolith

Attempting to generate class diagram crashed x-ray.

From a Real Monolith

Name withheld by request

Software architecture represents the tension between coupling & cohesion.

ACID versus BASE

BASE

ACID

!

! Atomic ! Consistent ! Isolated !

Durable

Basic Availability

! Soft-state ! Eventual

Consistency

As your system becomes more distributed, prefer BASE to ACID…

 …because CAP Theorem www.julianbrowne.com/article/viewer/brewers-cap-theorem Formal proof: http://lpd.ep!.ch/sgilbert/pubs/BrewersConjecture-SigAct.pdf 

# of users

http://highscalability.com/blog/2013/5/1/mytheric-brewer-on-why-banks-are-base-not-acidavailability.html http://www.eaipatterns.com/docs/IEEE_Software_Design_2PC.pdf 

what problem de!nitions

characteristics

AGENDA

engineering

What “Traditional” SOA Got Right Breaking monoliths into services Focus on integration over internal  coupling Prefer BASE to ACID

What “Traditional” SOA Missed Architecture is abstract until operationalized. Impact of Conway’s Law The folly of trying to build “Uber” services (Customer) Didn’t support easy change (ESB pattern)

support

!

Microservice is the "rst architectural style developed post-Continuous Delivery.

what problem de!nitions

characteristics

AGENDA

engineering

Monoliths vs. Microservices

user interface server-side DBA

Orders Shipping Catalog

Products, not Projects projects:

products: ‘s “You build it, you run it”

Smart Endpoints, Dumb Pipes

as decoupled & cohesive as possible inspired by Unix "lters/pipes transport: HTTP messaging over lightweight bus

Prefer Choreography to Orchestration

pack of enterprise architects

Consumer Driven Contracts

Because Conway’s Law! traditional SOA / ESB pattern

Consumer Driven Contracts http://martinfowler.com/articles/consumerDrivenContracts.html

Prefer REST over SOAP

SOAP = RPC REST is less brittle at integration points

Standardize on integration, not platform embrace polyglot solutions where sensible

too few languages/platforms

Building Microservices DESIGNINGFINE� GRAINED SYSTEMS

Standardize in the gaps between services - be ! exible about what happens inside the boxes SamNewman

too many languages/platforms

Standardize on integration, not platform

…but don’t go crazy Building Microservices DESIGNINGFINE� GRAINED SYSTEMS

Have one, two or maybe three ways of integrating, not 20. Sam Newman

Building Microservices DESIGNING FINE�GRAINED SYSTEMS

Pick some sensible conventions, and stick with them. SamNewman

explicit about coupling

engineering safety nets

forces coarserundisciplined coupling = mess grained coupling coupling dynamics become integration issues

Microservice architectures promote coupling from application to integration architecture.

Decentralized Data Management Building Microservices DESIGNING FINE�GRAINED SYSTEMS

 Avoid distributed transactions if at all possible SamNewman

ACID versus BASE

Decentralized Governance

Decentralized Governance

Decentralized Governance

Enterprise architects su# er from less pressure to make the correct choice(s) in microservice architectures.

Small, Single Responsibility small enough to "t in your head rewrite over maintain (10—1000 LOC)-ish / service

single responsibility 

How Big?

Standardize on integration, not platform partition along natural boundaries domain organizational

"nd

transactional 

a balance between standardization and free–for–all 

Partitioning by Existing Coupling

God Object : an object that knows too much or does too much

Asynchronicity return optimized for ranking/aggregation, not display

Prefer timely partial over slow complete

Traditional Monolith

Model

User Interface

CQRS Query Model

User Interface

Command Model

http://codebetter.com/gregyoung/2010/02/16/cqrs-task-based-uis-event-sourcing-agh/ 

Reporting Query Model

User Interface

Command Model

.

.

.

what problem de!nitions

characteristics

AGENDA

engineering

Design For Failure

clients must respond gracefully to provider failure aggressive monitoring: - business relevant - architectural - semantic

Monitoring

Building Microservices DESIGNING FINE�GRAINED SYSTEMS

You have to get much better at monitoring. SamNewman

Building Microservices DESIGNING FINE�GRAINED SYSTEMS

You are not a badass if you use an SSH Multiplexer! SamNewman

Aggregating Monitors Response Time

Response Time

Response Time

Aggregating Monitors

Building Microservices DESIGNING FINE�GRAINED SYSTEMS

Capture metrics, and logs, for each node, and aggregate them to get a rolled up picture. SamNewman

Synthetic Transactions

Building Microservices DESIGNING FINE�GRAINED SYSTEMS

Use synthetic transactions to test  production systems. SamNewman

Correlation IDs

ID: 123

ID: 123

ID: 123 Building Microservices DESIGNING FINE� GRAINED SYSTEMS

Use correlation IDs to track down nasty bugs Sam Newman

Engineering Consistency integration

metrics

Building Microservices DESIGNING FINE�GRAINED SYSTEMS

Consider Service Templates to make it easy to do the right thing! SamNewman

service behavior

downstream

SCM Repositorie Repositories s Prefer reposit Prefer reposi tor oryy per service to to monolithic monolit hic repository

Integrate via Integrate continuous integration

Testing Microservices

http://martinfowler.com/articles/microservice-t http://martinfowler.com/articles/microservice-testing/ esting/

Inside the Box

Unit Testing

Sociable

Solitary

Integration Testing

Integration Testing

Component Testing

Component Testing shims: inproctester github.com/aharin/inproctester

Plasma github.com/jennifersmith/plasma

Component Testing

Contract Testing Pact github.com/realestate-com-au/pact Pacto github.com/thoughtworks/pacto  Janus github.com/gga/janus

End-to-End Testing

Test Pyramid for Microservices

Deployment

engineering

Building Microservices DESIGNING FINE�GRAINED SYSTEMS

 Abstract out underlying  platform di  " erences to provide a uniform deployment mechanism. SamNewman

Don’t Let Changes Build Up staging

production

Don’t Let Changes Build Up staging

production

Building Microservices DESIGNING FINE� GRAINED SYSTEMS

Don’t let changes build up release as soon as you can, and  preferably one at a time!

Integration & Disintegration

Reducing Risk of Release Components are deployed .

Features are released .

Applications consist of routing . production

Blue/Green Deployments

1.1

1.1

1.1

1.2

1.2

1.2

Web server

Application server

Database server

Message Router

Blue/Green for Services Deploy Release Route Re-route upon failure production

How Big?

   k    s    i    r    e    s    a    e    l    e    r

# services

Dis-integrate services that monitoring shows are no longer used 

production

Building Microservices DESIGNINGFINE� GRAINED SYSTEMS

Use timeouts, circuit breakers and bulk-heads to avoid cascading failure. Sam Newman

what problem de!nitions

characteristics

SUMMARY

engineering

You must be this tall to use microservices

(Micro)service architectures provide unique bene!ts at the cost of increased (essential) complexity.

Inverse Conway Maneuver

Build teams that look like the architecture you want (and it will follow).

Efferent Coupling

efferent

Strive for low efferent coupling for your team.

Continuous Delivery Teams with low e" erent coupling deliver relatively independently into a common integration pipeline (without fearing breaking each others builds).

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF