SlideShare uma empresa Scribd logo
1 de 27
techblog.newsweaver.com
github.com/PierreVincent
@PierreVincent
pierrevincent
Microservices, Docker
& Service Discovery
avec Smartstack
Meetup - Docker Rennes
ISTIC, 28 Mai 2015
This work is licensed under a Creative Commons
Attribution 4.0 International License.
Déploiement
Microservices
Environnement de
Build
Tests d’intégration
Environnement de
Dev.
Microservices are small, autonomous
services that work together.
Sam Newman
Application
Monolithique
Ancrage
Technologique
Code complexe et
difficile d’accès
Refactoring difficile
Dette technique
croissante
Déploiement
disruptif
Problèmes en
production difficiles
à isoler
Options de scaling
limitées
Taille réduite
=
Cohésion forte
Autonomie et
isolation
=
Couplage faible
Indépendance
technologique
Isolation des fautes
=
Résilience
Réduction de
l’impact des
déploiements
Scaling spécifique
+
Microservices
Cohésion
1 conteneur = 1 microservice
Indépendance Technologique
Langage specifique au conteneur
Livraison
- Image docker (peu importe la techno)
- Docker registry
Couplage faible
Chaque conteneur est independant
Liberté de déploiement
Seulement besoin de Docker
Solutions d’orchestration
- Déploiements plus complexes
- Swarm, Compose, Kubernetes, Mesos...
Test / Validation
Systèmes distribués
Continuous
Delivery
Monitoring
Interfaces entre
services
Tout sur les microservices
Délimiter les microservices
Un peu de lecture !
Service Discovery
Organisation dynamique entre microservices
Nombre de services variable Services à courte durée de vie
Comment localiser les
services disponibles ?
Comment répartir la
charge entre les
instances ?
Comment savoir
qu’un service n’est
plus disponible ?
❏ Enregistrement / Découverte
❏ Load Balancing
❏ Abstraction pour les clients
❏ Gestion proactive des erreurs
❏ Résilience aux problèmes exterieurs
❏ Pas de “Single Point of Failure”
Checklist
Recommendations
Service
Viewing History
Service
C*
.../users/123/recommendations
.../users/123/viewingHistory
{ “watched”: [
“Breaking Bad”,
…
]}
{“recommendations”: [
{
“watch”: “Better call saul!”,
“because”: [“Breaking Bad”]
},
...
]}
Recommendations
Service
Viewing History
Service
http://1.1.1.1/users/123/recommendations
services.properties
viewing_history_url = http://1.1.1.1
1.1.1.1
Solution 1: Dépendances en config.
Possibilité de volume partagé avec liste des services
et instances
Pas vraiment dynamique :
- service doit prendre en compte les
changements
- configuration doit être mise à jour
+
-
Recommendations
Service
Viewing History
Service
http://viewing-history/users/123/recommendations
/etc/hosts
1.1.1.1 viewing-history
1.1.1.1
Solution 2: Docker links
docker run
--named=viewing-history
viewing-history-service:latest
docker run
--named=recommendations
--link viewing-history:viewing-history
recommendations-service:latest
Simplicité pour les clients
Dépendances claires
Déploiment possible avec docker-compose
Manque de dynamisme :
- ordre prédefini
- difficile pour instances multiples
+
-
viewing-history.service
→ 1.1.1.1
Recommendations
Service
Viewing History
Service
http://viewing-history.service/users/123/recommendations
1.1.1.1
Solution 3: DNS
DNS
Simplicité pour les clients
DNS avec round-robin :
- instances multiples
- load balancing
Problèmes de propagation
+
-
[
viewing-history: 1.1.1.1
...
]
Recommendations
Service
Viewing History
Service
http://1.1.1.1/users/123/recommendations
1.1.1.1
Solution 4: Publisher / Subscriber
Key-value
Store
Dynamique :
- chaque instance s’enregistre
- les clients découvrent les instances
Mise en place d’un Key-value Store HA
Complexité pour les services
- Logique codées dans les services
+
-
[
viewing-history: 1.1.1.1
...
]
Recommendations
Service
Viewing History
Service
1.1.1.1
Solution 4: Publisher / Subscriber + Ambassadeur
Key-value
Store
http://1.1.1.1/users/123/recommendations
Très dynamique
Transparence pour Clients et Services
Mise en place d’un Key-value Store HA
+
-
Smartstack
Discovery framework et intégration avec Docker
github.com/airbnb/nerve
github.com/airbnb/synapse
Zookeeper
(Quorum)
Application
Viewing History Service
API Application
Recommendations Service
SynapseHAProxyNerve
Smartstack
Vue d’ensemble
Application
Nerve
ZK
1.1.1.1
nerve.conf
name = viewing_history
ip = 1.1.1.1
port = 8080
healthCheck = /health
Smartstack
Nerve
API
(8080)
/health
Viewing History Service
Application
Synapse
ZK
1.1.1.2
synapse.conf
viewing_history → 9000
Smartstack
Synapse
HAProxy
1.1.1.1
haproxy.conf
viewing_history:
frontend: localhost:9000
backends: [1.1.1.1:8080]
GET
http://localhost:9000/users/123/viewingHistory
8080 Services
viewing_history: [1.1.1.1:8080]
Recommendations Service
ping
Distribution de base
(ex. Ubuntu)
ruby
synapse (gem)
HA Proxy
nerve (gem)
service.jar
synapse.conf / nerve.conf
startup script
server.js + autres
startup script
Base Smartstack
startSynapse.sh
startNerve.sh
+ Techno
synapse.conf / nerve.conf + Code du service
+ Config
FROM smartstack-java
# Discovery
ADD nerve.conf.json /etc/
ADD synapse.conf.json /etc/
# JAR
ADD service.jar /opt/service/
# Startup
ADD start.sh /opt/start.sh
ENTRYPOINT ["/opt/start.sh"]
Dockerfile
#!/bin/bash
/opt/startSynapse.sh
/opt/startNerve.sh
java -jar service.jar
start.sh
$ docker build -t my-service .
...
$ docker run -d -e ZK_HOSTS=zk1:2181,zk2:2181 my-service
color-service
color-service
color-service
color-ui-service
blue
{
"name": "blue",
"hex": "0000FF"
}
{
"name": "red",
"hex": "FF0000"
}
{
"name": "green",
"hex": "00FF00"
}
Démo !
techblog.newsweaver.com
Questions ?
@PierreVincent

Mais conteúdo relacionado

Destaque

Docker + Kubernetes를 이용한 빌드 서버 가상화 사례
Docker + Kubernetes를 이용한 빌드 서버 가상화 사례Docker + Kubernetes를 이용한 빌드 서버 가상화 사례
Docker + Kubernetes를 이용한 빌드 서버 가상화 사례NAVER LABS
 
Apache Spark 입문에서 머신러닝까지
Apache Spark 입문에서 머신러닝까지Apache Spark 입문에서 머신러닝까지
Apache Spark 입문에서 머신러닝까지Donam Kim
 
Apache spark 소개 및 실습
Apache spark 소개 및 실습Apache spark 소개 및 실습
Apache spark 소개 및 실습동현 강
 
Spark overview 이상훈(SK C&C)_스파크 사용자 모임_20141106
Spark overview 이상훈(SK C&C)_스파크 사용자 모임_20141106Spark overview 이상훈(SK C&C)_스파크 사용자 모임_20141106
Spark overview 이상훈(SK C&C)_스파크 사용자 모임_20141106SangHoon Lee
 
Spark 의 핵심은 무엇인가? RDD! (RDD paper review)
Spark 의 핵심은 무엇인가? RDD! (RDD paper review)Spark 의 핵심은 무엇인가? RDD! (RDD paper review)
Spark 의 핵심은 무엇인가? RDD! (RDD paper review)Yongho Ha
 
Docker란 무엇인가? : Docker 기본 사용법
Docker란 무엇인가? : Docker 기본 사용법Docker란 무엇인가? : Docker 기본 사용법
Docker란 무엇인가? : Docker 기본 사용법pyrasis
 
Docker ! De la découverte à la mise en production / Digital apéro [19/03/2015]
Docker ! De la découverte à la mise en production / Digital apéro [19/03/2015]Docker ! De la découverte à la mise en production / Digital apéro [19/03/2015]
Docker ! De la découverte à la mise en production / Digital apéro [19/03/2015]Silicon Comté
 
Docker en Production (Docker Paris)
Docker en Production (Docker Paris)Docker en Production (Docker Paris)
Docker en Production (Docker Paris)Jérôme Petazzoni
 
Oxalide Morning tech #2 - démarche performance
Oxalide Morning tech #2 - démarche performanceOxalide Morning tech #2 - démarche performance
Oxalide Morning tech #2 - démarche performanceLudovic Piot
 
Docker le buzz est il justifié ?
Docker le buzz est il justifié ? Docker le buzz est il justifié ?
Docker le buzz est il justifié ? Romain Chalumeau
 
Tresors de la musique, de la scultureet de la peinture
Tresors de la  musique, de la scultureet de la peintureTresors de la  musique, de la scultureet de la peinture
Tresors de la musique, de la scultureet de la peinturePezou
 
El cantodelloco
El cantodellocoEl cantodelloco
El cantodellococeliusky79
 

Destaque (18)

Docker + Kubernetes를 이용한 빌드 서버 가상화 사례
Docker + Kubernetes를 이용한 빌드 서버 가상화 사례Docker + Kubernetes를 이용한 빌드 서버 가상화 사례
Docker + Kubernetes를 이용한 빌드 서버 가상화 사례
 
Apache Spark 입문에서 머신러닝까지
Apache Spark 입문에서 머신러닝까지Apache Spark 입문에서 머신러닝까지
Apache Spark 입문에서 머신러닝까지
 
Apache spark 소개 및 실습
Apache spark 소개 및 실습Apache spark 소개 및 실습
Apache spark 소개 및 실습
 
Spark overview 이상훈(SK C&C)_스파크 사용자 모임_20141106
Spark overview 이상훈(SK C&C)_스파크 사용자 모임_20141106Spark overview 이상훈(SK C&C)_스파크 사용자 모임_20141106
Spark overview 이상훈(SK C&C)_스파크 사용자 모임_20141106
 
Architecture for the API-enterprise
Architecture for the API-enterpriseArchitecture for the API-enterprise
Architecture for the API-enterprise
 
Spark 의 핵심은 무엇인가? RDD! (RDD paper review)
Spark 의 핵심은 무엇인가? RDD! (RDD paper review)Spark 의 핵심은 무엇인가? RDD! (RDD paper review)
Spark 의 핵심은 무엇인가? RDD! (RDD paper review)
 
Docker란 무엇인가? : Docker 기본 사용법
Docker란 무엇인가? : Docker 기본 사용법Docker란 무엇인가? : Docker 기본 사용법
Docker란 무엇인가? : Docker 기본 사용법
 
Intro docker
Intro dockerIntro docker
Intro docker
 
Docker ! De la découverte à la mise en production / Digital apéro [19/03/2015]
Docker ! De la découverte à la mise en production / Digital apéro [19/03/2015]Docker ! De la découverte à la mise en production / Digital apéro [19/03/2015]
Docker ! De la découverte à la mise en production / Digital apéro [19/03/2015]
 
XebiConFr 15 - Le challenge des microservices
XebiConFr 15 - Le challenge des microservicesXebiConFr 15 - Le challenge des microservices
XebiConFr 15 - Le challenge des microservices
 
BackDay Xebia : Microservices en démo
BackDay Xebia : Microservices en démoBackDay Xebia : Microservices en démo
BackDay Xebia : Microservices en démo
 
Docker en Production (Docker Paris)
Docker en Production (Docker Paris)Docker en Production (Docker Paris)
Docker en Production (Docker Paris)
 
Oxalide Morning tech #2 - démarche performance
Oxalide Morning tech #2 - démarche performanceOxalide Morning tech #2 - démarche performance
Oxalide Morning tech #2 - démarche performance
 
Docker le buzz est il justifié ?
Docker le buzz est il justifié ? Docker le buzz est il justifié ?
Docker le buzz est il justifié ?
 
Docker - YaJUG
Docker  - YaJUGDocker  - YaJUG
Docker - YaJUG
 
Cidades no Planeta
Cidades no PlanetaCidades no Planeta
Cidades no Planeta
 
Tresors de la musique, de la scultureet de la peinture
Tresors de la  musique, de la scultureet de la peintureTresors de la  musique, de la scultureet de la peinture
Tresors de la musique, de la scultureet de la peinture
 
El cantodelloco
El cantodellocoEl cantodelloco
El cantodelloco
 

Mais de Pierre Vincent

[Test bash NL] Contract testing in practice with Pact
[Test bash NL] Contract testing in practice with Pact[Test bash NL] Contract testing in practice with Pact
[Test bash NL] Contract testing in practice with PactPierre Vincent
 
DevOpsDays Galway 2019 - Zero-downtime deployments
DevOpsDays Galway 2019 - Zero-downtime deploymentsDevOpsDays Galway 2019 - Zero-downtime deployments
DevOpsDays Galway 2019 - Zero-downtime deploymentsPierre Vincent
 
[Test Bash Manchester] Observability and Testing
[Test Bash Manchester] Observability and Testing[Test Bash Manchester] Observability and Testing
[Test Bash Manchester] Observability and TestingPierre Vincent
 
[Test bash manchester] contract testing in practice
[Test bash manchester] contract testing in practice[Test bash manchester] contract testing in practice
[Test bash manchester] contract testing in practicePierre Vincent
 
QCon London - How to build observable distributed systems
QCon London - How to build observable distributed systemsQCon London - How to build observable distributed systems
QCon London - How to build observable distributed systemsPierre Vincent
 
[RebelCon] Increasing visibility of distributed systems in production
[RebelCon] Increasing visibility of distributed systems in production[RebelCon] Increasing visibility of distributed systems in production
[RebelCon] Increasing visibility of distributed systems in productionPierre Vincent
 
Deploying microservices in a fast-paced customer-centric environment: How and...
Deploying microservices in a fast-paced customer-centric environment: How and...Deploying microservices in a fast-paced customer-centric environment: How and...
Deploying microservices in a fast-paced customer-centric environment: How and...Pierre Vincent
 
Improve collaboration and confidence with Consumer-driven contracts
Improve collaboration and confidence with Consumer-driven contractsImprove collaboration and confidence with Consumer-driven contracts
Improve collaboration and confidence with Consumer-driven contractsPierre Vincent
 
Consumer-driven contracts: avoid microservices integration hell! (MuCon Londo...
Consumer-driven contracts: avoid microservices integration hell! (MuCon Londo...Consumer-driven contracts: avoid microservices integration hell! (MuCon Londo...
Consumer-driven contracts: avoid microservices integration hell! (MuCon Londo...Pierre Vincent
 
Consumer-driven contracts: avoid microservices integration hell! (LondonCD - ...
Consumer-driven contracts: avoid microservices integration hell! (LondonCD - ...Consumer-driven contracts: avoid microservices integration hell! (LondonCD - ...
Consumer-driven contracts: avoid microservices integration hell! (LondonCD - ...Pierre Vincent
 
Agile at Newsweaver (Agile Cork March 2016)
Agile at Newsweaver (Agile Cork March 2016)Agile at Newsweaver (Agile Cork March 2016)
Agile at Newsweaver (Agile Cork March 2016)Pierre Vincent
 

Mais de Pierre Vincent (11)

[Test bash NL] Contract testing in practice with Pact
[Test bash NL] Contract testing in practice with Pact[Test bash NL] Contract testing in practice with Pact
[Test bash NL] Contract testing in practice with Pact
 
DevOpsDays Galway 2019 - Zero-downtime deployments
DevOpsDays Galway 2019 - Zero-downtime deploymentsDevOpsDays Galway 2019 - Zero-downtime deployments
DevOpsDays Galway 2019 - Zero-downtime deployments
 
[Test Bash Manchester] Observability and Testing
[Test Bash Manchester] Observability and Testing[Test Bash Manchester] Observability and Testing
[Test Bash Manchester] Observability and Testing
 
[Test bash manchester] contract testing in practice
[Test bash manchester] contract testing in practice[Test bash manchester] contract testing in practice
[Test bash manchester] contract testing in practice
 
QCon London - How to build observable distributed systems
QCon London - How to build observable distributed systemsQCon London - How to build observable distributed systems
QCon London - How to build observable distributed systems
 
[RebelCon] Increasing visibility of distributed systems in production
[RebelCon] Increasing visibility of distributed systems in production[RebelCon] Increasing visibility of distributed systems in production
[RebelCon] Increasing visibility of distributed systems in production
 
Deploying microservices in a fast-paced customer-centric environment: How and...
Deploying microservices in a fast-paced customer-centric environment: How and...Deploying microservices in a fast-paced customer-centric environment: How and...
Deploying microservices in a fast-paced customer-centric environment: How and...
 
Improve collaboration and confidence with Consumer-driven contracts
Improve collaboration and confidence with Consumer-driven contractsImprove collaboration and confidence with Consumer-driven contracts
Improve collaboration and confidence with Consumer-driven contracts
 
Consumer-driven contracts: avoid microservices integration hell! (MuCon Londo...
Consumer-driven contracts: avoid microservices integration hell! (MuCon Londo...Consumer-driven contracts: avoid microservices integration hell! (MuCon Londo...
Consumer-driven contracts: avoid microservices integration hell! (MuCon Londo...
 
Consumer-driven contracts: avoid microservices integration hell! (LondonCD - ...
Consumer-driven contracts: avoid microservices integration hell! (LondonCD - ...Consumer-driven contracts: avoid microservices integration hell! (LondonCD - ...
Consumer-driven contracts: avoid microservices integration hell! (LondonCD - ...
 
Agile at Newsweaver (Agile Cork March 2016)
Agile at Newsweaver (Agile Cork March 2016)Agile at Newsweaver (Agile Cork March 2016)
Agile at Newsweaver (Agile Cork March 2016)
 

Microservices, Docker & Service Discovery avec Smartstack