dsr microservices (day 1, part 2)

275
Microservices @Steve_Upton

Upload: steve-upton

Post on 13-Apr-2017

73 views

Category:

Engineering


4 download

TRANSCRIPT

Page 1: DSR Microservices (Day 1, Part 2)

Microservices@Steve_Upton

Page 2: DSR Microservices (Day 1, Part 2)

What Microservices actually look like

Page 3: DSR Microservices (Day 1, Part 2)

DevOps

Page 4: DSR Microservices (Day 1, Part 2)

“10+ Deploys Per Day: Dev and Ops Cooperation at Flickr”John Allspaw, Velocity 2009

Page 5: DSR Microservices (Day 1, Part 2)

“...a cross-disciplinary community of practice dedicated to the study of building, evolving and operating rapidly-changing resilient systems at

scale.”Jez Humble

Page 6: DSR Microservices (Day 1, Part 2)
Page 7: DSR Microservices (Day 1, Part 2)
Page 8: DSR Microservices (Day 1, Part 2)
Page 9: DSR Microservices (Day 1, Part 2)

Continuous Delivery

Configuration Management

Monitoring

Page 10: DSR Microservices (Day 1, Part 2)

Continuous Delivery

Page 11: DSR Microservices (Day 1, Part 2)

“If you have more meetings than releases, you’re an enterprise company”

Clifton Cunningham, CTO @ TES Global

Page 12: DSR Microservices (Day 1, Part 2)

Containers

Page 13: DSR Microservices (Day 1, Part 2)

Containerscredit to Anne Currie

Page 14: DSR Microservices (Day 1, Part 2)

Bare Metal

Page 15: DSR Microservices (Day 1, Part 2)

Bare Metal

✔ Powerful

✔ Simple

Page 16: DSR Microservices (Day 1, Part 2)

Bare Metal

✔ Powerful

✔ Simple

❌ Brittle

❌ Inflexible

Page 17: DSR Microservices (Day 1, Part 2)

Bare Metal

✔ Powerful

✔ Simple

❌ Brittle

❌ Inflexible

Page 18: DSR Microservices (Day 1, Part 2)

Virtual Machines

Page 19: DSR Microservices (Day 1, Part 2)

Virtual Machines

✔ Flexible

✔ Networking

✔ Security

Page 20: DSR Microservices (Day 1, Part 2)

Virtual Machines

✔ Flexible

✔ Networking

✔ Security

❌ Overweight

Page 21: DSR Microservices (Day 1, Part 2)

Virtual Machines

✔ Flexible

✔ Networking

✔ Security

❌ Overweight

Page 22: DSR Microservices (Day 1, Part 2)

Virtual Machines

✔ Flexible

✔ Networking

✔ Security

❌ Overweight

Page 23: DSR Microservices (Day 1, Part 2)

Containers

Page 24: DSR Microservices (Day 1, Part 2)

Containers

✔ Lightweight

✔ Agile

Page 25: DSR Microservices (Day 1, Part 2)

Containers

✔ Lightweight

✔ Agile

❌ Untested

❌ Networking

❌ Security

Page 26: DSR Microservices (Day 1, Part 2)

Containers

✔ Lightweight

✔ Agile

❌ Untested

❌ Networking

❌ Security

Page 27: DSR Microservices (Day 1, Part 2)

Containers

✔ Lightweight

✔ Agile

❌ Untested

❌ Networking

❌ Security

Page 28: DSR Microservices (Day 1, Part 2)
Page 29: DSR Microservices (Day 1, Part 2)

Exercise

Page 30: DSR Microservices (Day 1, Part 2)

Configuration Management

Page 31: DSR Microservices (Day 1, Part 2)
Page 32: DSR Microservices (Day 1, Part 2)

Immutable Infrastructure

Don’t change, replace

Requires automation

Page 33: DSR Microservices (Day 1, Part 2)

Immutable Infrastructure

Don’t change, replace

Requires automation

Blue-Green

Page 34: DSR Microservices (Day 1, Part 2)

Docker ComposeManage multi-container apps

Page 35: DSR Microservices (Day 1, Part 2)

Docker ComposeManage multi-container apps

Collection of dockerfiles → services

version: '2'

services:

web:

build: .

ports:

- "5000:5000"

volumes:

- .:/code

- logvolume01:/var/log

links:

- redis

redis:

image: redis

volumes:

logvolume01: {}

Page 36: DSR Microservices (Day 1, Part 2)

Is Docker production ready?

Page 37: DSR Microservices (Day 1, Part 2)

Is Docker production ready?

Page 38: DSR Microservices (Day 1, Part 2)

Is Docker production ready?

Not great at backwards compatibility…

Requires extra tooling

Page 39: DSR Microservices (Day 1, Part 2)
Page 40: DSR Microservices (Day 1, Part 2)
Page 41: DSR Microservices (Day 1, Part 2)

“Concurrent Production”

Page 42: DSR Microservices (Day 1, Part 2)

“The development contracts are being performed concurrent with the production contracts”

2015 Lockheed Martin Annual Report

Page 43: DSR Microservices (Day 1, Part 2)
Page 44: DSR Microservices (Day 1, Part 2)
Page 45: DSR Microservices (Day 1, Part 2)

Ideas

Page 46: DSR Microservices (Day 1, Part 2)

Ideas

Build

Page 47: DSR Microservices (Day 1, Part 2)

Ideas

Build

Product

Page 48: DSR Microservices (Day 1, Part 2)

Ideas

Measure

Build

Product

Page 49: DSR Microservices (Day 1, Part 2)

Ideas

Measure

Build

ProductData

Page 50: DSR Microservices (Day 1, Part 2)

Ideas

Measure

Build

ProductData

Learn

Page 51: DSR Microservices (Day 1, Part 2)
Page 52: DSR Microservices (Day 1, Part 2)
Page 53: DSR Microservices (Day 1, Part 2)
Page 54: DSR Microservices (Day 1, Part 2)

Inter-service communication

Page 55: DSR Microservices (Day 1, Part 2)

Build TestHTTP

Page 56: DSR Microservices (Day 1, Part 2)

Build Test

Email

Page 57: DSR Microservices (Day 1, Part 2)

Build Test

Email

Slack

Page 58: DSR Microservices (Day 1, Part 2)

Build Test

Email

Slack

Fireworks

Page 59: DSR Microservices (Day 1, Part 2)

Build Test

Email

Slack

Fireworks

Page 60: DSR Microservices (Day 1, Part 2)

Build Test

Email

Slack

Fireworks

Page 61: DSR Microservices (Day 1, Part 2)
Page 62: DSR Microservices (Day 1, Part 2)

“Service Discoveryis an anti-pattern”

Page 63: DSR Microservices (Day 1, Part 2)

“Service Discoveryis an anti-pattern”

Richard Rodger, CTO @ nearForm

Page 64: DSR Microservices (Day 1, Part 2)

Messaging!

Page 65: DSR Microservices (Day 1, Part 2)

Build Test

Email

Slack

Fireworks

RabbitMQ

Page 66: DSR Microservices (Day 1, Part 2)

Build Testpublish

Email

Slack

Fireworks

RabbitMQ

Page 67: DSR Microservices (Day 1, Part 2)

Build Testpublish

Email

Slack

Fireworks

RabbitMQ

subscribe

Page 68: DSR Microservices (Day 1, Part 2)

Time To Live

Page 69: DSR Microservices (Day 1, Part 2)

mq.publish(msg, {ttl: 10});

Time To Live

Page 70: DSR Microservices (Day 1, Part 2)

mq.publish(msg, {ttl: 10});

function put(msg, startTime) { response = http.put(msg); if (response.code != 200) { if (getTime() - startTime < timeout) { put(msg, startTime); } }}

startTime = getTime();put(msg, startTime);

Time To Live

Page 71: DSR Microservices (Day 1, Part 2)

mq.publish(msg, {ttl: 10});

function put(msg, startTime) { response = http.put(msg); if (response.code == 404) { // ??? } else if (response.code != 200) { if (getTime() - startTime < timeout) { put(msg, startTime); } }}

startTime = getTime();put(msg, startTime);

Time To Live

Page 72: DSR Microservices (Day 1, Part 2)

mq.publish(msg, {ttl: 10});

function put(msg, startTime) { response = http.put(msg); if (response.code == 404) { // ??? } else if (response.code == 429) { // ??? } else if (response.code == 500) { // ??? } else if (response.code != 200) { if (getTime() - startTime < timeout) { put(msg, startTime); } }}

startTime = getTime();put(msg, startTime);

Time To Live

Page 73: DSR Microservices (Day 1, Part 2)

mq.publish(msg, {ttl: 10});

function put(msg, startTime) { response = http.put(msg); if (response.code == 404) { // ??? } else if (response.code == 429) { // ??? } else if (response.code == 500) { // ??? } else if (response.code != 200) { if (getTime() - startTime < timeout) { timeSpent = getTime() - startTime; delay = Math.pow(timeSpent, 2); setTimeout(put(msg, startTime), delay); } }}

startTime = getTime();put(msg, startTime);

Time To Live

Page 74: DSR Microservices (Day 1, Part 2)

mq.publish(msg, {ttl: 10});

function put(msg, startTime) { response = http.put(msg); if (response.code == 404) { // ??? } else if (response.code == 429) { // ??? } else if (response.code == 500) { // ??? } else if (response.code != 200) { if (getTime() - startTime < timeout) { timeSpent = getTime() - startTime; delay = Math.pow(timeSpent, 2); remainingTime = timeout - timeSpent; delay = Math.min(delay, remainingTime); setTimeout(put(msg, startTime), delay); } }}

startTime = getTime();put(msg, startTime);

Time To Live

Page 75: DSR Microservices (Day 1, Part 2)

mq.publish(msg, {ttl: 10});

function put(msg, startTime) { response = http.put(msg); if (response.code == 404) { // ??? } else if (response.code == 429) { // ??? } else if (response.code == 500) { // ??? } else if (response.code != 200) { if (getTime() - startTime < timeout) { timeSpent = getTime() - startTime; fuzz = Math.floor(Math.random() * 10); delay = Math.pow(timeSpent, 2) + fuzz; remainingTime = timeout - timeSpent; delay = Math.min(delay, remainingTime); setTimeout(put(msg, startTime), delay); } }}

startTime = getTime();put(msg, startTime);

Time To Live

Page 76: DSR Microservices (Day 1, Part 2)

Quality of Service

Page 77: DSR Microservices (Day 1, Part 2)

// Best effort, fire and forgetmq.publish(unimportantMessage, {qos: 0});

// At least once deliverymq.publish(idempotentMessage, {qos: 1});

// Exactly once deliverymq.publish(importantMessage, {qos: 2});

Quality of Service

Page 78: DSR Microservices (Day 1, Part 2)

// Best effort, fire and forgetmq.publish(unimportantMessage, {qos: 0});

// At least once deliverymq.publish(idempotentMessage, {qos: 1});

// Exactly once deliverymq.publish(importantMessage, {qos: 2});

Quality of Service

Page 79: DSR Microservices (Day 1, Part 2)

// Best effort, fire and forgetmq.publish(unimportantMessage, {qos: 0});

// At least once deliverymq.publish(idempotentMessage, {qos: 1});

// Exactly once deliverymq.publish(importantMessage, {qos: 2});

Quality of Service

Page 80: DSR Microservices (Day 1, Part 2)

Concurrency

Page 81: DSR Microservices (Day 1, Part 2)

Concurrency

Upload text → Generate video → Post video

Page 82: DSR Microservices (Day 1, Part 2)

Concurrency

Fast Slow Fast

Upload text → Generate video → Post video

Page 83: DSR Microservices (Day 1, Part 2)

Concurrency

Fast Slow Fast

Upload text → Generate video → Post video

Page 84: DSR Microservices (Day 1, Part 2)

Concurrency

Upload service

Video generation service

Posting service

Text Video

Page 85: DSR Microservices (Day 1, Part 2)

Concurrency

Upload service

Video generation service

Posting service

Text Video

Page 86: DSR Microservices (Day 1, Part 2)

Concurrency

Upload service

Video generation service

Posting service

Text Video

Page 87: DSR Microservices (Day 1, Part 2)

Concurrency

Upload service

Video generation service

Posting service

Text Video

Page 88: DSR Microservices (Day 1, Part 2)

Concurrency

Upload service

Video generation service

Posting service

Text VideoVideo generation

serviceVideo generation service

Page 89: DSR Microservices (Day 1, Part 2)

Concurrency

Upload service

Video generation service

Posting service

Text VideoVideo generation

serviceVideo generation serviceLo

ad B

alan

cer

Page 90: DSR Microservices (Day 1, Part 2)

Concurrency

publish

RabbitMQ

subscribe

Upload service

Video generation service

Video generation service

Video generation service

Page 91: DSR Microservices (Day 1, Part 2)

Concurrency

publish

RabbitMQ

subscribe

Upload service

Video generation service

Video generation service

Video generation service

Page 92: DSR Microservices (Day 1, Part 2)

Concurrency

publish

RabbitMQ

subscribe

Upload service

Video generation service

Video generation service

Video generation service

Page 93: DSR Microservices (Day 1, Part 2)

Concurrency

publish

RabbitMQ

subscribe

Upload service

Video generation service

Video generation service

Video generation service

Page 94: DSR Microservices (Day 1, Part 2)

Concurrency

publish

RabbitMQ

subscribe

Upload service

Video generation service

Video generation service

Video generation service

Page 95: DSR Microservices (Day 1, Part 2)

“Publish everything!”Tom Livesey, Droplet

Page 96: DSR Microservices (Day 1, Part 2)
Page 97: DSR Microservices (Day 1, Part 2)

Exercise

Page 98: DSR Microservices (Day 1, Part 2)
Page 99: DSR Microservices (Day 1, Part 2)

Lots of data sources

Page 100: DSR Microservices (Day 1, Part 2)

Lots of data sources

Lots of data consumers

Page 101: DSR Microservices (Day 1, Part 2)

Lots of data sources

Lots of data consumers

Lots of integrations

Page 102: DSR Microservices (Day 1, Part 2)

LinkedIn before

Page 103: DSR Microservices (Day 1, Part 2)

LinkedIn before

O(n2)

Page 104: DSR Microservices (Day 1, Part 2)

LinkedIn after

Page 105: DSR Microservices (Day 1, Part 2)

Up close

Page 106: DSR Microservices (Day 1, Part 2)

The log

Append only

Time ordered

Page 107: DSR Microservices (Day 1, Part 2)

Distributed logging

Page 108: DSR Microservices (Day 1, Part 2)
Page 109: DSR Microservices (Day 1, Part 2)

add(20)

add(5)

subtract(10)

add(15)

Page 110: DSR Microservices (Day 1, Part 2)

add(20)

add(5)

subtract(10)

add(15)

Page 111: DSR Microservices (Day 1, Part 2)

add(20)

add(5)

subtract(10)

add(15)

Page 112: DSR Microservices (Day 1, Part 2)

?

add(20)

add(5)

subtract(10)

add(15)

Page 113: DSR Microservices (Day 1, Part 2)

“If two identical, deterministic processes begin in the same state and get the same inputs in the

same order, they will produce the same output and end in the same state.”

State Machine Replication Principle, Jay Kreps, LinkedIn

Page 114: DSR Microservices (Day 1, Part 2)

30

add(20)

add(5)

subtract(10)

add(15)

?

Page 115: DSR Microservices (Day 1, Part 2)

Log as source of Truth

Page 116: DSR Microservices (Day 1, Part 2)
Page 117: DSR Microservices (Day 1, Part 2)
Page 118: DSR Microservices (Day 1, Part 2)
Page 119: DSR Microservices (Day 1, Part 2)

Initial population

Page 120: DSR Microservices (Day 1, Part 2)

person born

person died

person born

person born

Initial population

Page 121: DSR Microservices (Day 1, Part 2)

Population:308,745,538

person born

person died

person born

person born

Initial population

Page 122: DSR Microservices (Day 1, Part 2)
Page 123: DSR Microservices (Day 1, Part 2)
Page 124: DSR Microservices (Day 1, Part 2)
Page 125: DSR Microservices (Day 1, Part 2)
Page 126: DSR Microservices (Day 1, Part 2)

2 million writes s-1

(on 3 cheap machines)

10s of millions of writes s-1

(LinkedIn production)

Page 127: DSR Microservices (Day 1, Part 2)

2 million writes s-1

(on 3 cheap machines)

10s of millions of writes s-1

(LinkedIn production)

7 transactions s-1

(Bitcoin network)

Page 128: DSR Microservices (Day 1, Part 2)

Log as source of Truth

Page 129: DSR Microservices (Day 1, Part 2)

Event Sourcing

Page 130: DSR Microservices (Day 1, Part 2)

“We don’t care if our production system crashes.”Valerii Vasylkov, William Hill

Page 131: DSR Microservices (Day 1, Part 2)
Page 132: DSR Microservices (Day 1, Part 2)

Data science. Analytics about the business

Full-fledged stream processing framework

Microservice like. Core business functions

Build an app that consumes from Kafka directly

Page 133: DSR Microservices (Day 1, Part 2)

Data science. Analytics about the business

Full-fledged stream processing framework

Microservice like. Core business functions

Build an app that consumes from Kafka directly

Page 134: DSR Microservices (Day 1, Part 2)

Data science. Analytics about the business

Full-fledged stream processing framework

Microservice like. Core business functions

Build an app that consumes from Kafka directly

Page 135: DSR Microservices (Day 1, Part 2)
Page 136: DSR Microservices (Day 1, Part 2)
Page 137: DSR Microservices (Day 1, Part 2)

Testing Microservices

Page 138: DSR Microservices (Day 1, Part 2)

Monolithic testing

Page 139: DSR Microservices (Day 1, Part 2)

Monolithic testing

App

Test

Page 140: DSR Microservices (Day 1, Part 2)

Monolithic testing

App

Test

Test data

Test data

Test data

Page 141: DSR Microservices (Day 1, Part 2)

Monolithic testing

App

Test

Test data

Test data

Test data

Output ✔

Output ✔

Output ✔

Page 142: DSR Microservices (Day 1, Part 2)

Monolithic testing

App

Test

Test data

Test data

Test data

Output ✔

Output ✖

Output ✔

Page 143: DSR Microservices (Day 1, Part 2)

Monolithic testing

App

Test

Test data

Test data

Test data

Output ✔

Output ✔

Output ✔

Output ✔

Output ✔

Output ✔

Page 144: DSR Microservices (Day 1, Part 2)

Monolithic testing

App

Test Production

App

Test data

Test data

Test data

Output ✔

Output ✔

Output ✔

Page 145: DSR Microservices (Day 1, Part 2)

Microservice testingTest

Microservice

Microservice

Microservice

Page 146: DSR Microservices (Day 1, Part 2)

Microservice testingTest

Microservice

Microservice

Microservice

Tests

Outputs ✔

Tests

Outputs ✔

Outputs ✔

Tests

Page 147: DSR Microservices (Day 1, Part 2)

Microservice testingProduction

Microservice

Microservice

Microservice

Page 148: DSR Microservices (Day 1, Part 2)

Microservice testingProduction

Microservice

Microservice

Microservice

Page 149: DSR Microservices (Day 1, Part 2)

Monitoring = Testing

Page 150: DSR Microservices (Day 1, Part 2)
Page 151: DSR Microservices (Day 1, Part 2)
Page 152: DSR Microservices (Day 1, Part 2)
Page 153: DSR Microservices (Day 1, Part 2)
Page 154: DSR Microservices (Day 1, Part 2)

Chaos Gorilla

Page 155: DSR Microservices (Day 1, Part 2)

Chaos Kong

Page 156: DSR Microservices (Day 1, Part 2)

Conformity Monkey

Page 157: DSR Microservices (Day 1, Part 2)

Security Monkey

Page 158: DSR Microservices (Day 1, Part 2)

Janitor Monkey

Page 159: DSR Microservices (Day 1, Part 2)

Latency Monkey

Page 160: DSR Microservices (Day 1, Part 2)

“Everything fails all the time”Werner Vogels, VP + CTO @ Amazon

Page 161: DSR Microservices (Day 1, Part 2)

Design for Failure

Page 162: DSR Microservices (Day 1, Part 2)

Self healing systems

Page 163: DSR Microservices (Day 1, Part 2)

Debugging Microservices

Page 164: DSR Microservices (Day 1, Part 2)
Page 165: DSR Microservices (Day 1, Part 2)

“How big should my Microservice be?”Everyone

Page 166: DSR Microservices (Day 1, Part 2)

Domain Driven Design (DDD)

Page 167: DSR Microservices (Day 1, Part 2)
Page 168: DSR Microservices (Day 1, Part 2)
Page 169: DSR Microservices (Day 1, Part 2)
Page 170: DSR Microservices (Day 1, Part 2)
Page 171: DSR Microservices (Day 1, Part 2)

“Not all of a large system will be well designed”

Eric Evans

Page 172: DSR Microservices (Day 1, Part 2)

“The first draft of anything is shit”Ernest Hemingway

Page 173: DSR Microservices (Day 1, Part 2)

“... big enough to fit in your head”Dan North

Page 174: DSR Microservices (Day 1, Part 2)

“Replaceable component architecture”Dan North

Page 175: DSR Microservices (Day 1, Part 2)

Monolith first?

Page 177: DSR Microservices (Day 1, Part 2)

I. CodebaseOne codebase tracked in revision control, many deploys

Page 178: DSR Microservices (Day 1, Part 2)

I. CodebaseOne codebase tracked in revision control, many deploys

Always use version control!

Page 179: DSR Microservices (Day 1, Part 2)

I. CodebaseOne codebase tracked in revision control, many deploys

Always use version control!

One app (microservice) per repo

Page 180: DSR Microservices (Day 1, Part 2)

I. CodebaseOne codebase tracked in revision control, many deploys

Always use version control!

One app (microservice) per repo

Multiple deploys per app (local, dev, prod, etc.)

Page 181: DSR Microservices (Day 1, Part 2)

II. DependenciesExplicitly declare and isolate dependencies

Page 182: DSR Microservices (Day 1, Part 2)

II. DependenciesExplicitly declare and isolate dependencies

Never assume something is pre-installed

Page 183: DSR Microservices (Day 1, Part 2)

II. DependenciesExplicitly declare and isolate dependencies

Never assume something is pre-installed

Package managers/repos make this easy! $ pip install -r requirements.txt

$ npm install

$ bundle install

Page 184: DSR Microservices (Day 1, Part 2)

II. DependenciesExplicitly declare and isolate dependencies

Never assume something is pre-installed

Package managers/repos make this easy!

Isolate dependencies to prevent ‘leaking’

$ pip install -r requirements.txt

$ npm install

$ bundle install

Page 185: DSR Microservices (Day 1, Part 2)

II. DependenciesExplicitly declare and isolate dependencies

Never assume something is pre-installed

Package managers/repos make this easy!

Isolate dependencies to prevent ‘leaking’

$ npm install

Page 186: DSR Microservices (Day 1, Part 2)

II. DependenciesExplicitly declare and isolate dependencies

Never assume something is pre-installed

Package managers/repos make this easy!

Isolate dependencies to prevent ‘leaking’

(Aims to) prevent “it works on my machine” $ npm install

Page 187: DSR Microservices (Day 1, Part 2)

III. ConfigStore config in the environment

Page 188: DSR Microservices (Day 1, Part 2)

III. ConfigStore config in the environment

Config changes between deploys (dev, prod, etc.)

Page 189: DSR Microservices (Day 1, Part 2)

III. ConfigStore config in the environment

Config changes between deploys (dev, prod, etc.)

Store config in environment not codebase

Page 190: DSR Microservices (Day 1, Part 2)

III. ConfigStore config in the environment

Config changes between deploys (dev, prod, etc.)

Store config in environment not codebase

Page 191: DSR Microservices (Day 1, Part 2)

III. ConfigStore config in the environment

Config changes between deploys (dev, prod, etc.)

Store config in environment not codebase

Suggest environment vars, but other options...

Page 192: DSR Microservices (Day 1, Part 2)

III. ConfigStore config in the environment

Config changes between deploys (dev, prod, etc.)

Store config in environment not codebase

Suggest environment vars, but other options...

Supports multiple deploys from one codebase

Page 193: DSR Microservices (Day 1, Part 2)

III. ConfigStore config in the environment

Config changes between deploys (dev, prod, etc.)

Store config in environment not codebase

Suggest environment vars, but other options...

Supports multiple deploys from one codebase

Makes Open Sourcing easier

Page 194: DSR Microservices (Day 1, Part 2)

IV. Backing servicesTreat backing services as attached resources

Page 195: DSR Microservices (Day 1, Part 2)

IV. Backing servicesTreat backing services as attached resources

Backing services are any remote services

Page 196: DSR Microservices (Day 1, Part 2)

IV. Backing servicesTreat backing services as attached resources

Backing services are any remote services

Loosely coupled to a deploy

Page 197: DSR Microservices (Day 1, Part 2)

IV. Backing servicesTreat backing services as attached resources

Backing services are any remote services

Loosely coupled to a deploy

Treated as local resources

Page 198: DSR Microservices (Day 1, Part 2)

IV. Backing servicesTreat backing services as attached resources

Backing services are any remote services

Loosely coupled to a deploy

Treated as local resources

Allows easy swapping out of services

Page 199: DSR Microservices (Day 1, Part 2)

V. Build, release, runStrictly separate build and run stages

Page 200: DSR Microservices (Day 1, Part 2)

V. Build, release, runStrictly separate build and run stages

Build

Page 201: DSR Microservices (Day 1, Part 2)

V. Build, release, runStrictly separate build and run stages

Build → Release

Page 202: DSR Microservices (Day 1, Part 2)

V. Build, release, runStrictly separate build and run stages

Build → Release → Run

Page 203: DSR Microservices (Day 1, Part 2)

V. Build, release, runStrictly separate build and run stages

Build → Release → Run

Strict separation between the stages

Page 204: DSR Microservices (Day 1, Part 2)

V. Build, release, runStrictly separate build and run stages

Build → Release → Run

Strict separation between the stages

One way (no tweaking the live server!)

Page 205: DSR Microservices (Day 1, Part 2)

VI. ProcessesExecute the app as one or more stateless processes

Page 206: DSR Microservices (Day 1, Part 2)

VI. ProcessesExecute the app as one or more stateless processes

Apps run as processes (duh)

Page 207: DSR Microservices (Day 1, Part 2)

VI. ProcessesExecute the app as one or more stateless processes

Apps run as processes (duh)

No state: every node is independent

Page 208: DSR Microservices (Day 1, Part 2)

VI. ProcessesExecute the app as one or more stateless processes

Apps run as processes (duh)

No state: every node is independent

Caching is fine, but not for future use

Page 209: DSR Microservices (Day 1, Part 2)

VI. ProcessesExecute the app as one or more stateless processes

Apps run as processes (duh)

No state: every node is independent

Caching is fine, but not for future use

State must be stored in backing services

Page 210: DSR Microservices (Day 1, Part 2)

VII. Port bindingExport services via port binding

Page 211: DSR Microservices (Day 1, Part 2)

VII. Port bindingExport services via port binding

Expose endpoints

http://localhost:5000/

test.mosquitto.org:1883

redis://redisbox:6379/0

Page 212: DSR Microservices (Day 1, Part 2)

VII. Port bindingExport services via port binding

Expose endpoints

No runtime injection or native APIs http://localhost:5000/

test.mosquitto.org:1883

redis://redisbox:6379/0

Page 213: DSR Microservices (Day 1, Part 2)

VII. Port bindingExport services via port binding

Expose endpoints

No runtime injection or native APIs

HTTP or other protocols make things easy

http://localhost:5000/

test.mosquitto.org:1883

redis://redisbox:6379/0

Page 214: DSR Microservices (Day 1, Part 2)

VIII. ConcurrencyScale out via the process model

Page 215: DSR Microservices (Day 1, Part 2)

VIII. ConcurrencyScale out via the process model

Processes are the unit of scaling

Page 216: DSR Microservices (Day 1, Part 2)

VIII. ConcurrencyScale out via the process model

Processes are the unit of scaling

Don’t daemonize!

Page 217: DSR Microservices (Day 1, Part 2)

VIII. ConcurrencyScale out via the process model

Processes are the unit of scaling

Don’t daemonize!

Take advantage of OS resource scaling

Page 218: DSR Microservices (Day 1, Part 2)

IX. DisposabilityMaximize robustness with fast startup and graceful shutdown

Page 219: DSR Microservices (Day 1, Part 2)

IX. DisposabilityMaximize robustness with fast startup and graceful shutdown

Can be started or stopped quickly (Cattle not pets)

Page 220: DSR Microservices (Day 1, Part 2)

IX. DisposabilityMaximize robustness with fast startup and graceful shutdown

Can be started or stopped quickly (Cattle not pets)

Quick startup allows easy scaling up

Graceful shutdown allows easy scaling down

Page 221: DSR Microservices (Day 1, Part 2)

IX. DisposabilityMaximize robustness with fast startup and graceful shutdown

Can be started or stopped quickly (Cattle not pets)

Quick startup allows easy scaling up

Graceful shutdown allows easy scaling down

Easier if you scale with independent processes...

Page 222: DSR Microservices (Day 1, Part 2)

X. Dev/prod parityKeep development, staging, and production as similar as possible

Page 223: DSR Microservices (Day 1, Part 2)

X. Dev/prod parityKeep development, staging, and production as similar as possible

Keep time between environment deploys low

Page 224: DSR Microservices (Day 1, Part 2)

X. Dev/prod parityKeep development, staging, and production as similar as possible

Keep time between environment deploys low

Devs also handle deployment and maintenance (DevOps)

Keep tooling between environments as similar as possible

Page 225: DSR Microservices (Day 1, Part 2)

X. Dev/prod parityKeep development, staging, and production as similar as possible

Keep time between environment deploys low

Devs also handle deployment and maintenance (DevOps)

Keep tooling between environments as similar as possible

If you can, try one environment...

Page 226: DSR Microservices (Day 1, Part 2)

XI. LogsTreat logs as event streams

Page 227: DSR Microservices (Day 1, Part 2)

XI. LogsTreat logs as event streams

Don’t mess around writing to files, just use stdout

Page 228: DSR Microservices (Day 1, Part 2)

XI. LogsTreat logs as event streams

Don’t mess around writing to files, just use stdout

In dev, you can watch stdout

In production, it can be routed to other stores (Splunk etc.)

Page 229: DSR Microservices (Day 1, Part 2)

XI. LogsTreat logs as event streams

Don’t mess around writing to files, just use stdout

In dev, you can watch stdout

In production, it can be routed to other stores (Splunk etc.)

Keeps aggregated logs time ordered (like Kafka)

Page 230: DSR Microservices (Day 1, Part 2)

XII. Admin processesRun admin/management tasks as one-off processes

Page 231: DSR Microservices (Day 1, Part 2)

XII. Admin processesRun admin/management tasks as one-off processes

One-off admin tasks (DB migrations etc.) should be run from production environment

Page 232: DSR Microservices (Day 1, Part 2)

XII. Admin processesRun admin/management tasks as one-off processes

One-off admin tasks (DB migrations etc.) should be run from production environment

Don’t run scripts from local machine or directly on the DB

Page 233: DSR Microservices (Day 1, Part 2)

XII. Admin processesRun admin/management tasks as one-off processes

One-off admin tasks (DB migrations etc.) should be run from production environment

Don’t run scripts from local machine or directly on the DB

Check in scripts to app repos to keep things in sync

Page 234: DSR Microservices (Day 1, Part 2)

One-off admin tasks (DB migrations etc.) should be run from production environment

Don’t run scripts from local machine or directly on the DB

Check in scripts to app repos to keep things in sync

ssh into production box and run the task

XII. Admin processesRun admin/management tasks as one-off processes

Page 235: DSR Microservices (Day 1, Part 2)

XII. Admin processesRun admin/management tasks as one-off processes

One-off admin tasks (DB migrations etc.) should be run from production environment

Don’t run scripts from local machine or directly on the DB

Check in scripts to app repos to keep things in sync

ssh into production box and run the task

...or don’t. Immutable Infrastructure!

Page 236: DSR Microservices (Day 1, Part 2)

1990 2000 2010 2015

Ord

er le

ad ti

me

(log(

ish)

)

< 1 sec

1 hour

1 week

6 months Data center

Virtual machines

Commercial cloud (AWS)

Docker

FaaS

5 secs

PaaS

Page 237: DSR Microservices (Day 1, Part 2)

Microservices or distributed systems?

Page 238: DSR Microservices (Day 1, Part 2)

The future of Microservices

Page 239: DSR Microservices (Day 1, Part 2)
Page 240: DSR Microservices (Day 1, Part 2)

Hardware lead times

1990 2000 2010 2015

Ord

er le

ad ti

me

(log(

ish)

)

< 1 sec

1 hour

1 week

6 months Data center

Virtual machines

Commercial cloud (AWS)

Docker

FaaS

5 secs

PaaS

Page 241: DSR Microservices (Day 1, Part 2)

Hardware lead times

1990 2000 2010 2015

Ord

er le

ad ti

me

(log(

ish)

)

< 1 sec

1 hour

1 week

6 months Data center

Virtual machines

Commercial cloud (AWS)

Docker

FaaS

5 secs

PaaS

Page 242: DSR Microservices (Day 1, Part 2)

Amazon Lambda

Serverless

‘Serverless’ (not really)

Function as a Service (FaaS)

No persistence, no upkeep costs

200 ms startup time (Node.js)

Page 243: DSR Microservices (Day 1, Part 2)

What is the role of a manager?

Page 244: DSR Microservices (Day 1, Part 2)

Managers

Page 245: DSR Microservices (Day 1, Part 2)

Managers

Provide guidance

Page 246: DSR Microservices (Day 1, Part 2)

Managers

Provide guidance

Keep things ‘safe’

Page 247: DSR Microservices (Day 1, Part 2)

Managers

Provide guidance

Keep things ‘safe’

Organise the team

Page 248: DSR Microservices (Day 1, Part 2)

Managers

Provide guidance

Keep things ‘safe’

Organise the team

Enable team to work

Page 249: DSR Microservices (Day 1, Part 2)

Managers Microservices

Provide guidance

Keep things ‘safe’

Organise the team

Enable team to work

Page 250: DSR Microservices (Day 1, Part 2)

Managers Microservices

Provide guidance

Keep things ‘safe’

Organise the team

Enable team to work

Explore new tech

Page 251: DSR Microservices (Day 1, Part 2)

Managers Microservices

Provide guidance

Keep things ‘safe’

Organise the team

Enable team to work

Explore new tech

Experiment

Page 252: DSR Microservices (Day 1, Part 2)

Managers Microservices

Provide guidance

Keep things ‘safe’

Organise the team

Enable team to work

Explore new tech

Experiment

Enables self-organisation

Page 253: DSR Microservices (Day 1, Part 2)

Managers Microservices

Provide guidance

Keep things ‘safe’

Organise the team

Enable team to work

Explore new tech

Experiment

Enables self-organisation

Tech empowers team

Page 254: DSR Microservices (Day 1, Part 2)
Page 255: DSR Microservices (Day 1, Part 2)

No managers (or other titles)

Programmers take responsibility

Expect/allow failure (remove fear)

Work directly with customers

Programmer Anarchy

Page 256: DSR Microservices (Day 1, Part 2)

Conclusion

Page 257: DSR Microservices (Day 1, Part 2)

Speed > efficiency

DevOps

Empower teams

Embrace the distributed world

Page 258: DSR Microservices (Day 1, Part 2)

Speed > efficiency

DevOps

Empower teams

Embrace the distributed world

Page 259: DSR Microservices (Day 1, Part 2)

Speed > efficiency

DevOps

Empower teams

Embrace the distributed world

Page 260: DSR Microservices (Day 1, Part 2)

Speed > efficiency

DevOps

Empower teams

Embrace the distributed world

Page 261: DSR Microservices (Day 1, Part 2)

“Microservices are hard. Some things you get for free, but you have to work for the good stuff. If you won’t put in the work, you shouldn’t be doing Microservices. (You should be doing that stuff

anyway!)”Steve Upton

Page 262: DSR Microservices (Day 1, Part 2)

“Microservices are hard. Some things you get for free, but you have to work for the good stuff. If you won’t put in the work, you shouldn’t be doing Microservices. (You should be doing that stuff

anyway!)”Steve Upton

Page 263: DSR Microservices (Day 1, Part 2)

“Microservices are hard. Some things you get for free, but you have to work for the good stuff. If you won’t put in the work, you shouldn’t be doing Microservices. (You should be doing that stuff

anyway!)”Steve Upton

Page 264: DSR Microservices (Day 1, Part 2)

“Microservices are hard. Some things you get for free, but you have to work for the good stuff. If you won’t put in the work, you shouldn’t be doing Microservices. (You should be doing that stuff

anyway!)”Steve Upton

Page 265: DSR Microservices (Day 1, Part 2)

“Microservices are hard. Some things you get for free, but you have to work for the good stuff. If you won’t put in the work, you shouldn’t be doing Microservices. (You should be doing that stuff

anyway!)”Steve Upton

Page 266: DSR Microservices (Day 1, Part 2)

“Microservices are hard. Some things you get for free, but you have to work for the good stuff. If you won’t put in the work, you shouldn’t be doing Microservices. (You should be doing that stuff

anyway!)”Steve Upton

Page 267: DSR Microservices (Day 1, Part 2)

Questions?@Steve_Uptonsteveupton.io

Page 270: DSR Microservices (Day 1, Part 2)

Referenceshttp://www.slideshare.net/BruceWong3/the-case-for-chaos

http://www.slideshare.net/fredgeorge

http://www.slideshare.net/dataloop/anne-currie-force12io-game-of-hosts-containers-vs-vms

https://www.nrdc.org/sites/default/files/data-center-efficiency-assessment-IB.pdf

https://martinjeeblog.com/2012/11/20/what-is-programmer-anarchy-and-does-it-have-a-future/

http://static.googleusercontent.com/media/research.google.com/en//people/jeff/Berkeley-Latency-Mar2012.pdf

http://apsblog.burtongroup.com/2009/01/soa-is-dead-long-live-services.html

Page 271: DSR Microservices (Day 1, Part 2)

References cont.http://www.ibm.com/developerworks/webservices/library/ar-esbpat1/

https://ocw.mit.edu/courses/aeronautics-and-astronautics/16-885j-aircraft-systems-engineering-fall-2005/

https://www.fogcreek.com/blog/eight-fallacies-of-distributed-computing-tech-talk/

http://www.ibiblio.org/harris/500milemail.html

http://www.lockheedmartin.com/content/dam/lockheed/data/corporate/documents/2015-Annual-Report.pdf

http://www.counterpunch.org/2013/03/04/when-money-is-no-object-the-strange-saga-of-the-f-35/

Page 275: DSR Microservices (Day 1, Part 2)

Image credits cont.https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19720013196.pdf