SlideShare a Scribd company logo
Building a smarter application stack
Tomas	
  Doran	
  
@bobtfish	
  
2014-­‐06-­‐10
Docker is the future
• Preaching to the converted here ;)

• Game changing technology

• No silver bullets (ever)
• Introduces it’s own set of problems and issues
• Dependency discovery / wiring
• Scheduling
2
Smartstack
• One possible solution to discovery
problems

• This talk:
• Application architecture
• Problem(s) we’re solving
• Why this solution works well for us
• Alternate solutions
3
Microservices - also the future!
• The same as SOA
• But one API per service.
• Own data store!

• Lots of services (dozens, maybe 100s)

• All individually very simple
• Easy to reason about.
• Easy to replace
4
Don’t break the site - ever!!!
• Microservices are individually deployable!
• When we say “Don’t break the site”
• We mean
• Don’t break all of the site!
5
Don’t break the site - ever!!!
• If you have graceful degradation…
• You can ignore MTBF in the backend services!
• You only care about MTTR.
6
“I’ll just break this out into it’s own
application, as it’ll be easier to
maintain in 10 years time”
- Pre seed funding
nobody, ever!
7
Monolith - the reality
• Everyone has one of these :)
• If you’re far enough down the path, you call
this ‘The presentation layer’.

• Still poses a challenge
• need async requests
• need graceful degradation
8
Monolith - the reality
• Most popular service

• Most dependencies
• Call into 10s or 100s of other services in a
request!

• Needs circuit breakers + dynamic
configuration
9
No silver bullet = No one solution
• You should always have 2.
• Nagios / Sensu
• RRDs + Ganglia / Graphite + Diamond
• YAML files / Zookeeper
10
No silver bullet = No one solution
• ‘Top down’ architecture sucks.
• Instead, broad goals + ’Bottom up’ architecture
• Internal competition!
• Replacing the incumbent solution happens
organically
• If your thing works better, people will want to
move! 

• Not perfect! Better than top-down!
11
“Humans are bad at predicting the performance of
complex systems […]. Our ability to create large
and complex systems fools us into believing that
we’re also entitled to understand them”

- Carlos Bueno “Mature optimization handbook”

12
Distributed complexity
• Distributed systems introduce their own set of complexity
• Reasoning about the whole system challenging
• Timing/profiling/performance analysis non-trivial
• Resource scheduling also non-trivial
• 2nd order effects
!
• Can’t reason about emergent behavior
13
14
15
?
16
?
What the heck happened at 16:46?
17
?
And why did it stop at 17:00?
Dynamic architecture
• Cattle not pets
• AWS and VMs in ‘the cloud’ started this
• Docker takes it a step further

• Explicitly manage persistent state
• Explicit regular recycling
• All updates are redeploys

18
Dependency nightmares
• Almost everything has some dependencies
• Simple example, web app with a mysql DB
• App config in a YAML file

• Mysql container address changes when you restart mysql!
• Oops, app can’t find mysql!

• Do I need to restart every application using mysql?
• Sucks!
• Do I need to rebuild application containers using mysql?
• To edit the config YAML file!
• Super super sucks! 19
Runtime wiring
• mysql failovers - the simple case!

• Presentation layer talking to service REST layers
• Different deployment schedules
• No downtime

• Only possible solution: wiring dependencies at runtime
• A challenge
• Also an opportunity

• DNS is workable in some cases
20
Dynamic discovery
• Discovery becomes a core problem

• DNS re-resolving not generally trustworthy
• You need to test everything for this

• DNS balancing (internally) is awful
• Failed node + multiple connections/requests
• DNS round robin
• Everything sees failure
• Slow to shift traffic
• Round robin is crappy for load balancing

21
Externalized wiring
• Remove a lot of complexity from the application domain

• Run a load balancer (haproxy) on each machine

• Applications always connect to load balancer on fixed
host/port
• localhost on traditional metal/VMs
• supplied by —link or environment variables in Docker

• Applications become wiring agnostic!
22
Externalized wiring
23
‘Client side load balancing’
• Lots of projects use this approach:
• Project Atomic
• Marathon + Mesos-Docker
• vulcand (https://github.com/mailgun/vulcand)
• Frontrunner (https://github.com/Wizcorp/
frontrunner)
• Consul
!
• Smartstack
24
Legacy infrastructure
• Physical machines
• Application images in AMIs
• kvm

• Can’t just use container links or a Docker only
solution

• Want to use the same (uniform) solution
everywhere.
25
Entropy reduction
• You can’t change everything at once!

• Everything will tend towards chaos
• ‘Old infrastructure’
• ‘New infrastructure’
• ‘New new infrastructure’
!
• Solution specifically chosen so it could be generic.
26
SmartStack
• 2 parts
• Synapse
• Nerve
!
• Conceptually simple
• Very flexible
• Easy to hack on
• Plays well on traditional machines
• Plays well in docker
27
Synapse
• Does discovery against a pluggable backend
• Writes out a haproxy configuration

• Assign a well known port to all services
• Application connects to that port
• haproxy forwards to an available backend

• Your application doesn’t need to know about discovery!

• Technology agnostic - works the same on metal/VMs/Docker
28
29
Why synapse?
• haproxy is a well known solution
• ruby - easy to modify
• simple (has one job)
• Pluggable - discovery with multiple methods:
• JSON config (static)
• zookeeper
• etcd
• docker API
• ec2 tags
• Flexible
• Deploy one per instance
• Or pairs as dedicated lbs 30
Nerve
• Health checks services
• Health checks are pluggable.
• HTTP (flexible) + mysql come out the box
• Registers service information to backend
• zookeeper
• etcd (beta)
31
32
Connector agnostic containers
• On ‘real servers’ or VMs, running a synapse
instance per box is fine.

• In docker, we want to abstract more than that
• Make containers connector agnostic!
• They don’t need to know or care
• Upgrade independently.
33
Synapse <3 ambassador
containers
• ‘Ambassador pattern’
• Run a synapse ‘ambassador’ container on each host
for each service
• Link each application to the ambassador for each of
it’s dependencies
• Environment variables to each service’s haproxy
• Separates synapse management (i.e. changing the
wiring) from application management (i.e.
upgrading the app version).
34
35
Container links
• Ambassador for service A presents:
• port 8000 for HTTP REST service
• port 8443 for HTTPS REST service
!
• Container linking to ambassador sees:
• SRVA_PORT_8000_TCP=tcp://172.17.0.8:6379
• SRVA_PORT_8000_TCP_PROTO=tcp
• SRVA_PORT_8000_TCP_ADDR=172.17.0.8
• SRVA_PORT_8000_TCP_PORT=6379
• SRVA_PORT_8443_TCP=tcp://172.17.0.8:6380
• SRVA_PORT_8443_TCP_PROTO=tcp
• SRVA_PORT_8443_TCP_ADDR=172.17.0.8
• SRVA_PORT_8443_TCP_PORT=6380
36
Nerve registration container
• Each app container gets a Nerve instance
• Nerve registers its 1 app
• Nerve instance can be generic
• Make services all have a standard /health
endpoint
• Healthchecks standard
• Only need one nerve container image!
37
Alternate options
• Just register the contents of the docker API into etcd
• http://coreos.com/blog/docker-dynamic-ambassador-
powered-by-etcd/
• No health checks
• Docker only
• confd
• Consul
• frontrunner - discovery from Marathon
• Uses haproxy too
• Less health checking options
38
Vulcand
39
Issues
• If you have lots of machines + services, you have a lot
of Synapses
• haproxy health checks can become expensive on
end user apps
• Nerve helps with this

• Lots of small load balancers is harder to reason about
than a few big ones
40
Live demo?
41
Thanks
• Slides will be online

http://slideshare.net/bobtfish

• Official Smartstack site:

http://nerds.airbnb.com/smartstack-service-discovery-cloud/

• Pre-built containers to play with + blog post

http://engineeringblog.yelp.com/

https://index.docker.io/u/bobtfish/synapse-etcd-amb/

https://index.docker.io/u/bobtfish/nerve-etcd/

• Questions?
42

More Related Content

PDF
Dockersh and a brief intro to the docker internals
PDF
Steamlining your puppet development workflow
PPTX
Ansible: How to Get More Sleep and Require Less Coffee
PDF
Chasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
PDF
Docker Container Orchestration
PPTX
Hashicorp: Delivering the Tao of DevOps
PDF
Mitchell Hashimoto, HashiCorp
PPTX
Automating aws infrastructure and code deployments using Ansible @WebEngage
Dockersh and a brief intro to the docker internals
Steamlining your puppet development workflow
Ansible: How to Get More Sleep and Require Less Coffee
Chasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
Docker Container Orchestration
Hashicorp: Delivering the Tao of DevOps
Mitchell Hashimoto, HashiCorp
Automating aws infrastructure and code deployments using Ansible @WebEngage

What's hot (20)

PDF
Puppet Development Workflow
PPTX
How Yelp does Service Discovery
PDF
Service discovery in Docker environments
PDF
Docker at Shopify: From This-Looks-Fun to Production by Simon Eskildsen (Shop...
PDF
Cassandra on Docker
PPTX
Ansible presentation
PPTX
Distributed automation sel_conf_2015
PDF
Clocker - The Docker Cloud Maker
PDF
Cassandra and docker
PDF
Ansible Oxford - Cows & Containers
PDF
Ansible v2 and Beyond (Ansible Hawai'i Meetup)
PDF
How Ansible Makes Automation Easy
PPTX
Monitor-Driven Development Using Ansible
PDF
EC2 AMI Factory with Chef, Berkshelf, and Packer
PPTX
Automation with Packer and TerraForm
PDF
Service Delivery Assembly Line with Vagrant, Packer, and Ansible
PPTX
Go Faster with Ansible (PHP meetup)
KEY
London devops logging
PDF
Ansible - A 'crowd' introduction
PDF
Ansible 2.0 - How to use Ansible to automate your applications in AWS.
Puppet Development Workflow
How Yelp does Service Discovery
Service discovery in Docker environments
Docker at Shopify: From This-Looks-Fun to Production by Simon Eskildsen (Shop...
Cassandra on Docker
Ansible presentation
Distributed automation sel_conf_2015
Clocker - The Docker Cloud Maker
Cassandra and docker
Ansible Oxford - Cows & Containers
Ansible v2 and Beyond (Ansible Hawai'i Meetup)
How Ansible Makes Automation Easy
Monitor-Driven Development Using Ansible
EC2 AMI Factory with Chef, Berkshelf, and Packer
Automation with Packer and TerraForm
Service Delivery Assembly Line with Vagrant, Packer, and Ansible
Go Faster with Ansible (PHP meetup)
London devops logging
Ansible - A 'crowd' introduction
Ansible 2.0 - How to use Ansible to automate your applications in AWS.
Ad

Viewers also liked (20)

PDF
Empowering developers to deploy their own data stores
PDF
Service Discovery in Distributed Systems
PDF
Sensu and Sensibility - Puppetconf 2014
PPTX
Service Discovery using etcd, Consul and Kubernetes
PDF
Cumulonimbus fortification-secure-your-data-in-the-cloud
PPTX
Dear IT...I'd Like A Kubernetes Cluster
PPTX
Introducing Kubernetes Clusters in Rancher - February 2016 Online Meetup
PPTX
Next Gen Storage and Networking in Container Environments - September 2016 Ra...
PPTX
Rancher March 2016 Online Meetup Containers-as-a-Service with Rancher 1.0
PPTX
Storage for containers and cloud-native deployments - Rancher Online Meetup -...
PDF
PuppetConf 2016: Service Discovery and Puppet – Marc Cluet, Ukon Cherry
PDF
Automate CI/CD with Rancher
PDF
Deploying Containers with Rancher
PDF
Workshop WSO2 BPS 3.5.x - BPMN
PPTX
The ultimate container monitoring bake-off - Rancher Online Meetup October 2016
PDF
WTF Is Rancher?
PDF
Docker In the Bank
PDF
WILD microSERVICES v2
PPTX
Intro to Docker and clustering with Rancher from scratch
PPT
Docker and CloudStack
Empowering developers to deploy their own data stores
Service Discovery in Distributed Systems
Sensu and Sensibility - Puppetconf 2014
Service Discovery using etcd, Consul and Kubernetes
Cumulonimbus fortification-secure-your-data-in-the-cloud
Dear IT...I'd Like A Kubernetes Cluster
Introducing Kubernetes Clusters in Rancher - February 2016 Online Meetup
Next Gen Storage and Networking in Container Environments - September 2016 Ra...
Rancher March 2016 Online Meetup Containers-as-a-Service with Rancher 1.0
Storage for containers and cloud-native deployments - Rancher Online Meetup -...
PuppetConf 2016: Service Discovery and Puppet – Marc Cluet, Ukon Cherry
Automate CI/CD with Rancher
Deploying Containers with Rancher
Workshop WSO2 BPS 3.5.x - BPMN
The ultimate container monitoring bake-off - Rancher Online Meetup October 2016
WTF Is Rancher?
Docker In the Bank
WILD microSERVICES v2
Intro to Docker and clustering with Rancher from scratch
Docker and CloudStack
Ad

Similar to Building a smarter application stack - service discovery and wiring for Docker (20)

PPTX
Microservices with Node and Docker
PDF
stackconf 2023 | Infrastructure-From-Code and the end of Microservices by Ala...
PDF
API Microservices with Node.js and Docker
PPTX
Docker & aPaaS: Enterprise Innovation and Trends for 2015
PDF
Microservices Architecture In The Real World: Mason Jones
PDF
Modern times - architectures for a Next Generation of IT
PDF
Rise of the machines: Continuous Delivery at SEEK - YOW! Night Summary Slides
PDF
Platform - Technical architecture
PDF
What they don't tell you about micro-services
PDF
Platform Clouds, Containers, Immutable Infrastructure Oh My!
PDF
The Need of Cloud-Native Application
ODP
The journey to container adoption in enterprise
PDF
Newt global meetup microservices
PDF
Docker microservices and the service mesh
PPTX
Cloud to hybrid edge cloud evolution Jun112020.pptx
PDF
Cloud Computing as Innovation Hub - Mohammad Fairus Khalid
PDF
Lattice: A Cloud-Native Platform for Your Spring Applications
PDF
Microservices: How loose is loosely coupled?
PDF
AWS Community Day - Amy Negrette - Gateways to Gateways
PPTX
Microservices, Docker deploy and Microservices source code in C#
Microservices with Node and Docker
stackconf 2023 | Infrastructure-From-Code and the end of Microservices by Ala...
API Microservices with Node.js and Docker
Docker & aPaaS: Enterprise Innovation and Trends for 2015
Microservices Architecture In The Real World: Mason Jones
Modern times - architectures for a Next Generation of IT
Rise of the machines: Continuous Delivery at SEEK - YOW! Night Summary Slides
Platform - Technical architecture
What they don't tell you about micro-services
Platform Clouds, Containers, Immutable Infrastructure Oh My!
The Need of Cloud-Native Application
The journey to container adoption in enterprise
Newt global meetup microservices
Docker microservices and the service mesh
Cloud to hybrid edge cloud evolution Jun112020.pptx
Cloud Computing as Innovation Hub - Mohammad Fairus Khalid
Lattice: A Cloud-Native Platform for Your Spring Applications
Microservices: How loose is loosely coupled?
AWS Community Day - Amy Negrette - Gateways to Gateways
Microservices, Docker deploy and Microservices source code in C#

More from Tomas Doran (20)

PPTX
Long haul infrastructure: Failures and successes
PPT
Deploying puppet code at light speed
PDF
Thinking through puppet code layout
PDF
Docker puppetcamp london 2013
PDF
"The worst code I ever wrote"
PDF
Test driven infrastructure development (2 - puppetconf 2013 edition)
PDF
Test driven infrastructure development
PPT
London devops - orc
KEY
Message:Passing - lpw 2012
KEY
Webapp security testing
KEY
Webapp security testing
KEY
Dates aghhhh!!?!?!?!
KEY
Messaging, interoperability and log aggregation - a new framework
KEY
Zero mq logs
KEY
Cooking a rabbit pie
KEY
High scale flavour
KEY
Large platform architecture in (mostly) perl - an illustrated tour
KEY
Large platform architecture in (mostly) perl
KEY
Web frameworks don't matter
KEY
Real time system_performance_mon
Long haul infrastructure: Failures and successes
Deploying puppet code at light speed
Thinking through puppet code layout
Docker puppetcamp london 2013
"The worst code I ever wrote"
Test driven infrastructure development (2 - puppetconf 2013 edition)
Test driven infrastructure development
London devops - orc
Message:Passing - lpw 2012
Webapp security testing
Webapp security testing
Dates aghhhh!!?!?!?!
Messaging, interoperability and log aggregation - a new framework
Zero mq logs
Cooking a rabbit pie
High scale flavour
Large platform architecture in (mostly) perl - an illustrated tour
Large platform architecture in (mostly) perl
Web frameworks don't matter
Real time system_performance_mon

Recently uploaded (20)

PDF
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
DOCX
Unit-3 cyber security network security of internet system
PDF
Slides PDF The World Game (s) Eco Economic Epochs.pdf
PDF
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
PDF
Unit-1 introduction to cyber security discuss about how to secure a system
PDF
SASE Traffic Flow - ZTNA Connector-1.pdf
PPTX
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
PDF
WebRTC in SignalWire - troubleshooting media negotiation
PDF
Tenda Login Guide: Access Your Router in 5 Easy Steps
PPTX
artificial intelligence overview of it and more
PPTX
522797556-Unit-2-Temperature-measurement-1-1.pptx
PPTX
INTERNET------BASICS-------UPDATED PPT PRESENTATION
PPTX
Digital Literacy And Online Safety on internet
PDF
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
PPTX
presentation_pfe-universite-molay-seltan.pptx
PPTX
Job_Card_System_Styled_lorem_ipsum_.pptx
PPTX
Introuction about ICD -10 and ICD-11 PPT.pptx
PDF
Cloud-Scale Log Monitoring _ Datadog.pdf
PDF
Triggering QUIC, presented by Geoff Huston at IETF 123
PDF
An introduction to the IFRS (ISSB) Stndards.pdf
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
Unit-3 cyber security network security of internet system
Slides PDF The World Game (s) Eco Economic Epochs.pdf
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
Unit-1 introduction to cyber security discuss about how to secure a system
SASE Traffic Flow - ZTNA Connector-1.pdf
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
WebRTC in SignalWire - troubleshooting media negotiation
Tenda Login Guide: Access Your Router in 5 Easy Steps
artificial intelligence overview of it and more
522797556-Unit-2-Temperature-measurement-1-1.pptx
INTERNET------BASICS-------UPDATED PPT PRESENTATION
Digital Literacy And Online Safety on internet
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
presentation_pfe-universite-molay-seltan.pptx
Job_Card_System_Styled_lorem_ipsum_.pptx
Introuction about ICD -10 and ICD-11 PPT.pptx
Cloud-Scale Log Monitoring _ Datadog.pdf
Triggering QUIC, presented by Geoff Huston at IETF 123
An introduction to the IFRS (ISSB) Stndards.pdf

Building a smarter application stack - service discovery and wiring for Docker

  • 1. Building a smarter application stack Tomas  Doran   @bobtfish   2014-­‐06-­‐10
  • 2. Docker is the future • Preaching to the converted here ;)
 • Game changing technology
 • No silver bullets (ever) • Introduces it’s own set of problems and issues • Dependency discovery / wiring • Scheduling 2
  • 3. Smartstack • One possible solution to discovery problems
 • This talk: • Application architecture • Problem(s) we’re solving • Why this solution works well for us • Alternate solutions 3
  • 4. Microservices - also the future! • The same as SOA • But one API per service. • Own data store!
 • Lots of services (dozens, maybe 100s)
 • All individually very simple • Easy to reason about. • Easy to replace 4
  • 5. Don’t break the site - ever!!! • Microservices are individually deployable! • When we say “Don’t break the site” • We mean • Don’t break all of the site! 5
  • 6. Don’t break the site - ever!!! • If you have graceful degradation… • You can ignore MTBF in the backend services! • You only care about MTTR. 6
  • 7. “I’ll just break this out into it’s own application, as it’ll be easier to maintain in 10 years time” - Pre seed funding nobody, ever! 7
  • 8. Monolith - the reality • Everyone has one of these :) • If you’re far enough down the path, you call this ‘The presentation layer’.
 • Still poses a challenge • need async requests • need graceful degradation 8
  • 9. Monolith - the reality • Most popular service
 • Most dependencies • Call into 10s or 100s of other services in a request!
 • Needs circuit breakers + dynamic configuration 9
  • 10. No silver bullet = No one solution • You should always have 2. • Nagios / Sensu • RRDs + Ganglia / Graphite + Diamond • YAML files / Zookeeper 10
  • 11. No silver bullet = No one solution • ‘Top down’ architecture sucks. • Instead, broad goals + ’Bottom up’ architecture • Internal competition! • Replacing the incumbent solution happens organically • If your thing works better, people will want to move! 
 • Not perfect! Better than top-down! 11
  • 12. “Humans are bad at predicting the performance of complex systems […]. Our ability to create large and complex systems fools us into believing that we’re also entitled to understand them”
 - Carlos Bueno “Mature optimization handbook”
 12
  • 13. Distributed complexity • Distributed systems introduce their own set of complexity • Reasoning about the whole system challenging • Timing/profiling/performance analysis non-trivial • Resource scheduling also non-trivial • 2nd order effects ! • Can’t reason about emergent behavior 13
  • 14. 14
  • 15. 15 ?
  • 16. 16 ? What the heck happened at 16:46?
  • 17. 17 ? And why did it stop at 17:00?
  • 18. Dynamic architecture • Cattle not pets • AWS and VMs in ‘the cloud’ started this • Docker takes it a step further
 • Explicitly manage persistent state • Explicit regular recycling • All updates are redeploys
 18
  • 19. Dependency nightmares • Almost everything has some dependencies • Simple example, web app with a mysql DB • App config in a YAML file
 • Mysql container address changes when you restart mysql! • Oops, app can’t find mysql!
 • Do I need to restart every application using mysql? • Sucks! • Do I need to rebuild application containers using mysql? • To edit the config YAML file! • Super super sucks! 19
  • 20. Runtime wiring • mysql failovers - the simple case!
 • Presentation layer talking to service REST layers • Different deployment schedules • No downtime
 • Only possible solution: wiring dependencies at runtime • A challenge • Also an opportunity
 • DNS is workable in some cases 20
  • 21. Dynamic discovery • Discovery becomes a core problem
 • DNS re-resolving not generally trustworthy • You need to test everything for this
 • DNS balancing (internally) is awful • Failed node + multiple connections/requests • DNS round robin • Everything sees failure • Slow to shift traffic • Round robin is crappy for load balancing
 21
  • 22. Externalized wiring • Remove a lot of complexity from the application domain
 • Run a load balancer (haproxy) on each machine
 • Applications always connect to load balancer on fixed host/port • localhost on traditional metal/VMs • supplied by —link or environment variables in Docker
 • Applications become wiring agnostic! 22
  • 24. ‘Client side load balancing’ • Lots of projects use this approach: • Project Atomic • Marathon + Mesos-Docker • vulcand (https://github.com/mailgun/vulcand) • Frontrunner (https://github.com/Wizcorp/ frontrunner) • Consul ! • Smartstack 24
  • 25. Legacy infrastructure • Physical machines • Application images in AMIs • kvm
 • Can’t just use container links or a Docker only solution
 • Want to use the same (uniform) solution everywhere. 25
  • 26. Entropy reduction • You can’t change everything at once!
 • Everything will tend towards chaos • ‘Old infrastructure’ • ‘New infrastructure’ • ‘New new infrastructure’ ! • Solution specifically chosen so it could be generic. 26
  • 27. SmartStack • 2 parts • Synapse • Nerve ! • Conceptually simple • Very flexible • Easy to hack on • Plays well on traditional machines • Plays well in docker 27
  • 28. Synapse • Does discovery against a pluggable backend • Writes out a haproxy configuration
 • Assign a well known port to all services • Application connects to that port • haproxy forwards to an available backend
 • Your application doesn’t need to know about discovery!
 • Technology agnostic - works the same on metal/VMs/Docker 28
  • 29. 29
  • 30. Why synapse? • haproxy is a well known solution • ruby - easy to modify • simple (has one job) • Pluggable - discovery with multiple methods: • JSON config (static) • zookeeper • etcd • docker API • ec2 tags • Flexible • Deploy one per instance • Or pairs as dedicated lbs 30
  • 31. Nerve • Health checks services • Health checks are pluggable. • HTTP (flexible) + mysql come out the box • Registers service information to backend • zookeeper • etcd (beta) 31
  • 32. 32
  • 33. Connector agnostic containers • On ‘real servers’ or VMs, running a synapse instance per box is fine.
 • In docker, we want to abstract more than that • Make containers connector agnostic! • They don’t need to know or care • Upgrade independently. 33
  • 34. Synapse <3 ambassador containers • ‘Ambassador pattern’ • Run a synapse ‘ambassador’ container on each host for each service • Link each application to the ambassador for each of it’s dependencies • Environment variables to each service’s haproxy • Separates synapse management (i.e. changing the wiring) from application management (i.e. upgrading the app version). 34
  • 35. 35
  • 36. Container links • Ambassador for service A presents: • port 8000 for HTTP REST service • port 8443 for HTTPS REST service ! • Container linking to ambassador sees: • SRVA_PORT_8000_TCP=tcp://172.17.0.8:6379 • SRVA_PORT_8000_TCP_PROTO=tcp • SRVA_PORT_8000_TCP_ADDR=172.17.0.8 • SRVA_PORT_8000_TCP_PORT=6379 • SRVA_PORT_8443_TCP=tcp://172.17.0.8:6380 • SRVA_PORT_8443_TCP_PROTO=tcp • SRVA_PORT_8443_TCP_ADDR=172.17.0.8 • SRVA_PORT_8443_TCP_PORT=6380 36
  • 37. Nerve registration container • Each app container gets a Nerve instance • Nerve registers its 1 app • Nerve instance can be generic • Make services all have a standard /health endpoint • Healthchecks standard • Only need one nerve container image! 37
  • 38. Alternate options • Just register the contents of the docker API into etcd • http://coreos.com/blog/docker-dynamic-ambassador- powered-by-etcd/ • No health checks • Docker only • confd • Consul • frontrunner - discovery from Marathon • Uses haproxy too • Less health checking options 38
  • 40. Issues • If you have lots of machines + services, you have a lot of Synapses • haproxy health checks can become expensive on end user apps • Nerve helps with this
 • Lots of small load balancers is harder to reason about than a few big ones 40
  • 42. Thanks • Slides will be online
 http://slideshare.net/bobtfish
 • Official Smartstack site:
 http://nerds.airbnb.com/smartstack-service-discovery-cloud/
 • Pre-built containers to play with + blog post
 http://engineeringblog.yelp.com/
 https://index.docker.io/u/bobtfish/synapse-etcd-amb/
 https://index.docker.io/u/bobtfish/nerve-etcd/
 • Questions? 42