SlideShare une entreprise Scribd logo
1  sur  18
Télécharger pour lire hors ligne
Consul 
-­‐ 
Service 
discovery 
and 
others 
By 
Walter 
Liu 
2014/11/11
Similar 
services 
• Consul 
• SkyDNS 
• Others 
• Zookeeper 
• etcd 
• Serf
What’s 
Consul? 
• Service 
Discovery 
• DNS 
• HTTP 
(JSON) 
• Health 
Checking 
(Service 
Discovery 
need 
this) 
• Key/Value 
Store 
• dynamic 
configuraMon 
• feature 
flagging 
• coordinaMon 
• leader 
elecMon 
• (Very 
like 
the 
funcMonality 
of 
Zookeeper 
we 
used) 
• MulM 
Datacenter 
• Network 
parMMon 
• If 
one 
DC 
off, 
no 
impact 
to 
another 
DC. 
• Data 
duplicate 
to 
another 
DC 
automaMcally.
User 
Scenarios 
in 
Our 
Infra 
• Simplify 
config 
(even 
with 
SaltStack) 
• Dynamic 
server 
cluster 
• Faster 
failure 
recovery 
• Dynamic 
cluster 
configuraMon 
• Launching 
a 
node 
in 
a 
container 
cloud. 
(Future 
maybe?)
Scenario: 
Simplify 
con>ig 
• ENV 
(from 
hostname 
or 
specified 
in 
Salt) 
• $TYPE=“prod” 
• $GROUP=“gg” 
• $DATACENTER=“mydc1” 
• Config 
could 
be 
• HOST_POSTFIX 
= 
$GROUP+$TYPE+$DATACENTER 
= 
• “prod.gg.mydc1.consul” 
• Config 
in 
Group 
• “db.prod.gg.mydc.consul” 
• Config 
for 
a 
datacenter 
• “redis.prod.mydc1.consul” 
• So, 
every 
config 
for 
prod/stg/dev 
could 
be 
the 
same. 
• Do 
config 
in 
service 
provider 
instead 
of 
every 
client. 
• Service 
provider 
could 
automaMcally 
register 
if 
supported.
Scenario: 
Dynamic 
server 
cluster 
• Background 
• A 
server 
cluster 
without 
load 
balancer 
(Cannot 
apply 
LB) 
• An 
applicaMon 
that 
use 
this 
service 
• Sequence 
• Query 
Consul 
will 
return 
a 
list 
of 
servers. 
• When 
a 
server 
failed, 
Consul 
will 
aware 
that 
very 
quickly 
and 
remove 
it 
from 
the 
list. 
• An 
applicaMon 
that 
use 
this 
cluster 
will 
be 
interrupted 
and 
need 
to 
re-­‐query 
Consul. 
Consul 
will 
return 
the 
new 
list 
of 
servers.
Scenario: 
Faster 
failure 
recovery 
• Background 
• A 
master/slave 
DB 
without 
automaMc 
failover 
• Sequence 
• The 
master 
DB 
is 
dead. 
• Nagios 
found 
it. 
• OPS 
aware 
it 
and 
log-­‐in 
slave 
DB. 
• OPS 
restart 
slave 
DB 
as 
master 
and 
run 
script 
to 
register 
new 
DB 
• All 
applicaMons 
that 
use 
this 
DB 
will 
change 
to 
new 
DB.
Scenario: 
Dynamic 
cluster 
con>iguration 
• If 
a 
service 
cluster 
needs 
dynamic/automaMc 
change 
configuraMon 
during 
run-­‐Mme.
Scenario: 
Launching 
a 
node 
in 
a 
container 
cloud. 
• Assume 
the 
container 
image 
of 
the 
service 
is 
ready. 
• Specify 
correct 
hostname 
of 
the 
new 
container. 
• Launch 
the 
new 
container. 
• The 
new 
container 
start 
the 
new 
service. 
• If 
it 
is 
a 
simple 
service 
provider, 
it 
registers 
itself 
to 
Consul. 
• If 
it 
uses 
other 
services, 
it 
queries 
these 
services 
from 
Consul. 
• If 
the 
configuraMon 
is 
all 
the 
same, 
the 
new 
node 
is 
ready.
OTHERS
Use 
pip 
+ 
virtualenv 
• Why, 
• Reduce 
package 
conflict. 
(Use 
egg 
is 
not 
very 
friendly.) 
• Some 
Python 
packages 
doesn’t 
have 
RPM. 
• Install 
using 
requirement.txt 
(pip 
install 
–r 
requirement.txt) 
• (?) 
private 
pip 
repository 
• Below 
for 
dev 
• Use 
virtualenvwrapper 
to 
be 
more 
convenient. 
• How 
to 
produce 
requirement 
more 
easily? 
• pip 
freeze 
> 
stable-­‐req.txt 
• Pip 
freeze 
–r 
dev-­‐req.txt 
> 
stable-­‐req.txt 
# 
Keep 
old 
comments
Example: 
requirement.txt 
• Beaker==1.3.1 
• Chameleon==2.11 
• DecoratorTools==1.7 
• DistuMls2==1.0a3 
• Django==1.5.1 
• M2Crypto==0.20.2 
• Magic-­‐file-­‐extensions==0.1 
• Mako==0.8.1 
• MarkupSafe==0.9.2 
• MySQL-­‐python==1.2.3c1 
• PasteDeploy==1.5.0 
• PyXML==0.8.4 
• Pygments==1.1.1 
• SOAPpy==0.11.6 
• SSSDConfig==1.11.6 
• Scrapy==0.18.4
Store 
SHOULD-­‐BE-­‐CHANGED 
con>ig 
in 
environment 
var 
• Why, 
• Leak 
secrets 
in 
version 
control 
system. 
• Check-­‐in 
always 
config 
to 
version 
control 
system 
accidentally. 
• Example, 
• DB 
username/password, 
AWS 
API 
Keys 
• Secret-­‐token 
(web 
framework 
like 
Django) 
• URI 
resource 
string, 
Used 
service 
host, 
port 
…..
Explicitly 
store 
prod/stg/dev 
settings 
in 
version 
control 
• Why, 
• Check-­‐in 
always 
config 
to 
version 
control 
system 
accidentally. 
• All 
sevngs 
in 
all 
environment 
are 
visible 
to 
everyone. 
• For 
example, 
• DEBUG=True 
in 
Django 
• Log 
level 
• How 
(Django 
for 
example) 
• sevngs/ 
• prod.py 
• staging.py 
• dev.py 
• ENV[“DJANGO_SETTINGS_MODULE”] 
= 
“sevngs.prod” 
• “sevngs.prod” 
could 
automaMcally 
come 
from 
hostname. 
• If 
this 
env 
variable 
is 
not 
set, 
service 
will 
print 
log 
and 
exit.
Consul 
vs. 
SkyDNS 
• Pros 
• Beyer 
health 
check 
(SkyDNS 
uses 
heartbeat 
+ 
TTL) 
• MulMple 
datacenter 
support 
by 
using 
“region”. 
• A 
beyer 
web 
view. 
(hyp://demo.consul.io/ui/) 
• Beyer 
RAFT 
implementaMon 
(unverified) 
• Cons 
• lesser 
contributors 
(1/3) 
• More 
immature 
(0.41 
now) 
and 
young.
Problem 
needs 
attention 
• For 
only 
one 
server 
service 
like 
DB, 
what 
if 
a 
second 
server 
register 
the 
service 
accidentally? 
• Use 
DNS+DNS 
forwarding 
approach 
may 
not 
be 
good 
for 
DNS 
heavy 
service. 
(Like 
Odin)
Other 
References 
• Service 
registrator 
for 
Docker 
• hyps://github.com/progrium/registrator 
• Set 
env 
by 
Consul 
• hyps://github.com/hashicorp/envconsul

Contenu connexe

Tendances

Load Balancing Apps in Docker Swarm with NGINX
Load Balancing Apps in Docker Swarm with NGINXLoad Balancing Apps in Docker Swarm with NGINX
Load Balancing Apps in Docker Swarm with NGINX
NGINX, Inc.
 

Tendances (20)

The Good Parts / The Hard Parts
The Good Parts / The Hard PartsThe Good Parts / The Hard Parts
The Good Parts / The Hard Parts
 
Kubernetes 1.3 - Highlights
Kubernetes 1.3 - HighlightsKubernetes 1.3 - Highlights
Kubernetes 1.3 - Highlights
 
Host Health Monitoring with Docker Run
Host Health Monitoring with Docker RunHost Health Monitoring with Docker Run
Host Health Monitoring with Docker Run
 
Load Balancing Apps in Docker Swarm with NGINX
Load Balancing Apps in Docker Swarm with NGINXLoad Balancing Apps in Docker Swarm with NGINX
Load Balancing Apps in Docker Swarm with NGINX
 
Dockercon Swarm Updated
Dockercon Swarm UpdatedDockercon Swarm Updated
Dockercon Swarm Updated
 
Amazon EC2 Container Service in Action
Amazon EC2 Container Service in ActionAmazon EC2 Container Service in Action
Amazon EC2 Container Service in Action
 
Scaling Development Environments with Docker
Scaling Development Environments with DockerScaling Development Environments with Docker
Scaling Development Environments with Docker
 
Docker Swarm for Beginner
Docker Swarm for BeginnerDocker Swarm for Beginner
Docker Swarm for Beginner
 
Docker Swarm Introduction
Docker Swarm IntroductionDocker Swarm Introduction
Docker Swarm Introduction
 
Testing your infrastructure with litmus
Testing your infrastructure with litmusTesting your infrastructure with litmus
Testing your infrastructure with litmus
 
[오픈소스컨설팅] EFK Stack 소개와 설치 방법
[오픈소스컨설팅] EFK Stack 소개와 설치 방법[오픈소스컨설팅] EFK Stack 소개와 설치 방법
[오픈소스컨설팅] EFK Stack 소개와 설치 방법
 
Installation Openstack Swift
Installation Openstack SwiftInstallation Openstack Swift
Installation Openstack Swift
 
I can't believe it's not a queue: Kafka and Spring
I can't believe it's not a queue: Kafka and SpringI can't believe it's not a queue: Kafka and Spring
I can't believe it's not a queue: Kafka and Spring
 
Docker 1.5
Docker 1.5Docker 1.5
Docker 1.5
 
An intro to Docker, Terraform, and Amazon ECS
An intro to Docker, Terraform, and Amazon ECSAn intro to Docker, Terraform, and Amazon ECS
An intro to Docker, Terraform, and Amazon ECS
 
Swarm mode
Swarm modeSwarm mode
Swarm mode
 
Setup 3 Node Kafka Cluster on AWS - Hands On
Setup 3 Node Kafka Cluster on AWS - Hands OnSetup 3 Node Kafka Cluster on AWS - Hands On
Setup 3 Node Kafka Cluster on AWS - Hands On
 
Lesson Learned from Using Docker Swarm at Pronto
Lesson Learned from Using Docker Swarm at ProntoLesson Learned from Using Docker Swarm at Pronto
Lesson Learned from Using Docker Swarm at Pronto
 
Docker and Maestro for fun, development and profit
Docker and Maestro for fun, development and profitDocker and Maestro for fun, development and profit
Docker and Maestro for fun, development and profit
 
About Node.js
About Node.jsAbout Node.js
About Node.js
 

Similaire à Consul - service discovery and others

Cassandra
CassandraCassandra
Cassandra
exsuns
 

Similaire à Consul - service discovery and others (20)

Kubernetes Walk Through from Technical View
Kubernetes Walk Through from Technical ViewKubernetes Walk Through from Technical View
Kubernetes Walk Through from Technical View
 
Ansible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less CoffeeAnsible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less Coffee
 
NSBCon UK nservicebus on Azure by Yves Goeleven
NSBCon UK nservicebus on Azure by Yves GoelevenNSBCon UK nservicebus on Azure by Yves Goeleven
NSBCon UK nservicebus on Azure by Yves Goeleven
 
NetflixOSS Open House Lightning talks
NetflixOSS Open House Lightning talksNetflixOSS Open House Lightning talks
NetflixOSS Open House Lightning talks
 
Distributed system coordination by zookeeper and introduction to kazoo python...
Distributed system coordination by zookeeper and introduction to kazoo python...Distributed system coordination by zookeeper and introduction to kazoo python...
Distributed system coordination by zookeeper and introduction to kazoo python...
 
Where Django Caching Bust at the Seams
Where Django Caching Bust at the SeamsWhere Django Caching Bust at the Seams
Where Django Caching Bust at the Seams
 
Benchmarking Solr Performance at Scale
Benchmarking Solr Performance at ScaleBenchmarking Solr Performance at Scale
Benchmarking Solr Performance at Scale
 
To Build My Own Cloud with Blackjack…
To Build My Own Cloud with Blackjack…To Build My Own Cloud with Blackjack…
To Build My Own Cloud with Blackjack…
 
[AWS Dev Day] 실습워크샵 | Amazon EKS 핸즈온 워크샵
 [AWS Dev Day] 실습워크샵 | Amazon EKS 핸즈온 워크샵 [AWS Dev Day] 실습워크샵 | Amazon EKS 핸즈온 워크샵
[AWS Dev Day] 실습워크샵 | Amazon EKS 핸즈온 워크샵
 
More Cache for Less Cash (DevLink 2014)
More Cache for Less Cash (DevLink 2014)More Cache for Less Cash (DevLink 2014)
More Cache for Less Cash (DevLink 2014)
 
Galera cluster for high availability
Galera cluster for high availability Galera cluster for high availability
Galera cluster for high availability
 
DjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling DisqusDjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling Disqus
 
Autoscaled Distributed Automation Expedia Know How
Autoscaled Distributed Automation Expedia Know HowAutoscaled Distributed Automation Expedia Know How
Autoscaled Distributed Automation Expedia Know How
 
Planning to Fail #phpne13
Planning to Fail #phpne13Planning to Fail #phpne13
Planning to Fail #phpne13
 
Managing and Scaling Puppet - PuppetConf 2014
Managing and Scaling Puppet - PuppetConf 2014Managing and Scaling Puppet - PuppetConf 2014
Managing and Scaling Puppet - PuppetConf 2014
 
Cloud computing & lamp applications
Cloud computing & lamp applicationsCloud computing & lamp applications
Cloud computing & lamp applications
 
Containers orchestrators: Docker vs. Kubernetes
Containers orchestrators: Docker vs. KubernetesContainers orchestrators: Docker vs. Kubernetes
Containers orchestrators: Docker vs. Kubernetes
 
Cassandra
CassandraCassandra
Cassandra
 
Riak add presentation
Riak add presentationRiak add presentation
Riak add presentation
 
Apache Performance Tuning: Scaling Out
Apache Performance Tuning: Scaling OutApache Performance Tuning: Scaling Out
Apache Performance Tuning: Scaling Out
 

Plus de Walter Liu

Salty OPS – Saltstack Introduction
Salty OPS – Saltstack IntroductionSalty OPS – Saltstack Introduction
Salty OPS – Saltstack Introduction
Walter Liu
 
Django deployment and rpm+yum
Django deployment and rpm+yumDjango deployment and rpm+yum
Django deployment and rpm+yum
Walter Liu
 
Service production from d3 pitfall viewpoint
Service production from d3 pitfall viewpointService production from d3 pitfall viewpoint
Service production from d3 pitfall viewpoint
Walter Liu
 

Plus de Walter Liu (18)

Generative AI 在手機遊戲發行上的應用介紹.pdf
Generative AI 在手機遊戲發行上的應用介紹.pdfGenerative AI 在手機遊戲發行上的應用介紹.pdf
Generative AI 在手機遊戲發行上的應用介紹.pdf
 
Infrastructure as code using Kubernetes
Infrastructure as code using KubernetesInfrastructure as code using Kubernetes
Infrastructure as code using Kubernetes
 
手機遊戲數位行銷工具淺談
手機遊戲數位行銷工具淺談手機遊戲數位行銷工具淺談
手機遊戲數位行銷工具淺談
 
關於第三方追蹤廣告再行銷的那些事兒
關於第三方追蹤廣告再行銷的那些事兒關於第三方追蹤廣告再行銷的那些事兒
關於第三方追蹤廣告再行銷的那些事兒
 
Kubernetes Workshop
Kubernetes WorkshopKubernetes Workshop
Kubernetes Workshop
 
Using Kubernetes to deploy Django in GCP
Using Kubernetes to deploy Django in GCPUsing Kubernetes to deploy Django in GCP
Using Kubernetes to deploy Django in GCP
 
Game DDOS Prevention
Game DDOS PreventionGame DDOS Prevention
Game DDOS Prevention
 
Airflow - a data flow engine
Airflow - a data flow engineAirflow - a data flow engine
Airflow - a data flow engine
 
Super Fast Gevent Introduction
Super Fast Gevent IntroductionSuper Fast Gevent Introduction
Super Fast Gevent Introduction
 
HTTP/2 to web dev
HTTP/2 to web devHTTP/2 to web dev
HTTP/2 to web dev
 
HTTP/2 Introduction
HTTP/2 IntroductionHTTP/2 Introduction
HTTP/2 Introduction
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
 
WRS GIT Branching Model - draft
WRS GIT Branching Model - draftWRS GIT Branching Model - draft
WRS GIT Branching Model - draft
 
Salty OPS – Saltstack Introduction
Salty OPS – Saltstack IntroductionSalty OPS – Saltstack Introduction
Salty OPS – Saltstack Introduction
 
Django deployment and rpm+yum
Django deployment and rpm+yumDjango deployment and rpm+yum
Django deployment and rpm+yum
 
Game Localization in Python
Game Localization in PythonGame Localization in Python
Game Localization in Python
 
Service production from d3 pitfall viewpoint
Service production from d3 pitfall viewpointService production from d3 pitfall viewpoint
Service production from d3 pitfall viewpoint
 
Celery in the Django
Celery in the DjangoCelery in the Django
Celery in the Django
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Dernier (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

Consul - service discovery and others

  • 1. Consul -­‐ Service discovery and others By Walter Liu 2014/11/11
  • 2. Similar services • Consul • SkyDNS • Others • Zookeeper • etcd • Serf
  • 3. What’s Consul? • Service Discovery • DNS • HTTP (JSON) • Health Checking (Service Discovery need this) • Key/Value Store • dynamic configuraMon • feature flagging • coordinaMon • leader elecMon • (Very like the funcMonality of Zookeeper we used) • MulM Datacenter • Network parMMon • If one DC off, no impact to another DC. • Data duplicate to another DC automaMcally.
  • 4.
  • 5. User Scenarios in Our Infra • Simplify config (even with SaltStack) • Dynamic server cluster • Faster failure recovery • Dynamic cluster configuraMon • Launching a node in a container cloud. (Future maybe?)
  • 6. Scenario: Simplify con>ig • ENV (from hostname or specified in Salt) • $TYPE=“prod” • $GROUP=“gg” • $DATACENTER=“mydc1” • Config could be • HOST_POSTFIX = $GROUP+$TYPE+$DATACENTER = • “prod.gg.mydc1.consul” • Config in Group • “db.prod.gg.mydc.consul” • Config for a datacenter • “redis.prod.mydc1.consul” • So, every config for prod/stg/dev could be the same. • Do config in service provider instead of every client. • Service provider could automaMcally register if supported.
  • 7. Scenario: Dynamic server cluster • Background • A server cluster without load balancer (Cannot apply LB) • An applicaMon that use this service • Sequence • Query Consul will return a list of servers. • When a server failed, Consul will aware that very quickly and remove it from the list. • An applicaMon that use this cluster will be interrupted and need to re-­‐query Consul. Consul will return the new list of servers.
  • 8. Scenario: Faster failure recovery • Background • A master/slave DB without automaMc failover • Sequence • The master DB is dead. • Nagios found it. • OPS aware it and log-­‐in slave DB. • OPS restart slave DB as master and run script to register new DB • All applicaMons that use this DB will change to new DB.
  • 9. Scenario: Dynamic cluster con>iguration • If a service cluster needs dynamic/automaMc change configuraMon during run-­‐Mme.
  • 10. Scenario: Launching a node in a container cloud. • Assume the container image of the service is ready. • Specify correct hostname of the new container. • Launch the new container. • The new container start the new service. • If it is a simple service provider, it registers itself to Consul. • If it uses other services, it queries these services from Consul. • If the configuraMon is all the same, the new node is ready.
  • 12. Use pip + virtualenv • Why, • Reduce package conflict. (Use egg is not very friendly.) • Some Python packages doesn’t have RPM. • Install using requirement.txt (pip install –r requirement.txt) • (?) private pip repository • Below for dev • Use virtualenvwrapper to be more convenient. • How to produce requirement more easily? • pip freeze > stable-­‐req.txt • Pip freeze –r dev-­‐req.txt > stable-­‐req.txt # Keep old comments
  • 13. Example: requirement.txt • Beaker==1.3.1 • Chameleon==2.11 • DecoratorTools==1.7 • DistuMls2==1.0a3 • Django==1.5.1 • M2Crypto==0.20.2 • Magic-­‐file-­‐extensions==0.1 • Mako==0.8.1 • MarkupSafe==0.9.2 • MySQL-­‐python==1.2.3c1 • PasteDeploy==1.5.0 • PyXML==0.8.4 • Pygments==1.1.1 • SOAPpy==0.11.6 • SSSDConfig==1.11.6 • Scrapy==0.18.4
  • 14. Store SHOULD-­‐BE-­‐CHANGED con>ig in environment var • Why, • Leak secrets in version control system. • Check-­‐in always config to version control system accidentally. • Example, • DB username/password, AWS API Keys • Secret-­‐token (web framework like Django) • URI resource string, Used service host, port …..
  • 15. Explicitly store prod/stg/dev settings in version control • Why, • Check-­‐in always config to version control system accidentally. • All sevngs in all environment are visible to everyone. • For example, • DEBUG=True in Django • Log level • How (Django for example) • sevngs/ • prod.py • staging.py • dev.py • ENV[“DJANGO_SETTINGS_MODULE”] = “sevngs.prod” • “sevngs.prod” could automaMcally come from hostname. • If this env variable is not set, service will print log and exit.
  • 16. Consul vs. SkyDNS • Pros • Beyer health check (SkyDNS uses heartbeat + TTL) • MulMple datacenter support by using “region”. • A beyer web view. (hyp://demo.consul.io/ui/) • Beyer RAFT implementaMon (unverified) • Cons • lesser contributors (1/3) • More immature (0.41 now) and young.
  • 17. Problem needs attention • For only one server service like DB, what if a second server register the service accidentally? • Use DNS+DNS forwarding approach may not be good for DNS heavy service. (Like Odin)
  • 18. Other References • Service registrator for Docker • hyps://github.com/progrium/registrator • Set env by Consul • hyps://github.com/hashicorp/envconsul