SlideShare a Scribd company logo
LB+HA webapp with Docker Swarm
Simone Soldateschi
ROME - APRIL 13/14 2018
“Let me tell you a story...”
Who I am
● Staff Engineer at Slack
● Previously at Microsoft, Rackspace
● 10+ years of experience as
○ Software Engineer
○ Systems Engineer
○ DevOps'in for the last 8 years
Simone Soldateschi
@soldasimo
simone.soldateschi@gmail.com
Friday: 5.50pm-6.30pm
+ during breaks
● Container Orchestration Engines, COEs
● Docker Swarm Mode, why
● Cloud Infrastructure, abs
● Service Management, how
Agenda
Container Orchestration
Engines
COEs
- Lots of features
(auto-scaling, secrets
management, UI)
- YAML deployment
model
- Pods
- Large community
- Google, Red Hat, Azure
- Quite recent project
- YAML deployment model
- Multi-master
- Auto-healing
- TLS network security
- Quick and Easy
- No UI
- No auto-scaling
- No external load-balancing
- Multi-master
- Highly scalable
- Multi OSes
- Steep learning curve
- Airbnb, ~Apple, eBay,
Netflix, Twitter
Docker Swarm Mode
The path to Docker Swarm Mode
«If you are using a Docker version prior to 1.12.0,
you can use standalone swarm,
but we recommend updating.»
https://docs.docker.com/engine/swarm/
Standalone Swarm != Swarm mode
$ docker swarm init
$ docker swarm join
Key Features
● Cluster management with Docker Engine
● Declarative service model
● Auto Scaling
● Multi-host networking
● Service Discovery
● Load balancing
● Secure by default (TLS)
● Rolling updates
● Developer oriented
Docker Swarm Security
Cloud Infrastructure
Manager initialises cluster
docker swarm init 
--advertise-addr $MANAGER_IP
Stand up basic cluster
[Manager|Worker]
docker swarm join 
--token $TOKEN_[MANAGER|WORKER] 
$MANAGER_IP:2377
Infrastructure as Code
template PRplan
plan destroyapply
DEV
DEPLOY
Basic Cluster
Architecture
Raft
Internal Distributed Store
Raft RaftLeader
Follower
Follower
Workers Gossip network
Raft consensus groupManagers
The Raft Consensus Algorithm
The Secret Lives of Data
Raft consensus
Given N managers:
● Raft tolerates up to (N-1)/2 failures.
● Raft requires a quorum of (N/2)+1 members to agree
on values proposed to the cluster.
Cluster Fault Tolerance
Multi AZ
Scale Cluster in/out
manager ASG
worker ASG
Docker Swarm cluster revised
Manager
docker swarm join 
--token $TOKEN_MANAGER 
$MANAGER_IP:2377
Worker
docker swarm join 
--token $TOKEN_WORKER 
$MANAGER_IP:2377
Autojoin Swarm Nodes
Autojoin Swarm Nodes
1. Ask manager for a token,
e.g. API, SSH
3. Join with token
2. Fetch token
Autojoin Swarm Nodes
1. Ask Vault for
a token
2. Fetch token
3. Join with token
Service Management
stack
Container, Service and Stack
service
container
A day in the life of a Docker Service
create scale rm
ls
logs rollback
ps
update
?
?
inspect
$ docker service create --name web -p 80:80 nginx
overall progress: 1 out of 1 tasks
1/1: running [=================================>]
verify: Service converged
Docker service
$ docker service scale web=3
web scaled to 3
overall progress: 3 out of 3 tasks
1/3: running [=================================>]
2/3: running [=================================>]
3/3: running [=================================>]
verify: Service converged
$ docker service rm web
A day in the life of a Docker Stack
deploy services rm
ls
?
ps
Docker Stacks
version: "3"
services:
web:
image: nginx
deploy:
replicas: 3
resources:
limits:
cpus: "0.1"
memory: 50M
restart_policy:
condition: on-failure
ports:
- "80:80"
networks:
- webnet
networks:
webnet:
$ docker stack deploy -c docker-compose.yml webstack
Creating network webstack_webnet
Creating service webstack_web
$ docker stack ps --format 
"{{.Name}}: {{.Image}} {{.Node}} {{.DesiredState}}"
webstack
webstack_web.1: nginx:latest worker2 Running
webstack_web.2: nginx:latest manager Running
webstack_web.3: nginx:latest worker1 Running
Docker Stacks
$ docker service scale webstack_web=6
webstack_web scaled to 6
overall progress: 6 out of 6 tasks
1/6: running [===================================>]
2/6: running [===================================>]
3/6: running [===================================>]
4/6: running [===================================>]
5/6: running [===================================>]
6/6: running [===================================>]
verify: Service converged
Secrets Management
● It’s best not to have secrets.
● Don’t write secrets down.
● Protect secrets in one place.
Secrets Management
manager
TLS
Internal distributed store
manager
TLS
manager
TLS
Service Deploy
worker
TLS
worker
TLS
worker
TLS
Raft Consensus Group
Multi-region
Cloud Infrastructure
Multi-region
Pilot Light
Tie up all things
// wait for it...
Demo Time
● Stand up development Swarm cluster
● Start services
● Start monitoring
● Scale and Load-test
Stand up Dev Swarm cluster
$ git clone 
https://github.com/siso/vagrant-docker-swarm.git
$ cd vagrant-docker-swarm
$ AUTO_START_SWARM=true vagrant up
Scale and Load-test
Monitor load-tests
Q&A
simone soldateschi
Friday: 5.50pm-6.30pm
+ during breaks
@soldasimo
simone.soldateschi@gmail.com
github.com/siso/vagrant-docker-swarm
Recap
● Services and Stacks
Recap
● Swarm Mode
● Multi-region infrastructure
● Provision Infrastructure
● Demo
Lesson Learned
● Options are good. Many COEs to choose from.
● Docker Swarm Mode is great for greenfield project.
● Prototype, then automate. Don’t do both.
Thank You!
Extras
git clone https://github.com/siso/swarmprom.git
cd /home/vagrant/swarmprom
ADMIN_USER=admin 
ADMIN_PASSWORD=admin 
docker stack deploy -c docker-compose.yml mon
echo "View Grafana Dashboard at http://$(docker node inspect self --format
'{{ .Status.Addr }}'):3000"
Start Monitoring Systems
References
● vagrant-docker-swarm github
repo
● swarmprom
Docker Swarm instrumentation with Prometheus,
Grafana, cAdvisor, Node Exporter and Alert Manager
● ...
License
Attribution-ShareAlike 4.0
International
Load-balancing high-available web-app with Docker Swarm cluster. - Simone Soldateschi - Codemotion Rome 2018
Docker Engine
Load-balancing high-available web-app with Docker Swarm cluster. - Simone Soldateschi - Codemotion Rome 2018
TODO -- Container Network Model
TODO -- Service Discovery

More Related Content

PPTX
Codemotion Rome 2018 Docker Swarm Mode
PPTX
Docker cluster with swarm, consul, registrator and consul-template
PDF
Apache Camel in the belly of the Docker whale
PPTX
Apache Camel K - Fredericia
PDF
Altitude SF 2017: Advanced VCL: Shielding and Clustering
PDF
Apache Camel v3, Camel K and Camel Quarkus
PDF
Puppet Camp London Fall 2015 - Service Discovery and Puppet
PDF
Puppet in the Pipeline
Codemotion Rome 2018 Docker Swarm Mode
Docker cluster with swarm, consul, registrator and consul-template
Apache Camel in the belly of the Docker whale
Apache Camel K - Fredericia
Altitude SF 2017: Advanced VCL: Shielding and Clustering
Apache Camel v3, Camel K and Camel Quarkus
Puppet Camp London Fall 2015 - Service Discovery and Puppet
Puppet in the Pipeline

What's hot (20)

PPTX
Apache Camel K - Copenhagen
PPTX
Openstack Overview
PDF
Service discovery in Docker environments
PPTX
So I Wrote a Manifest
PPTX
Apache Camel K - Copenhagen v2
PPTX
Integrating microservices with apache camel on kubernetes
PDF
Automating the Network
PDF
Cloud-Native Integration with Apache Camel on Kubernetes (Copenhagen October ...
PPTX
Microservices with docker swarm and consul
PDF
SouJava May 2020: Apache Camel 3 - the next generation of enterprise integration
PDF
Introduction to Akka-Streams
PDF
Camel Day Italy 2021 - What's new in Camel 3
PPTX
Stacking up with OpenStack: Building for High Availability
PDF
Commit to excellence - Java in containers
PDF
Red Hat Nordics 2020 - Apache Camel 3 the next generation of enterprise integ...
KEY
London devops logging
PDF
Docker Swarm and Traefik 2.0
PDF
Docker at Shopify: From This-Looks-Fun to Production by Simon Eskildsen (Shop...
PDF
Service discovery in a microservice architecture using consul
PPTX
Nashorn: JavaScript that doesn't suck - Tomer Gabel, Wix
Apache Camel K - Copenhagen
Openstack Overview
Service discovery in Docker environments
So I Wrote a Manifest
Apache Camel K - Copenhagen v2
Integrating microservices with apache camel on kubernetes
Automating the Network
Cloud-Native Integration with Apache Camel on Kubernetes (Copenhagen October ...
Microservices with docker swarm and consul
SouJava May 2020: Apache Camel 3 - the next generation of enterprise integration
Introduction to Akka-Streams
Camel Day Italy 2021 - What's new in Camel 3
Stacking up with OpenStack: Building for High Availability
Commit to excellence - Java in containers
Red Hat Nordics 2020 - Apache Camel 3 the next generation of enterprise integ...
London devops logging
Docker Swarm and Traefik 2.0
Docker at Shopify: From This-Looks-Fun to Production by Simon Eskildsen (Shop...
Service discovery in a microservice architecture using consul
Nashorn: JavaScript that doesn't suck - Tomer Gabel, Wix
Ad

Similar to Load-balancing high-available web-app with Docker Swarm cluster. - Simone Soldateschi - Codemotion Rome 2018 (20)

PDF
New Docker Features for Orchestration and Containers
ODP
Drupal Efficiency using open source technologies from Sun
PPTX
Dockerizing the Hard Services: Neutron and Nova
PDF
What's New in Docker 1.12 by Mike Goelzer and Andrea Luzzardi
PDF
What's New in Docker 1.12 (June 20, 2016) by Mike Goelzer & Andrea Luzzardi
ODP
Drupal Efficiency - Coding, Deployment, Scaling
PDF
Container orchestration from theory to practice
PDF
DevOps Meetup ansible
PPTX
Salting new ground one man ops from scratch
ODP
Why Sun for Drupal?
PDF
Apache Druid Auto Scale-out/in for Streaming Data Ingestion on Kubernetes
PDF
Large-scaled Deploy Over 100 Servers in 3 Minutes
PDF
What's New in Docker 1.12?
PDF
Deep Dive into Docker Swarm Mode
PPT
The Future is Now: Leveraging the Cloud with Ruby
PDF
Postgres the hardway
PPTX
Toolbox of a Ruby Team
PDF
CCCEU15 run cloudstack in docker
PDF
CloudStack Collab Conference 2015 Run CloudStack in Docker
PPTX
Managing and Scaling Puppet - PuppetConf 2014
New Docker Features for Orchestration and Containers
Drupal Efficiency using open source technologies from Sun
Dockerizing the Hard Services: Neutron and Nova
What's New in Docker 1.12 by Mike Goelzer and Andrea Luzzardi
What's New in Docker 1.12 (June 20, 2016) by Mike Goelzer & Andrea Luzzardi
Drupal Efficiency - Coding, Deployment, Scaling
Container orchestration from theory to practice
DevOps Meetup ansible
Salting new ground one man ops from scratch
Why Sun for Drupal?
Apache Druid Auto Scale-out/in for Streaming Data Ingestion on Kubernetes
Large-scaled Deploy Over 100 Servers in 3 Minutes
What's New in Docker 1.12?
Deep Dive into Docker Swarm Mode
The Future is Now: Leveraging the Cloud with Ruby
Postgres the hardway
Toolbox of a Ruby Team
CCCEU15 run cloudstack in docker
CloudStack Collab Conference 2015 Run CloudStack in Docker
Managing and Scaling Puppet - PuppetConf 2014
Ad

More from Codemotion (20)

PDF
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
PDF
Pompili - From hero to_zero: The FatalNoise neverending story
PPTX
Pastore - Commodore 65 - La storia
PPTX
Pennisi - Essere Richard Altwasser
PPTX
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
PPTX
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
PPTX
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
PPTX
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
PDF
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
PDF
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
PDF
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
PDF
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
PDF
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
PDF
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
PPTX
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
PPTX
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
PDF
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
PDF
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
PDF
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
PDF
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Pompili - From hero to_zero: The FatalNoise neverending story
Pastore - Commodore 65 - La storia
Pennisi - Essere Richard Altwasser
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019

Recently uploaded (20)

PDF
Empathic Computing: Creating Shared Understanding
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Getting Started with Data Integration: FME Form 101
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Spectroscopy.pptx food analysis technology
PPTX
Big Data Technologies - Introduction.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Approach and Philosophy of On baking technology
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Tartificialntelligence_presentation.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
A Presentation on Artificial Intelligence
Empathic Computing: Creating Shared Understanding
Dropbox Q2 2025 Financial Results & Investor Presentation
Getting Started with Data Integration: FME Form 101
SOPHOS-XG Firewall Administrator PPT.pptx
MYSQL Presentation for SQL database connectivity
Assigned Numbers - 2025 - Bluetooth® Document
“AI and Expert System Decision Support & Business Intelligence Systems”
Spectroscopy.pptx food analysis technology
Big Data Technologies - Introduction.pptx
Unlocking AI with Model Context Protocol (MCP)
Approach and Philosophy of On baking technology
Group 1 Presentation -Planning and Decision Making .pptx
NewMind AI Weekly Chronicles - August'25-Week II
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Tartificialntelligence_presentation.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
Programs and apps: productivity, graphics, security and other tools
Diabetes mellitus diagnosis method based random forest with bat algorithm
A Presentation on Artificial Intelligence

Load-balancing high-available web-app with Docker Swarm cluster. - Simone Soldateschi - Codemotion Rome 2018