Deploying and Testing Microservices

Post on 07-Nov-2014

349 views 5 download

Tags:

description

Sam Newman is a technologist at ThoughtWorks. This talk from FlowCon 2014 goes into the nitty gritty of managing build, test and release of microservices and also covers the often ignored tradeoff between testing before deployment, and testing afterwards.

Transcript of Deploying and Testing Microservices

TESTING & DEPLOYING MICROSERVICESSam Newman Flowcon, September 2014

1

@samnewman@flowconsf

Accounts

Returns

Invoicing

Shipping

Inventory

Customer Service

@samnewman@flowconsf

Accounts

Returns

Invoicing

Shipping

Inventory

Customer Service

Focused around a business domain

@samnewman@flowconsf

Accounts

Returns

Invoicing

Shipping

Inventory

Customer Service

Focused around a business domain

Technology Agnostic API

@samnewman@flowconsf

Accounts

Returns

Invoicing

Shipping

Inventory

Customer Service

Focused around a business domain

Technology Agnostic API

Small

@samnewman@flowconsf

Independently Releasable

@samnewman@flowconsf

Testing

Deployment

@samnewman@flowconsf

Host

Service

@samnewman@flowconsf

Host

Service

Host

Service Service

Service Service

VS

@samnewman@flowconsf

Host

Service

Host

Service Service

Service Service

Much Easier To Reason About

VS

@samnewman@flowconsf

Host

Service

Host

Service Service

Service Service

Much Easier To Reason About

Easier To Provision

VS

@samnewman@flowconsf

Host

Service

Host

Service Service

Service Service

Much Easier To Reason About

Easier To Provision

Fewer Side-effects

VS

@samnewman@flowconsf

Host

Service

Host

Service Service

Service Service

Much Easier To Reason About

Easier To Provision

Fewer Side-effects

VS

Enforces Interdependence

@samnewman@flowconsf

Host

Service

Host

Service Service

Service Service

Much Easier To Reason About

Easier To Provision

Fewer Side-effectsLower host-management overhead

VS

Enforces Interdependence

@samnewman@flowconsf

Host

Service

Host

Service Service

Service Service

Much Easier To Reason About

Easier To Provision

Fewer Side-effectsCheaper!

Lower host-management overhead

VS

Enforces Interdependence

@samnewman@flowconsf

Reducing Host Management Overhead?

@samnewman@flowconsf

API-driven Host Provisioning

@samnewman@flowconsf

Virtualisation Platforms

@samnewman@flowconsf

VMWare

Virtualisation Platforms

@samnewman@flowconsf

VMWareAWS

Digital Ocean

Virtualisation Platforms

@samnewman@flowconsf

Step 0: Provision Host

@samnewman@flowconsf

Step 0: Provision Host

Step 1: Configure Host

@samnewman@flowconsf

Step 0: Provision Host

Step 2: Install Service

Step 1: Configure Host

@samnewman@flowconsf

Step 0: Provision Host

Step 2: Install Service

Step 1: Configure Host

@samnewman@flowconsf

@samnewman@flowconsf

Ansible

Puppet

Chef

@samnewman@flowconsf

Ansible

Puppet

Chef

@samnewman@flowconsf

Ansible

Puppet

Chef

AWS

Digital Ocean

OpenStack

VMWare

@samnewman@flowconsf

Ansible

Puppet

Chef

AWS

Digital Ocean

OpenStack

VMWare

Vagrant

@samnewman@flowconsf

Ansible

Puppet

Chef

AWS

Digital Ocean

OpenStack

VMWare

Vagrant

Immutable Servers

@samnewman@flowconsf

Ansible

Puppet

Chef

AWS

Digital Ocean

OpenStack

VMWare

Vagrant

Immutable Servers

Fast Spin-up

@samnewman@flowconsf

Ansible

Puppet

Chef

AWS

Digital Ocean

OpenStack

VMWare

Vagrant

Immutable Servers

Fast Spin-up

Provider Agnostic

@samnewman@flowconsf

Ansible

Puppet

Chef

AWS

Digital Ocean

OpenStack

VMWare

Vagrant

Immutable Servers

Fast Spin-up

Provider Agnostic

Feedback Can Suffer

@samnewman@flowconsf

Ansible

Puppet

Chef

AWS

Digital Ocean

OpenStack

VMWare

Vagrant

Immutable Servers

Fast Spin-up

Provider Agnostic

Feedback Can Suffer

Cycle Time

@samnewman@flowconsf

Immutable Servers

@samnewman@flowconsf

Cost?

@samnewman@flowconsf

Machine

Base OS

Hypervisor

VM

OS

Apps

VM

OS

Apps

VM

OS

Apps

@samnewman@flowconsf

Machine

Base OS

Hypervisor

VM

OS

Apps

VM

OS

Apps

VM

OS

Apps

Expensive!

@samnewman@flowconsf

@samnewman@flowconsf

@samnewman@flowconsf

DOCKER

@samnewman@flowconsf

DOCKER

Machine

@samnewman@flowconsf

DOCKER

Machine

Base OS

@samnewman@flowconsf

DOCKER

Machine

Base OS

Docker

@samnewman@flowconsf

DOCKER

Machine

Base OS

Docker

Apps

@samnewman@flowconsf

DOCKER

Machine

Base OS

Docker

Apps Apps

@samnewman@flowconsf

DOCKER

Machine

Base OS

Docker

Apps Apps Apps

@samnewman@flowconsf

DOCKER

Machine

Base OS

Docker

Apps Apps Apps

Docker Image Registry

@samnewman@flowconsf

DOCKER

Machine

Base OS

Docker

Apps Apps Apps

Docker Image Registry

@samnewman@flowconsf

DOCKER

Machine

Base OS

Docker

Apps Apps Apps

Docker Image Registry

@samnewman@flowconsf

@samnewman@flowconsf

@samnewman@flowconsf

Semi-permanent Servers

@samnewman@flowconsf

Semi-permanent Servers

Image-based Deployments

@samnewman@flowconsf

Semi-permanent Servers

Image-based Deployments

Docker

@samnewman@flowconsf

Testing

@samnewman@flowconsf

The Monolith

DB

@samnewman@flowconsf

The Monolith

DB

@samnewman@flowconsf

The Monolith

DB

@samnewman@flowconsf

The Monolith

DB

@samnewman@flowconsf

InventoryAccounts

Returns

Invoicing

Shipping

Customer Service

@samnewman@flowconsf

InventoryAccounts

Returns

Invoicing

Shipping

Customer Service

Inventory

@samnewman@flowconsf

InventoryAccounts

Returns

Invoicing

Shipping

Customer Service

Inventory

@samnewman@flowconsf

Inventory Accounts

Mountebank http://www.mbtest.org

@samnewman@flowconsf

InventoryAccounts!Stub

Mountebank http://www.mbtest.org

@samnewman@flowconsf

Shipping

InventoryAccounts

Returns

Invoicing

Customer Service

@samnewman@flowconsf

Shipping

InventoryAccounts

Returns

Invoicing

Customer Service

@samnewman@flowconsf

Shipping

InventoryAccounts

Returns

Invoicing

Customer Service

@samnewman@flowconsf

Shipping

InventoryAccounts

Returns

Invoicing

Customer Service

@samnewman@flowconsf

Shipping

InventoryAccounts

Returns

Invoicing

Customer Service

@samnewman@flowconsf

@samnewman@flowconsf

Browsers

@samnewman@flowconsf

Timing

Browsers

@samnewman@flowconsf

Provisioning of Environments

Timing

Browsers

@samnewman@flowconsf

Provisioning of Environments

Networks

Timing

Browsers

@samnewman@flowconsf

Deployment

Provisioning of Environments

Networks

Timing

Browsers

@samnewman@flowconsf

Deployment

Provisioning of Environments

Networks

Timing

Browsers Diagnosis

@samnewman@flowconsf

Shipping Inventory

CONSUMER-DRIVEN CONTRACTS

@samnewman@flowconsf

Expectations

Shipping Inventory

CONSUMER-DRIVEN CONTRACTS

@samnewman@flowconsf

Expectations

Shipping Inventory

CONSUMER-DRIVEN CONTRACTS

@samnewman@flowconsf

Expectations

Prod

Shipping Inventory

CONSUMER-DRIVEN CONTRACTS

@samnewman@flowconsf

Expectations

Prod

Shipping Inventory

CONSUMER-DRIVEN CONTRACTS

@samnewman@flowconsf

@samnewman@flowconsf

https://github.com/realestate-com-au/pact

@samnewman@flowconsf

No Integration Tests?

@samnewman@flowconsf

Journeys

@samnewman@flowconsf

Testing

@samnewman@flowconsf

Testing

S/M TestsBuild Large Tests

@samnewman@flowconsf

Testing

S/M TestsBuild Large Tests

@samnewman@flowconsf

Testing

S/M TestsBuild Large Tests Production

@samnewman@flowconsf

Testing

S/M TestsBuild Large Tests Production

Monitoring & Alerting

@samnewman@flowconsf

Testing

S/M TestsBuild Large Tests Production

Monitoring & Alerting

Testers

@samnewman@flowconsf

Testing

S/M TestsBuild Large Tests Production

Monitoring & Alerting

Testers Operations

@samnewman@flowconsf

Monitoring & AlertingTesting

@samnewman@flowconsf

Prod

Prod

Prod

Prod

@samnewman@flowconsf

Prod

Prod

Prod

Prod

QA

@samnewman@flowconsf

Monitoring & Alerting

Testing

@samnewman@flowconsf

Monitoring & Alerting

Testing

@samnewman@flowconsf

Monitoring & Alerting

Testing

@samnewman@flowconsf

Monitoring & Alerting

Testing

@samnewman@flowconsf

@samnewman@flowconsf

@samnewman@flowconsf

SEMANTIC MONITORING

@samnewman@flowconsfhttps://www.flickr.com/photos/robdray/3138644233

@samnewman@flowconsf

Testing

Deployment

@samnewman@flowconsf

Testing

Deployment

One-server per host

@samnewman@flowconsf

Testing

Deployment

One-server per host

Image/docker based artefacts

@samnewman@flowconsf

Testing

Deployment

One-server per host Immutable ServersImage/docker

based artefacts

@samnewman@flowconsf

Testing

Pre-Release Validation

Consumer-driven Contracts

Single-server Tests

Journey Tests

Deployment

One-server per host Immutable ServersImage/docker

based artefacts

@samnewman@flowconsf

Testing

Post-Release Validation

Semantic Monitoring

Pre-Release Validation

Consumer-driven Contracts

Single-server Tests

Journey Tests

Deployment

One-server per host Immutable ServersImage/docker

based artefacts

37

Sam Newman

Building MicroservicesDESIGNING FINE-GRAINED SYSTEMS

Any questions: @samnewman

snewman@thoughtworks.com

THANKS!