and Microservices Randy Shoup @randyshoup - - PowerPoint PPT Presentation

and microservices
SMART_READER_LITE
LIVE PREVIEW

and Microservices Randy Shoup @randyshoup - - PowerPoint PPT Presentation

Monoliths, Migrations, and Microservices Randy Shoup @randyshoup linkedin.com/in/randyshoup Background VP Engineering at WeWork o Physical space as a service VP Engineering at Stitch Fix o Using technology and data science to


slide-1
SLIDE 1

Monoliths, Migrations, and Microservices

Randy Shoup @randyshoup linkedin.com/in/randyshoup

slide-2
SLIDE 2

Background

  • VP Engineering at WeWork
  • Physical space as a service
  • VP Engineering at Stitch Fix
  • Using technology and data science to revolutionize clothing retail
  • Director of Engineering for Google App Engine
  • World’s largest Platform-as-a-Service
  • Chief Engineer at eBay
  • Evolving multiple generations of eBay’s infrastructure
slide-3
SLIDE 3

“Tell us how you did things at Google and eBay.” “Sure, I’ll tell you, but you have to promise not to do them! [… yet]”

slide-4
SLIDE 4

Architecture Evolution

  • eBay
  • 5th generation today
  • Monolithic Perl à Monolithic C++ à Java à microservices
  • Twitter
  • 3rd generation today
  • Monolithic Rails à JS / Rails / Scala à microservices
  • Amazon
  • Nth generation today
  • Monolithic Perl / C++ à Java / Scala à microservices
slide-5
SLIDE 5

No one starts with microservices … Past a certain scale, everyone ends up with microservices

slide-6
SLIDE 6

If you don’t end up regretting your early technology decisions, you probably over- engineered.

slide-7
SLIDE 7

STARTING SCALING OPTIMIZING

https://ittybiz.com/s-curve/

slide-8
SLIDE 8

STARTING SCALING OPTIMIZING

https://ittybiz.com/s-curve/

I D E A

slide-9
SLIDE 9

What problem are you trying to solve?

slide-10
SLIDE 10

Idea Phase: “Prototype” Architecture

  • Goal: Explore the space as rapidly and cheaply as

possible

  • Find business model
  • Find product market fit
  • Acquire first customers
  • è Rapid Iteration
  • *Everything* is a prototype
  • You *will* throw it all away
slide-11
SLIDE 11

Idea Phase: “Prototype” Architecture

  • Ideally No Technology At All
  • Paper prototypes
  • Google ads
  • Excel spreadsheet
  • Wordpress blog
  • If you *really* need to build something …
  • Familiar technology
  • Cobble it together
slide-12
SLIDE 12

“Do things that don’t scale”

  • - Paul Graham
slide-13
SLIDE 13

STARTING SCALING OPTIMIZING

https://ittybiz.com/s-curve/

One Team 3-6 month horizon

slide-14
SLIDE 14

Two-Pizza Team

4-6 people

“A team should be no larger than can be fed by two large pizzas.”

  • - Jeff Bezos, Amazon
slide-15
SLIDE 15

Starting Phase: “Just Enough” Architecture

  • Goal: Meet near-term, evolving customer needs as

cheaply as possible

  • Delight first customers
  • Acquire more
  • Rapid learning and improvement
  • Team productivity
  • NOT about scaling
slide-16
SLIDE 16

“The best code you can write now is code you’ll discard in a couple of years time”

  • - Martin Fowler

http://martinfowler.com/bliki/SacrificialArchitecture.html

slide-17
SLIDE 17

Starting Phase: “Just Enough” Architecture

  • Simple, Familiar Technology
  • Ease of Use
  • Expressive Power
  • Rapid prototyping frameworks (Ruby / Rails, PHP, etc.)
  • Monolithic Architecture
  • Single application
  • Single database
  • Minimal Infrastructure
  • Ideally serverless
  • PaaS or Lambda instead of IaaS
slide-18
SLIDE 18

The Monolithic Architecture

2-3 monolithic tiers

Presentation Application Database

slide-19
SLIDE 19

Monolithic Architecture

  • Simple at first
  • In-process latencies
  • Single build and

deployment unit

  • Resource-efficient at

small scale

  • Coordination overhead

as team grows

  • Poor enforcement of

modularity

  • No horizontal scaling
  • Single point of failure,

single performance bottleneck

Pros Cons

slide-20
SLIDE 20

Starting Phase: Preparing to Scale

  • Modularity Discipline
  • Use “shared libraries” within the monolith
  • Easy to modify or replace
  • Detailed Logging
  • Understanding user behavior
  • Instrumenting for diagnosis and recovery
  • Continuous Delivery
  • Deploy many times per day
slide-21
SLIDE 21

When to Rearchitect?

  • Velocity
  • Time to market is constrained by coupling and lack of isolation in the

monolith

  • Teams step on each others’ toes, and can no longer develop

independently

  • Difficult for new engineers to be productive
  • Scaling
  • Vertical scaling of the monolith no longer works
  • Parts of the system need to scale independently of others
slide-22
SLIDE 22

When to Rearchitect?

  • Deployment
  • Parts of the system need to deploy independently of others
  • Monolithic release is too slow, too complicated, too risky
slide-23
SLIDE 23

STARTING SCALING OPTIMIZING

https://ittybiz.com/s-curve/

More and More Teams 6-24 month horizon

slide-24
SLIDE 24

Scaling Phase: Scalable Architecture

  • Goal: Stay ahead of rapidly growing business. Keep

the site up (!)

  • Scaling the Teams
  • Scaling the Technology
  • Repeatable Processes
slide-25
SLIDE 25

Many Two-Pizza Teams

Idea Development Quality Operations Idea Development Quality Operations Idea Development Quality Operations

slide-26
SLIDE 26

Scaling Phase: Scalable Architecture

  • Technology that Scales
  • Common migrations to {Python, Go, JVM languages}
  • Concurrency
  • Asynchrony
  • Independent systems
  • Fit-for-purpose systems: analytics, search
  • Separated services: payments, etc.
  • Layered services: caching, etc.
  • Event queue
  • Use events to communicate between applications and services
slide-27
SLIDE 27

Scaling Phase: Scalable Architecture

  • Scalable persistence
  • Break up the monolithic database
  • Functional partitioning
  • Sharding
slide-28
SLIDE 28

Microservices

  • Single-purpose
  • Simple, well-defined interface
  • Modular and independent

A C D E B

slide-29
SLIDE 29

Microservices

  • Single-purpose
  • Simple, well-defined interface
  • Modular and independent
  • Isolated persistence (!)

A C D E B

slide-30
SLIDE 30

Microservice Architecture

  • Each unit is simple
  • Independent scaling and

performance

  • Independent testing and

deployment

  • “Optimal” technology

stack

  • Security boundary
  • Multiple cooperating units
  • Exchange in-process for

network latencies

  • More sophisticated

deployment and monitoring tools

  • Overall system complexity

Pros Cons

slide-31
SLIDE 31

Migrating to Services

  • Incremental Migration
  • Migrating a Monolithic Application
  • Migrating a Monolithic Database
slide-32
SLIDE 32

Migrating to Services

  • Incremental Migration
  • Migrating a Monolithic Application
  • Migrating a Monolithic Database
slide-33
SLIDE 33

“The only thing a Big Bang migration guarantees is a big *Bang*.”

  • - Martin Fowler
slide-34
SLIDE 34

Incremental Migration

  • Step 0: Pilot Implementation
  • Choose initial end-to-end vertical experience to migrate / create
  • (+) Opportunity to learn and adjust
  • (+) Demonstrate feasibility and gain confidence
  • (+) Bound investment and risk
  • (+) Provide real customer value
  • Initial step is the hardest
  • Learning how to do things in the new way
  • Building out basic supporting capabilities
slide-35
SLIDE 35

Incremental Migration

  • Steps 1-N: Incremental Migration
  • Prioritize business value -- highest ROI areas first
  • Focus on areas with greatest rate of change
  • (+) Maximize near-term payoff from investment
  • (+) Confront and solve hard problems sooner rather than later
  • New feature development in parallel
  • Typically cannot pause all feature work in all areas to migrate J
  • Within a particular area, try to separate feature work from migration work

in distinct steps

slide-36
SLIDE 36

Incremental Migration

  • Residual monolith may remain indefinitely
  • Lowest business value
  • Most stable and least changing
  • Can migrate – or not – opportunistically
slide-37
SLIDE 37

Migrating to Services

  • Incremental Migration
  • Migrating a Monolithic Application
  • Migrating a Monolithic Database
slide-38
SLIDE 38

Carving up the Monolith

  • Look for (or create) a “seam” in the

monolith

  • This is often the hardest part (!)
  • Wall it off behind an interface
  • Write automated tests around the

interface

  • Replace implementation with an

independent component

  • è Rinse and Repeat
slide-39
SLIDE 39

Migrating to Services

  • Incremental Migration
  • Migrating a Monolithic Application
  • Migrating a Monolithic Database
slide-40
SLIDE 40

Extracting Microservices

  • Problem: Monolithic shared DB
  • Clients
  • Shipments
  • Items
  • Styles, SKUs
  • Warehouses
  • etc.

stitchfix.com Styling app Warehouse app Merch app CS app Logistics app Payments service Profile service

slide-41
SLIDE 41

Extracting Microservices

  • Decouple applications / services from shared DB
  • Clients
  • Shipments
  • Items
  • Styles, SKUs
  • Warehouses
  • etc.

stitchfix.com Styling app Warehouse app Merch app CS app Logistics app Payments service Profile service

slide-42
SLIDE 42

Extracting Microservices

  • Decouple applications / services from shared DB

Styling app Warehouse app core_item core_sku core_client

slide-43
SLIDE 43

Extracting Microservices

  • Step 1: Create a service

Styling app Warehouse app core_item core_sku core_client client-service

slide-44
SLIDE 44

Extracting Microservices

  • Step 2: Applications use the service

Styling app Warehouse app core_item core_sku core_client client-service

slide-45
SLIDE 45

Extracting Microservices

  • Step 3: Move data to private database

Styling app Warehouse app core_item core_sku client-service core_client

slide-46
SLIDE 46

Extracting Microservices

  • Step 4: Rinse and Repeat

Styling app Warehouse app core_sku client-service core_client item-service core_item

slide-47
SLIDE 47

Extracting Microservices

  • Step 4: Rinse and Repeat

Styling app Warehouse app client-service core_client item-service core_item style-service core_sku

slide-48
SLIDE 48

Extracting Microservices

  • Step 4: Rinse and Repeat

Styling app Warehouse app client-service core_client item-service core_item style-service core_sku

slide-49
SLIDE 49

Getting to rearchitect a system is a sign of success, not failure.

slide-50
SLIDE 50

Service as System of Record

  • Single System of Record
  • Every piece of data is owned by a single service
  • That service is the canonical system of record for that data
  • Every other copy is a read-only, non-authoritative

cache

@randyshoup linkedin.com/in/randyshoup

customer-service styling-service customer-search billing-service

slide-51
SLIDE 51

Microservices and Events

  • Events are a first-class part of a service interface
  • A service interface includes
  • Synchronous request-response (REST, gRPC, etc)
  • Events the service produces
  • Events the service consumes
  • Bulk reads and writes (ETL)
  • The interface includes any mechanism for getting

data in or out of the service (!)

@randyshoup linkedin.com/in/randyshoup

slide-52
SLIDE 52

STARTING SCALING OPTIMIZING

https://ittybiz.com/s-curve/

Fewer Teams 2-5 year horizon

slide-53
SLIDE 53

STARTING SCALING OPTIMIZING

https://ittybiz.com/s-curve/

slide-54
SLIDE 54

Merci!

@randyshoup linkedin.com/in/randyshoup medium.com/@randyshoup