DEPLOYING AND SCALING MICROSERVICESSam Newman YOW! 2015
@samnewman
@samnewman
Sam Newman
Building MicroservicesDESIGNING FINE-GRAINED SYSTEMS
@samnewman
Core Principles
@samnewman
Artifacts
Core Principles
@samnewman
Artifacts
Core Principles
Platforms
@samnewman
Artifacts
Core Principles
Platforms
@samnewman
Accounts
Returns
Invoicing
Shipping
Inventory
Customer Service
@samnewman
Independent Deployability
@samnewman
Accounts
Returns v345
Invoicing
Inventory
Customer Service
Shipping v123
@samnewman
AccountsInvoicing
Shipping v456
Inventory
Customer Service
Returns v890
@samnewman
https://www.flickr.com/photos/torkildr/3462607995/
@samnewman
TestsBuild Performance ProdUAT
https://www.flickr.com/
@samnewman
TestsBuild Performance ProdUAT
https://www.flickr.com/
Source Control
@samnewman
TestsBuild Performance ProdUAT
https://www.flickr.com/
Source Control
@samnewman
TestsBuild Performance ProdUAT
https://www.flickr.com/
Source Control
@samnewman
TestsBuild Performance ProdUAT
https://www.flickr.com/
Source Control
!
@samnewman
TestsBuild Performance ProdUAT
https://www.flickr.com/
Source Control
! !
@samnewman
TestsBuild Performance ProdUAT
https://www.flickr.com/
Source Control
! ! !
@samnewman
TestsBuild Performance ProdUAT
https://www.flickr.com/
Source Control
! ! !
@samnewman
TestsBuild Performance ProdUAT
https://www.flickr.com/
Source Control
! ! !
One Artifact For All Environments
@samnewman
TestsBuild Performance ProdUAT
https://www.flickr.com/
Source Control
! ! !
One Artifact For All Environments
Same Deployment Process Everywhere
@samnewman
$ deploy Returns v456 Production
@samnewman
$ deploy Returns v456 Production
Service Name
@samnewman
$ deploy Returns v456 Production
Service Name Version
@samnewman
$ deploy Returns v456 Production
local
Service Name Version
@samnewman
$ deploy Returns v456 Production
locallatest
Service Name Version
@samnewman
$ deploy Returns v456 Production
locallatest
Service Name Version
Environment
@samnewman
TestsBuild Large TestsUAT Prod
DB
Machine
UAT Environment
Machine
Perf
@samnewman
TestsBuild UAT Perf
Master DB
Machine
Perf Environment
Machine Machine Machine
Slave DB
Perf Prod
@samnewman
TestsBuild UAT Perf Prod
Master DB
Machine
Production Environment
Machine Machine Machine
Slave DB
@samnewman
Same Artifact
@samnewman
Same Artifact
Different Topology
@samnewman
Core Principles?
@samnewman
Independent Deployability
Core Principles?
@samnewman
Independent Deployability
One Artifact For All Environments
Core Principles?
@samnewman
Independent Deployability
One Artifact For All Environments
Same Deployment Process Everywhere
Core Principles?
@samnewman
Artifacts
Core Principles
Platforms
@samnewman
What do we want from an artifact?
@samnewman
What do we want from an artifact?
@samnewman
What do we want from an artifact?
Easy to create
@samnewman
What do we want from an artifact?
Easy to deploy
Easy to create
@samnewman
What do we want from an artifact?
Easy to deploy
Abstract out the tech stack
Easy to create
@samnewman
What do we want from an artifact?
Easy to deploy
Abstract out the tech stack
Good for dev, good for ops
Easy to create
@samnewman
Tarballs
@samnewman
Tarballs
Giant bundles of stuff
@samnewman
Tarballs
Easy to create
Easy to deploy
Abstract out the tech stack
Good for dev, good for ops
@samnewman
Tarballs
Easy to create!
Easy to deploy
Abstract out the tech stack
Good for dev, good for ops
@samnewman
Tarballs
Easy to create!
Easy to deploy"
Abstract out the tech stack
Good for dev, good for ops
@samnewman
Tarballs
Easy to create!
Easy to deploy"
Abstract out the tech stack#
Good for dev, good for ops
@samnewman
Tarballs
Easy to create!
Easy to deploy"
Abstract out the tech stack#
Good for dev, good for ops"
@samnewman
Stack-specific
@samnewman
Stack-specific
nuget
jar
pip
gems
@samnewman
Stack-specific
Easy to create
Abstract out the tech stack
Easy to deploy
Good for dev, good for ops
@samnewman
Stack-specific
Easy to create!
Abstract out the tech stack
Easy to deploy
Good for dev, good for ops
@samnewman
Stack-specific
Easy to create!
Abstract out the tech stack
Easy to deploy#
Good for dev, good for ops
@samnewman
Stack-specific
Easy to create!
Abstract out the tech stack"
Easy to deploy#
Good for dev, good for ops
@samnewman
Stack-specific
Easy to create!
Abstract out the tech stack"
Easy to deploy#
Good for dev, good for ops"
@samnewman
Everything in Go is Awesome
@samnewman
Everything in Go is Awesome
FACT
@samnewman
OS-Specific
@samnewman
OS-Specific
$ sudo apt-get install myservice
@samnewman
OS-Specific
$ sudo apt-get install myservice
$ deploy Returns v456 Production
@samnewman
OS-Specific
Easy to deploy
Easy to create
Abstract out the tech stack
Good for dev, good for ops
@samnewman
OS-Specific
Easy to deploy
Easy to create"
Abstract out the tech stack
Good for dev, good for ops
@samnewman
OS-Specific
Easy to deploy!
Easy to create"
Abstract out the tech stack
Good for dev, good for ops
@samnewman
OS-Specific
Easy to deploy!
Easy to create"
Abstract out the tech stack!
Good for dev, good for ops
@samnewman
OS-Specific
Easy to deploy!
Easy to create"
Abstract out the tech stack!
Good for dev, good for ops#
@samnewman
Build
@samnewman
Build
Deb Repo
@samnewman
Host
Build
Deb Repo
@samnewman
Host
Build
Deb Repo
@samnewman
Host
Build
Deb Repo
@samnewman
@samnewman
A v1.5
@samnewman
A v2.1
A v1.5
@samnewman
A v2.1
A v1.5
@samnewman
Host
@samnewman
Host
@samnewman
Host Host
Host Host
@samnewman
Host Host
Host Host
Independent Execution Environments FTW!
@samnewman
Custom Images
Easy to deploy
Easy to create
Abstract out the tech stack
Good for dev, good for ops
@samnewman
Custom Images
Easy to deploy
Easy to create#
Abstract out the tech stack
Good for dev, good for ops
@samnewman
Custom Images
Easy to deploy#
Easy to create#
Abstract out the tech stack
Good for dev, good for ops
@samnewman
Custom Images
Easy to deploy#
Easy to create#
Abstract out the tech stack
Good for dev, good for ops
!
@samnewman
Custom Images
Easy to deploy#
Easy to create#
Abstract out the tech stack
Good for dev, good for ops
!
#
@samnewman
@samnewman
@samnewman
Cost of isolated hosts is reduced…
@samnewman
Cost of isolated hosts is reduced…
…in terms of effort…
@samnewman
Cost of isolated hosts is reduced…
…in terms of effort…
…and computing resources
@samnewman
Docker!
Easy to deploy
Abstract out the tech stack
Good for dev, good for ops
Easy to create
@samnewman
Docker!
Easy to deploy
Abstract out the tech stack
Good for dev, good for ops
Easy to create#
@samnewman
Docker!
Easy to deploy
Abstract out the tech stack
Good for dev, good for ops
Easy to create
!
#
@samnewman
Docker!
Easy to deploy
Abstract out the tech stack
Good for dev, good for ops
Easy to create
!
!
#
@samnewman
Docker!
Easy to deploy
Abstract out the tech stack
Good for dev, good for ops
Easy to create
!
!
#
#
@samnewman
Artifacts
Core Principles
Platforms
@samnewman
What do we want from our deployment platform?
@samnewman
What do we want from our deployment platform?
Separate artifact from topology
@samnewman
What do we want from our deployment platform?
Separate artifact from topology
Makes handling lots of services easy!
@samnewman
What do we want from our deployment platform?
Separate artifact from topology
Makes handling lots of services easy!
Supports docker images
@samnewman
Deployment Platforms?
@samnewman
Docker Swarm
@samnewman
Docker Swarm
@samnewman
Docker Swarm
@samnewman
Docker Swarm
@samnewman
DOCKER SWARM
@samnewman
DOCKER SWARM
Swarm Manager
@samnewman
DOCKER SWARM
Swarm Node Swarm Node Swarm Node
Swarm Manager
@samnewman
DOCKER SWARM
Swarm Node Swarm Node Swarm Node
Swarm Manager
@samnewman
DOCKER SWARM
Swarm Node Swarm Node Swarm Node
Swarm Manager
$ docker …
@samnewman
DOCKER SWARM
Swarm Node Swarm Node Swarm Node
Swarm Manager
$ docker …
@samnewman
DOCKER SWARM
Swarm Node Swarm Node Swarm Node
Swarm Manager
$ docker …
@samnewman
DOCKER SWARM
Swarm Node Swarm Node Swarm Node
Swarm Manager
$ docker …
@samnewman
SCHEDULING STRATEGIES - BINPACK
Swarm Node Swarm Node Swarm Node
Swarm Manager
@samnewman
SCHEDULING STRATEGIES - BINPACK
Swarm Node Swarm Node Swarm Node
Swarm Manager
@samnewman
SCHEDULING STRATEGIES - SPREAD
Swarm Node Swarm Node Swarm Node
Swarm Manager
@samnewman
SCHEDULING STRATEGIES - SPREAD
Swarm Node Swarm Node Swarm Node
Swarm Manager
@samnewman
DOCKER COMPOSE
web: build: . ports: - "5000:5000" volumes: - .:/code links: - redis
redis: image: redis
@samnewman
@samnewman
Doesn’t rebalance
@samnewman
Doesn’t rebalance
Doesn’t restart failed containers
@samnewman
Doesn’t rebalance
Doesn’t restart failed containers
Plays nice with the rest of docker
@samnewman
Doesn’t rebalance
Doesn’t restart failed containers
Plays nice with the rest of docker
Case studies thin on the ground
@samnewman
@samnewman
Mesos Master
MESOS
@samnewman
Mesos Master
MESOS
@samnewman
Mesos Master
Mesos Agent Mesos Agent Mesos Agent
MESOS
@samnewman
Frameworks!
@samnewman
@samnewman
Frameworks
@samnewman
Frameworks
Scheduler
@samnewman
Frameworks
Scheduler Executor
@samnewman
Mesos Master
Mesos Agent Mesos Agent Mesos Agent
MESOS
@samnewman
Mesos Master
Mesos Agent Mesos Agent Mesos Agent
MESOSHadoop Scheduler
@samnewman
Mesos Master
Mesos Agent Mesos Agent Mesos Agent
MESOS
Hadoop Executor
Hadoop Scheduler
@samnewman
Mesos Master
Mesos Agent Mesos Agent Mesos Agent
MESOS
Hadoop Executor
Hadoop Scheduler
@samnewman
Mesos Master
Mesos Agent Mesos Agent Mesos Agent
MESOS
Hadoop Executor
Hadoop Scheduler
Hadoop
@samnewman
Mesos Master
Mesos Agent Mesos Agent Mesos Agent
MESOS
Hadoop Executor
Hadoop Scheduler
Hadoop
Marathon
Marathon
@samnewman
Mesos Master
Mesos Agent Mesos Agent Mesos Agent
MESOS
Hadoop Executor
Hadoop Scheduler
Hadoop
Marathon
Marathon
Marathon Scheduler
@samnewman
Mesos Master
Mesos Agent Mesos Agent Mesos Agent
MESOS
Hadoop Executor
Hadoop Scheduler
Hadoop
Marathon
Marathon
Marathon Scheduler
@samnewman
OTHER FRAMEWORKS…
https://github.com/alde/eremetic
@samnewman
AWS Lambda
@samnewman
@samnewman
Great if you need to run other workloads
@samnewman
Great if you need to run other workloads
Really powerful - fully featured, widely used
@samnewman
Great if you need to run other workloads
Really powerful - fully featured, widely used
Fairly complex - lots of moving parts
@samnewman
@samnewman
@samnewman
KUBERNETES ARCHITECTURE…SORT OF
@samnewman
API Server
KUBERNETES ARCHITECTURE…SORT OF
@samnewman
API Server
KUBERNETES ARCHITECTURE…SORT OF
@samnewman
API Server
Kubelet Kubelet Kubelet
KUBERNETES ARCHITECTURE…SORT OF
@samnewman
API Server
Kubelet Kubelet Kubelet
$ kubectl …
KUBERNETES ARCHITECTURE…SORT OF
@samnewman
API Server
Kubelet Kubelet Kubelet
$ kubectl …
KUBERNETES ARCHITECTURE…SORT OF
@samnewman
PODS?
@samnewman
A collection of tightly coupled containers, running on one node
PODS?
@samnewman
A collection of tightly coupled containers, running on one node
PODS?
Can have metadata, volumes too
@samnewman
A collection of tightly coupled containers, running on one node
PODS?
Can have metadata, volumes too
Pods are mortal - not long running!
@samnewman
A collection of tightly coupled containers, running on one node
PODS?
Can have metadata, volumes too
Pods are mortal - not long running!
A pod = a unit of scheduling
@samnewman
SERVICES!
@samnewman
SERVICES!
{ "kind": "Service", "apiVersion": "v1", "metadata": { "name": "my-service" }, "spec": { "selector": { "app": "MyApp" }, "ports": [ { "protocol": "TCP", "port": 80, "targetPort": 9376 } ] } }
@samnewman
SERVICES!
A mapping of metadata and ports
to a set of pods
{ "kind": "Service", "apiVersion": "v1", "metadata": { "name": "my-service" }, "spec": { "selector": { "app": "MyApp" }, "ports": [ { "protocol": "TCP", "port": 80, "targetPort": 9376 } ] } }
@samnewman
JSON is neither human readable nor human writeable
@samnewman
JSON is neither human readable nor human writeable
Please stop using it for anything other than machines
@samnewman
Kubelet
@samnewman
Kubelet
@samnewman
Kubelet
@samnewman
Kubelet
Service Proxy
@samnewman
Kubelet
Service Proxy
:80
@samnewman
You don’t scale a service…
Kubelet
Service Proxy
:80
@samnewman
You don’t scale a service…
…you scale the pods!
Kubelet
Service Proxy
:80
@samnewman
@samnewman
Simpler to setup than Mesos - but more single purpose too
@samnewman
Simpler to setup than Mesos - but more single purpose too
Closer to a PAAS
@samnewman
Simpler to setup than Mesos - but more single purpose too
Closer to a PAAS
Pods can be confusing!
@samnewman
Simpler to setup than Mesos - but more single purpose too
Closer to a PAAS
Fairly new, but a growing amount of impressive support
Pods can be confusing!
@samnewman
Docker Swarm
@samnewman
Docker Swarm
@samnewman
Docker Swarm
@samnewman
Docker Swarm
@samnewman
@samnewman
Core Principles
@samnewman
Core Principles
Independent Deployability
@samnewman
Core Principles
One Artifact For All Environments
Independent Deployability
@samnewman
Core Principles
One Artifact For All Environments
Independent Deployability
Same Deployment
Process
@samnewman
Core Principles
One Artifact For All Environments
Independent Deployability
Same Deployment
Process
Docker Images As Artifacts
@samnewman
Core Principles
One Artifact For All Environments
Independent Deployability
Same Deployment
Process
Docker Images As Artifacts
Criteria For Selecting A Platform
@samnewman
@samnewman
Sam Newman
Building MicroservicesDESIGNING FINE-GRAINED SYSTEMS
AUTHD
@samnewman
Sam Newman
Building MicroservicesDESIGNING FINE-GRAINED SYSTEMS
AUTHD
Send me your questions on twitter!
@samnewman
Sam Newman
Building MicroservicesDESIGNING FINE-GRAINED SYSTEMS
AUTHD
Send me your questions on twitter!
@samnewman
@samnewman
Sam Newman
Building MicroservicesDESIGNING FINE-GRAINED SYSTEMS
AUTHD
Send me your questions on twitter!
@samnewman
And I’ll write up an answer for you!