DEPLOYING AND SCALING MICROSERVICES
Sam Newman Goto Chicago 2016
DEPLOYING AND SCALING MICROSERVICES Sam Newman Goto Chicago 2016 - - PowerPoint PPT Presentation
DEPLOYING AND SCALING MICROSERVICES Sam Newman Goto Chicago 2016 @samnewman Building Microservices DESIGNING FINE - GRAINED SYSTEMS Sam Newman @samnewman Core Principles @samnewman Core Principles Artifacts @samnewman Core Principles
Sam Newman Goto Chicago 2016
@samnewman
@samnewman
Sam Newman
DESIGNING 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
@samnewman
Accounts Returns v345 Invoicing Inventory Customer Service Shipping v123
@samnewman
Accounts Invoicing Shipping v456 Inventory Customer Service Returns v890
@samnewman
https://www.flickr.com/photos/torkildr/3462607995/
@samnewman
Tests Build Performance Prod UAT https://www.flickr.com/
@samnewman
Tests Build Performance Prod UAT https://www.flickr.com/
Source Control
@samnewman
Tests Build Performance Prod UAT https://www.flickr.com/
Source Control
@samnewman
Tests Build Performance Prod UAT https://www.flickr.com/
Source Control
@samnewman
Tests Build Performance Prod UAT https://www.flickr.com/
Source Control
@samnewman
Tests Build Performance Prod UAT https://www.flickr.com/
Source Control
@samnewman
Tests Build Performance Prod UAT https://www.flickr.com/
Source Control
@samnewman
Tests Build Performance Prod UAT https://www.flickr.com/
Source Control
@samnewman
Tests Build Performance Prod UAT https://www.flickr.com/
Source Control
@samnewman
Tests Build Performance Prod UAT https://www.flickr.com/
Source Control
Same Deployment Process Everywhere
@samnewman
@samnewman
Service Name
@samnewman
Service Name Version
@samnewman
local Service Name Version
@samnewman
local latest Service Name Version
@samnewman
local latest Service Name Version Environment
@samnewman
Tests Build Large Tests UAT Prod
DB Machine UAT Environment Machine
Perf
@samnewman
Tests Build UAT Perf Prod
Master DB Machine Production Environment Machine Machine Machine Slave DB
@samnewman
@samnewman
@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
@samnewman
Tarballs Easy to create Easy to deploy Abstract out the tech stack Good for dev, good for ops
@samnewman
Tarballs Easy to create
Abstract out the tech stack Good for dev, good for ops
@samnewman
Tarballs Easy to create
Good for dev, good for ops
@samnewman
Tarballs Easy to create
@samnewman
Tarballs Easy to create
@samnewman
Stack-specific
@samnewman
Stack-specific
@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
Easy to deploy Good for dev, good for ops
@samnewman
Stack-specific Easy to create
Easy to deploy
@samnewman
Stack-specific Easy to create
@samnewman
Stack-specific Easy to create
@samnewman
@samnewman
@samnewman
OS-Specific
@samnewman
OS-Specific
@samnewman
OS-Specific
@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
Good for dev, good for ops
@samnewman
OS-Specific Easy to deploy
Good for dev, good for ops
@samnewman
OS-Specific Easy to deploy
@samnewman
OS-Specific Easy to deploy
@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
@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
Good for dev, good for ops
@samnewman
Custom Images Easy to deploy
Good for dev, good for ops
@samnewman
Custom Images Easy to deploy
Good for dev, good for ops
@samnewman
Custom Images Easy to deploy
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
@samnewman
@samnewman
@samnewman
@samnewman
@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:
volumes:
links:
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 Does
@samnewman
Doesn’t rebalance Doesn’t restart failed containers Does Does
@samnewman
Doesn’t rebalance Doesn’t restart failed containers Plays nice with the rest of docker Does Does
@samnewman
Doesn’t rebalance Doesn’t restart failed containers Plays nice with the rest of docker Case studies thin on the ground Does Does
@samnewman
@samnewman
Mesos Master MESOS
@samnewman
Mesos Master MESOS
@samnewman
Mesos Master Mesos Agent Mesos Agent Mesos Agent MESOS
@samnewman
@samnewman
@samnewman
@samnewman
@samnewman
@samnewman
Mesos Master Mesos Agent Mesos Agent Mesos Agent MESOS
@samnewman
Mesos Master Mesos Agent Mesos Agent Mesos Agent MESOS 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
@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
@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
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
@samnewman
@samnewman
@samnewman
@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
DESIGNING FINE-GRAINED SYSTEMS
http://samnewman.io/podcast
@samnewman snewman@thoughtworks.com