monolith to microservices - o’reilly oscon

58
Monolith to Microservices How HomeDepot.com made the switch Christopher Grant Sr Architect HomeDepot.com cgrant cgrant

Upload: christopher-grant

Post on 20-Feb-2017

212 views

Category:

Technology


10 download

TRANSCRIPT

Page 1: Monolith to Microservices - O’Reilly Oscon

Monolith to MicroservicesHow HomeDepot.com made the switch

Christopher Grant Sr Architect HomeDepot.com

cgrantcgrant

Page 2: Monolith to Microservices - O’Reilly Oscon

Building the monolith

Page 3: Monolith to Microservices - O’Reilly Oscon

1996

Page 4: Monolith to Microservices - O’Reilly Oscon

Its an old story

• Start out small

• Lean and ready to take on the world

• Add some new features

• One day suddenly you realize

…you’ve got a monolith

Page 5: Monolith to Microservices - O’Reilly Oscon

2011

• 2 GB Java Deploy that took an hour

• Locking SCM (Clear Case) with no CI

• 3 Month long release Cycles

• 2-4 hour deploy outages

• Infrastructure drift (Pets) and config sprawl

Page 6: Monolith to Microservices - O’Reilly Oscon

Breaking Down the Monolith

Page 7: Monolith to Microservices - O’Reilly Oscon

Our Objective

• Increase the rate of change

• Increase number developers

• Maintain and enhance operations

Page 8: Monolith to Microservices - O’Reilly Oscon

Agile

Page 9: Monolith to Microservices - O’Reilly Oscon

Domain Spaces

Page 10: Monolith to Microservices - O’Reilly Oscon

Continuous Integration Tooling

Page 11: Monolith to Microservices - O’Reilly Oscon

APIs

Page 12: Monolith to Microservices - O’Reilly Oscon

Feature Throttles

Page 13: Monolith to Microservices - O’Reilly Oscon

Key Take Aways

Page 14: Monolith to Microservices - O’Reilly Oscon

Start with a vision

• Have a vision

• Understand your objectives

• Choose what matters

• Implement in stages

Page 15: Monolith to Microservices - O’Reilly Oscon

Culture change can be hard

Schneider Culture Modelhttp://agilitrix.com/2011/03/how-to-make-your-culture-work/

Page 16: Monolith to Microservices - O’Reilly Oscon

Iterative Architecture?

Page 17: Monolith to Microservices - O’Reilly Oscon

Changing the wheels while driving?

Page 18: Monolith to Microservices - O’Reilly Oscon

Evolutionary Architecture

Page 19: Monolith to Microservices - O’Reilly Oscon

Architect for Change

• Prepare for future changes

• Be proactive not reactive

• Delay until the last responsible moment

• Expect but minimize future rework

Page 20: Monolith to Microservices - O’Reilly Oscon

Domain Driven DesignHeader

Imagery ProductPod BuyBox

BreadCrumbShareThis

ItemRelatedGroups

Product Details

Certona

Footer

Page 21: Monolith to Microservices - O’Reilly Oscon

Decompose & Define Boundaries

• Understand business products & domains

• Identify people structures

• Review data models

• Look for the hard things

Page 22: Monolith to Microservices - O’Reilly Oscon

8 fallacies of distributed computing

• The network is reliable • Latency is zero • Bandwidth is infinite. • The network is secure

L Peter Deutsch and others at Sun Microsystems

• Topology doesn't change • There is one administrator • Transport cost is zero • The network is homogeneous

https://en.wikipedia.org/wiki/Fallacies_of_distributed_computing

Page 23: Monolith to Microservices - O’Reilly Oscon

Implement Safely

• Automate early and often

• Consider in-place and green-field

• Utilize feature switches and traffic throttles

• Encourage separation and independence

Page 24: Monolith to Microservices - O’Reilly Oscon

Result

2011 2015

Apps 1 30

Sales $1b $5b

Developers 170 300

Deploy frequency 3 month Weekly

Page 25: Monolith to Microservices - O’Reilly Oscon

2015 began moving to cloud & micro services

But wait

Theres more!!

Page 26: Monolith to Microservices - O’Reilly Oscon

Microservices in the Cloud

Page 27: Monolith to Microservices - O’Reilly Oscon

Microservices for everyone• Everyone’s trying to break down their monolith these days

• More maintainable

• Easier deployment

• More isolated concerns

• Not just for unicorns anymore

Page 28: Monolith to Microservices - O’Reilly Oscon

How is THD approaching it

Page 29: Monolith to Microservices - O’Reilly Oscon

Microservices Patterns

Chris Richardsonhttp://microservices.io/

Great resource &Great way to talk about what we did

Page 30: Monolith to Microservices - O’Reilly Oscon

Core Patterns

• Monolith

• Microservice

Page 31: Monolith to Microservices - O’Reilly Oscon

Core Patterns

• Monolith

• Microservice

Page 32: Monolith to Microservices - O’Reilly Oscon

Microservces

• How big should they be? • How many should we have?

Page 33: Monolith to Microservices - O’Reilly Oscon
Page 34: Monolith to Microservices - O’Reilly Oscon
Page 35: Monolith to Microservices - O’Reilly Oscon
Page 36: Monolith to Microservices - O’Reilly Oscon
Page 37: Monolith to Microservices - O’Reilly Oscon
Page 38: Monolith to Microservices - O’Reilly Oscon

Two Pizza Rule

If a team can’t be fed by two pizzas

then its too big -Jeff Bezzos

Page 39: Monolith to Microservices - O’Reilly Oscon

1Microserviceper

twopizzateam

Page 40: Monolith to Microservices - O’Reilly Oscon

Domain Services

Page 41: Monolith to Microservices - O’Reilly Oscon

• Code Base• Dependencies• Config• Backing Services• Build Release Run• Process• Port Binding• Concurrency• Disposability• Dev/Prod Parity• Logs• Admin Process

http://12factor.net/

Cloud Native Apps

Page 42: Monolith to Microservices - O’Reilly Oscon

Communication• API Gateways

• Discovery

• Server side

• Client Side

• Ambassador (proxy)

• Registration

• Self

• Third Party

Page 43: Monolith to Microservices - O’Reilly Oscon

Communication• API Gateways

• Discovery

• Server side

• Client Side

• Ambassador (proxy)

• Registration

• Self

• Third Party

Page 44: Monolith to Microservices - O’Reilly Oscon

Ambassador Pattern

Registry

Client Instance

Service Instance

Client App

Local Proxy

Service App

Registrator

1. The new server registers itself in the registry

2. Registry updates all LB configurations

3. The client App calls a local proxy

4. The Local proxy routes to the new Service App

1

2 3

4

Page 45: Monolith to Microservices - O’Reilly Oscon

Deployment patterns

• Single Service Per Host

• Multiple Service Per Host

• Single Service Per VM

• Single Service per container

Page 46: Monolith to Microservices - O’Reilly Oscon

Deployment patterns

• Single Service Per Host

• Multiple Services Per Host

• Single Service Per VM

• Single Service per container

Page 47: Monolith to Microservices - O’Reilly Oscon
Page 48: Monolith to Microservices - O’Reilly Oscon
Page 49: Monolith to Microservices - O’Reilly Oscon
Page 50: Monolith to Microservices - O’Reilly Oscon
Page 51: Monolith to Microservices - O’Reilly Oscon

Immutable Architecture

• Assets are rebuilt, redeployed but never modified

• SSH is only for diagnostic uses

• Base images used for speed and maintainability

• Immutable application assets added separately

Page 52: Monolith to Microservices - O’Reilly Oscon

Registry Agent Registry Template Logs Collector

Java 8

productpage-1-5-5.jar

Proxy

product-app.yamlsourceImage: java8-10141019properties: app_name: productpage app_version: 1-5-5

Single Instance

Base

App

(java8-10141019)

Page 53: Monolith to Microservices - O’Reilly Oscon

Building with Hammer & Nail

Page 54: Monolith to Microservices - O’Reilly Oscon

Data Management

• One Database per service

• Event-driven Architecture

Page 55: Monolith to Microservices - O’Reilly Oscon

Data Management

• One Database per service

• Event-driven Architecture

Page 56: Monolith to Microservices - O’Reilly Oscon

Decoupling Strategies

DB1

App1 App2

Shared Database

DB1

Dom1

App2

Shared Domain

App1

Decentralized Data

DB1

App1

DB2

App2

Queue

Page 57: Monolith to Microservices - O’Reilly Oscon

7 deadly sins of microservices

@danielbryantukDaniel Bryant

https://opencredo.com/the-seven-deadly-sins-of-microservices-redux/

Page 58: Monolith to Microservices - O’Reilly Oscon

Thank You