Top Banner
@njozwiak @xbucchiotty @vspiewak #3ReactApp Trois heures à l’assaut d’une application réactive Xavier Bucchiotty Nicolas Jozwiak Vincent Spiewak
196

3h à l'assaut d'une application réactive - Devoxx 2015

Jul 15, 2015

Download

Software

Xebia France
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Trois heures à l’assaut d’une application réactive

Xavier Bucchiotty Nicolas Jozwiak Vincent Spiewak

Page 2: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

@vspiewak

Speakers

@xbucchiotty

http://blog.xebia.fr

@njozwiak

Page 3: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Disclaimer

Page 4: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Agenda Contexte

Comment concevoir ?

Comment développer ?

Comment déployer ?

Comment monitorer ?

Page 5: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Agenda Contexte

Comment concevoir ?

Comment développer ?

Comment déployer ?

Comment monitorer ?

Page 6: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Contexte

Page 7: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Provider B

Architecture monolithique

Device Gateway Reporting Alerting Front WEB

Provider A

12

3 4

Page 8: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Provider B

Architecture monolithique

Device Gateway Reporting Alerting Front WEB

Provider A

12

3 4

Page 9: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Architecture monolithique

1 2 3 4

1 2 3 4

Load balancer

Page 10: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Solution: Cloud

Page 11: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

En résumé

Elastic Resilient

Page 12: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Agenda Contexte

Comment concevoir ?

Comment développer ?

Comment déployer ?

Comment monitorer ?

Page 13: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Provider B

Architecture monolithique

Device Gateway Reporting Alerting Front WEB

Provider A

12

3 4

Page 14: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Message Driven Couplage faible

Asynchrone

Non bloquant

Page 15: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Queues

Service Client

Page 16: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Bounded Queues

Service Client fail fast

Page 17: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Circuit Breaker

Page 18: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Circuit Breaker

Client ServiceCircuit Breaker

Page 19: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Circuit Breaker

Fail fast

OK

Page 20: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Circuit Breaker

Fail fast

OK

Page 21: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Circuit Breaker

Fail fast

OK

Page 22: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Provider B

Architecture

Device Gateway Reporting Alerting Front WEB

Provider A

12

3 4

Page 23: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Provider B

Architecture

Device Gateway Front WEB

Provider A

12

Reporting

Alerting3

configuration

Page 24: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Provider B

Architecture

Device Gateway Front WEB

Provider A

12

Reporting

Alerting

3

Page 25: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Provider B

Architecture

Device Gateway Front WEB

Provider A

12

Reporting

Alerting

3

Circuit breaker

Page 26: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Architecture

Page 27: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Microservices

Microservice

Business DomainIsoler les problèmes

Déploiements indépendants

Loi de Conway

Cacher les détails d’implémentation

Page 28: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Provider B

Architecture

Device Gateway Front WEB

Provider A

2

Reporting

AlertingCircuit breaker

Page 29: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Provider B

Architecture

Device Gateway Front WEB

Provider A

2

Reporting

AlertingCircuit breaker

Page 30: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Provider B

Architecture

Device Gateway Front WEB

Provider A

2

Reporting

AlertingCircuit breaker

API

API

API

Page 31: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Provider B

Architecture

Device Gateway Front WEB

Provider A

2

Reporting

AlertingCircuit breaker

API

API

API

Page 32: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Contexte transactionnel

Provider B

Device

Provider A

Gateway

Page 33: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Contexte transactionnelContexte transactionnel

Reporting

Alerting

API

API

Page 34: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Contexte transactionnel

Front WEB

API

Page 35: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

CQRS

Provider B

Device

Provider A

Gateway

query

Front WEB

API command

API

API

Reporting

Alerting

Page 36: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Dynamique du système

Provider B

Device Front WEB

Provider A

API

API

API

Gateway

Reporting

Alerting

DATAFLOW

Page 37: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Reactive Manifesto

Message driven

Elastic Resilient

Responsive

www.reactivemanifesto.org

Page 38: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

//asynchrone def handle(event): Result = { val f1 = Future(report(event)) val f2 = Future(alert(event))) Await.result(sequence(f1,f2)) Success }

// asynchrone et non bloquant :) def handle(event): Future[Result] = { val f1 = Future(report(event)) val f2 = Future(alert(event))) sequence(f1, f2).map(_ => Success) }

Asynchronisme

Page 39: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Loi d’Amdahl

Page 40: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

De Parallèle vers …

Reporting

Alerting

Gateway

Page 41: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Distribué

Reporting

Alerting

Gateway

Page 42: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Elasticité

Reporting

Alerting

Gateway

Page 43: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Fonctionnement partiel

serviceA

Gateway

serviceB

Device

Page 44: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Bounded Latency

serviceA

Gateway

serviceB

Device

Page 45: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Système de systèmes…

Page 46: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Provider B

Architecture

Device Gateway Front WEB

Provider A

2

Reporting

AlertingCircuit breaker

API

API

API

Page 47: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Agenda Contexte

Comment concevoir ?

Comment développer ?

Comment déployer ?

Comment monitorer ?

Page 48: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Framework asynchrone JVM

La programmation concurrente est difficile.

Page 49: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Framework asynchrone JVM

La programmation concurrente est difficile.

Callbacks?

Page 50: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Framework asynchrone JVM

La programmation concurrente est difficile.

ExecutorService?

Page 51: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Framework asynchrone JVM

La programmation concurrente est difficile.

Modèle acteur

Page 52: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Framework asynchrone JVM

Modèle acteur

Page 53: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Modèle acteur

acteur

Page 54: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Modèle acteur

acteur

la boîte aux lettres seul élément public d’un acteur

Page 55: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Modèle acteur

requête

réponse

acteur acteur

Page 56: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Modèle acteur

réponse

acteur acteur acteur

requête transfert

Page 57: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Modèle acteur

acteur acteur acteur

requête transfert

Page 58: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Modèle acteur

acteur acteur

requête transfert

timeout

Page 59: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Modèle acteur

A B

D I S P A T C H E R

THREADS

B

A

C D

D

CA

t

Page 60: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Développer en local avec les contraintes du distribué

Framework asynchrone JVM

Page 61: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Modèle acteur

acteur acteur

Page 62: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Modèle acteur

acteur acteur

Page 63: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

akka-cluster

acteur

acteur

akka-cluster

acteur

Page 64: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

akka-cluster

acteur

acteur

réseau point-à-point

acteur

Page 65: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

akka-cluster

acteur

acteur

acteur

Gossiping

acteur

Page 66: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

akka-clusterakka.actor.deployment { /orchestration { router = round-robin-group nr-of-instances = 100 routees.paths = ["/user/orchestration"] cluster { enabled = on allow-local-routees = off use-role = orchestration } } }

Page 67: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

akka-cluster est la clé de l’élasticité et de la résilience du système.

akka-cluster

Page 68: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Reactive Manifesto et Akka

Message driven

Elastic Resilient

Responsive

Page 69: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Provider B

Technos

Device Front WEB

Provider A

API

API

API

GatewayCircuit

breaker

Reporting

Alerting

Page 70: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Journal distribué

Page 71: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Journal distribué

Développé à l’origine chez LinkedIn

Rapide, robuste, scalable

File d’attentes, agrégation logs, streaming

Page 72: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Journal distribué

TOPIC

0

1

Page 73: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Journal distribué

TOPIC

BROKER 1

ZK

0

1

leader

Page 74: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Journal distribué

TOPIC

BROKER 1

ZK

0

1

leader

BROKER 2

synchro

Page 75: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

TOPIC

Journal distribué

BROKER 1

ZK

0

1

leader

BROKER 2

leader

replicasynchro

Page 76: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

TOPIC

Journal distribué

ZK

0

1

leader

BROKER 2

leader

replicasynchro

Page 77: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

TOPIC

Journal distribué

ZK

0

1

BROKER 2

leader

synchro

Page 78: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

TOPIC

Journal distribué

ZK

0

1

BROKER 2

leader

synchro

Élasticité

Résilience

Page 79: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

TOPIC

Journal distribué

BROKER 1

ZK

0

1

leader

BROKER 2

leader

replicaproducer

message pour partition 0

Page 80: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

TOPIC

Journal distribué

BROKER 1

ZK

0

1

leader

BROKER 2

leader

replicaproducer

message pour partition 1

Page 81: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

TOPIC

Journal distribué

BROKER 1

ZK

0

1

leader

BROKER 2

leader

replicaproducer

message pour partition 1

ordre garanti au sein d’une partition

Page 82: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

TOPIC

Journal distribué

BROKER 1

ZK

0

1

leader

BROKER 2

leaderconsumer 1topic T

partition 0group A

ordre garanti au sein d’une partition

consumer 2

Page 83: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Kafka topic

0 1 2 3 4 5 6 7 8 9

Nouveaux messages

Anciens messages

offset

Page 84: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Kafka topic

0 1 2 3 4 5 6 7 8 9

Nouveaux messages

Anciens messages

Consommateur groupe G1

Consommateur groupe G2

Page 85: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Reactive Manifesto et Kafka

Message driven

Elastic Resilient

Responsive

Page 86: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Provider B

Technos

Device Front WEB

Provider A

API

API

API

Page 87: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Elasticsearch

Page 88: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Reporting

Recherche full-text

Aggregations

Page 89: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Alerting

quantité

seuil

période de temps

filtres

Page 90: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Document

{ "device" : "device1234" "msg" : "some message" "timestamp" : "2015-04-08T13:30:00.000Z" }

Event

ESevents-2015

Page 91: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Elastique - Shards

Node 1INDEX

0

1

2

Page 92: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Elastique - Shards

Node 1INDEX

0

1'

2

Node 2INDEX

0'

1

2'

Page 93: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Elastique - Shards

Node 1INDEX

0

1'

2''

Node 2INDEX

0'

1''

2

Node 3INDEX

0''

1

2'

Page 94: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Node 3Node 2

Elastique - Noeuds

Node 1master

Node 3Node 2

Node 1data

Node 3Node 2

Node 1search

Page 95: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Résilient - Shards

Node 1INDEX

0

1'

2''

Node 2INDEX

0'

1''

2

Node 3INDEX

0''

1

2'

Page 96: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Résilient - Shards

Node 1INDEX

0

1'

2

Node 2INDEX

0'

1

2'

Page 97: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Résilient - Noeuds

Node 3Node 1master

Node 2Node 2master

Page 98: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Bounded QueuesNode

Queue (index)

Queue (bulk)

Queue (get)

Queue (refresh)

Queue (search)

Page 99: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Responsive - Timeout

Node 1

http://node1:9200/_search?timeout=10000

Page 100: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Recherche

Node 1TWITTER

0 1'

Node 2EVENT

0' 1

Node 3EVENT

0'' 1''

12

3’ 3’’

4

Page 101: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Reactive Manifesto et ES

Message driven

Elastic Resilient

Responsive

Page 102: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Provider B

Technos

Device Front WEB

Provider A

API

API

API

Page 103: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Couchbase

Page 104: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Couchbase

Gestion documents

Schemaless

Clé / valeur

Cache distribué

Page 105: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Couchbase

Fail over node

Cross data center replication

Page 106: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Reactive Manifesto et CB

Message driven

Elastic Resilient

Responsive

Page 107: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Provider B

Technos

Device Front WEB

Provider A

API

API

API

Page 108: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

PLAY / REACT JS

Page 109: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

PLAY

Formulaires, Json, validation

Intégration Scala et Akka

IO non bloquant

Sans état

Page 110: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

REACT JS

Créé par Facebook et Instagram

Composants

Data flow unique

Performant

Page 111: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Reactive Manifesto et Play

Message driven

Elastic Resilient

Responsive

Page 112: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Provider B

Technos

Device Front WEB

Provider A

API

API

API

Page 113: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Testing

Gateway

Endpoint Supervision

WorkersRouter

Provider B

Device

Provider A

Page 114: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Gateway

Test unitaire

Endpoint Supervision

WorkersRouter

Provider B

Device

Provider A

testkit

Page 115: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Gateway

Test unitaire

Endpoint Probe

WorkersProbe

Probe testkit

Page 116: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Gateway

Test unitaire

Workerstestkit

Validation

Endpoint

Page 117: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Gateway

Test unitaire

Workerstestkit

Probe

Page 118: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Test unitairedescribe("A kafka source actor") { it("should be able to pump a given number of message from kafka") { val probe = TestProbe() val reader = system.actorOf(Props(classOf[KafkaSource], probe)) //send 11 messages on a topic probe.send(reader, 10) probe.receiveN(10, max = 3.seconds) shouldBe messages.take(10) probe.expectNoMsg(1.second) } }

Page 119: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Test unitairedescribe("A terminal session") { it("should have an idle timeout") { implicit val system = ActorSystem("test", ConfigFactory.parseString("session.timeout=\"500 milliseconds\"")) val probe = TestProbe() val session = system.actorOf(DeviceSession.props) probe.watch(session) probe.expectTerminated(session, 1.second) } }

Page 120: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Gateway

Workers Probe

Test multi-jvm

multi-jvm

Page 121: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Gateway Validation

Workers Probemulti-jvm

Test multi-jvm

Page 122: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

"form a cluster" in { runOn(clusterNodes: _*) { SeedDiscovery.joinCluster(system) enterBarrier("deployed")

}

"support network partition" in { runOn(node1) { for { from <- group_1 to <- group_2 } { testConductor.blackhole(from, to, Direction.Both).await } }

Test multi-jvm

Page 123: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Test

Test intégration

docker  run

Execute  Test

docker  rm

Page 124: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Versioning

NOT SUPPORTED YET

Page 125: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Versioning

JSON

Scala

Apache Avro

Page 126: 3h à l'assaut d'une application réactive - Devoxx 2015

@YourTwitterHandle@YourTwitterHandle@njozwiak @xbucchiotty @vspiewak#3ReactApp

QUESTIONS ?

Page 127: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Provider B

Résumé

Device Front WEB

Provider A

Reporting

Alerting

API

API

API

GatewayCircuit

breaker

Page 128: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Agenda Contexte

Comment concevoir ?

Comment développer ?

Comment déployer ?

Comment monitorer ?

Page 129: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Thanks

Page 130: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Docker

Page 131: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

DockerFROM ubuntuRUN apt-get install -y wget software-properties-commonRUN apt-add-repository ppa:ansible/ansibleRUN apt-get update && apt-get install -y ansibleRUN wget https://bootstrap.pypa.io/ez_setup.py -O - | pythonRUN easy_install pipRUN pip install botoENV ANSIBLE_HOST_KEY_CHECKING=False

Page 132: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Provider B

Technos

Device Front WEB

Provider A

API

API

API

Page 133: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Mesos / Marathon

Page 134: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Mesos

Page 135: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Mesos

Distribution des

ressources

Détection des

erreurs

Page 136: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Marathon

Execution d’applications

API Rest

Beaucoup d’options

Page 137: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

{ "id": "provisioning", "instances": 1, "cpus": 2.0, "mem": 512, "ports":[9000], "container": { "type": "DOCKER", "docker": { "image": "project/web:0crec10a90724f791caaf95cbc62ea61abbd6376", "network": "BRIDGE", "portMappings": [ { "containerPort": 9000, "servicePort": 9000, "hostPort": 0, "protocol": "tcp" } ] } } }

Marathon Config

Page 138: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

… "healthChecks": [ { "path":"/health", "portIndex":0, "protocol":"HTTP", "gracePeriodSeconds":3, "intervalSeconds":10, "timeoutSeconds":10, "maxConsecutiveFailures":3 } ], … "upgradeStrategy": { "minimumHealthCapacity": 0 }, …

Marathon Config

Page 139: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Marathon

Page 140: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Architecture

Mesos master

Gateway Reporting

Alerting

Mesos slave / Marathon

Gateway

Alerting Reporting

Web

Http Post

Mesos slave / Marathon

Page 141: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Découverte de services

Page 142: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Découverte de services

seed-nodes 1 seed-nodes 1

seed-nodes 2

Nodes 1

Nodes 2

Page 143: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Découverte de services• Akka 2.4 snapshot

• Intégration avec Docker

remote { enabled-transports = ["akka.remote.netty.tcp"] netty.tcp { hostname = "127.0.0.1" port = 2551 } }

remote { enabled-transports = ["akka.remote.netty.tcp"] netty.tcp { hostname = "127.0.0.1" port = 2551 bind-hostname = "192.132.122.12" bind-port = 32001 } }

Page 144: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Découverte de services

Page 145: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Node 1

Node 2

Découverte de services

joinCluster

joinCluster

Page 146: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Bamboo

Page 147: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Problème IP dynamique

Port dynamique

Nombre d’instances

Sous domaines (web, monitoring, …)

Page 148: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Bamboo

Cluster Mesos

Cluster Marathon

Bamboo Zookeeper HAProxy

API /v2/eventSubscriptions

Page 149: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Bamboo: UI

Page 150: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Bamboo: UI

Page 151: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Bamboo

Cluster Mesos

Cluster Marathon

Bamboo

Bamboo HAProxy

WEB 1

Zookeeper

WEBChronos Inbound

WEB 2 WEB N

Docker Registry

web.app.io

Page 152: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Ansible

Page 153: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Problème Kafka

Couchbase

Marathon

Mesos master / slave

Elasticsearch master / search / data

GoCD server / agent

Page 154: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Introduction Infrastructure as code

Agent-less

Python / Boto

Page 155: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

$ cat inventory [webservers] foo.example.com bar.example.com

[dbservers] one.example.com two.example.com

Inventaire

Page 156: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Modules Commands (command, shell, script)

Files (file, copy, unarchive, …)

System (service, hostname, cron, …)

Packaging (apt, yum, …)

Source Control (git, svn, …)

Notifications (mail, irc, slack, …)

Page 157: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

$ cat tasks/main.yml - name: Create /mnt/data directory file: path=/mnt/data/elasticsearch state=directory

- name: Install Elasticsearch apt: name=elasticsearch state=latest force=yes notify: Restart Elasticsearch

Tasks

Page 158: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

$ tree -a . ├── files │ └── template.json ├── handlers │ └── main.yml ├── tasks │ └── main.yml ├── templates │ └── elasticsearch.conf.j2 └── vars └── .gitkeep

Rôles

Page 159: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

$ cat group_vars/elasticsearch

elasticsearch: version: 1.4 clustername: elasticsearch-cluster nodename: {{ hostvars[inventory_hostname]['ec2_id'] }} quorom: 1 replicas: 2 plugins: - head - paramedic

Variables

Page 160: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

discovery.zen.ping.multicast.enabled: false discovery.zen.ping.unicast.hosts: [ {% for host in groups[group_name] %}

"{{ hostvars[host]['ansible_eth0'].ipv4.address }}"

{% if not loop.last %},{% endif %}

{% endfor %} ]

Templates

Page 161: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

$ cat elasticsearch.yml - hosts: es_nodes user: ubuntu sudo: yes

roles: - all - java - elasticsearch

Playbooks

Page 162: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Résultats

Page 163: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Résultats Création instances EC2

Configuration DNS (Route 53)

Configuration instances

Ré-utilisation des rôles (all, java, zk, …)

Page 164: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Provider B

Technos

Device Front WEB

Provider A

API

API

API

Page 165: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

VPC + CROSS AZ

VPCAZ1 AZ2

PUBLIC

PRIV

PUBLIC

PRIV

WEBWEB GWGW

Page 166: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

GO Continuous Delivery

Page 167: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

GO CD: Principes

GO Server

GO Agent GO Agent GO Agent

DEV PROD

Page 168: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

GO CD: Principes

Update ES

Update Kafka

Create Infra

pipeline

stage

jobs

jobs…

Page 169: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

GO CD: Principes

npm install Karma

Job

task task

Page 170: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

GO CD: Principes

Create Infra Update Infra

Pipeline Group

Pipeline

Docker Images Deploy Containers

Pipeline Pipeline Pipeline

Page 171: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

GO CD: UI

Page 172: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

GO CD: UI

Page 173: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

TEMPLATES

Page 174: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Déploiement continu

Build  source  +  run  tests

docker  build  img

docker  push  img

install  img  instanceHttp Post to Marathon

docker  run  img

slave masterHub

Page 175: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Http post to Marathon

publish

Build  Marathon  request    with  dynamic  parameters

Page 176: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

SBTcpu in Marathon := 2 memory in Marathon := 512 instances in Marathon := 1 portsMapping in Marathon := Seq(dynamicPort(9000, Protocol.TCP))

healthchecks in Marathon := Seq(httpHealthCheck("/health", 3, 10, 10, 3))

Page 177: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Kafka

TOPIC

0

1 Reporting

Reporting

2 partitions deploy 2 instances

Page 178: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Agenda Contexte

Comment concevoir ?

Comment développer ?

Comment déployer ?

Comment monitorer ?

Page 179: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

KPI

Provider B

Device

Provider A

GatewayCircuit

breaker

UP TIME

LATENCE

Page 180: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

KPI

Reporting

Alerting

DÉBIT

Page 181: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

KPI

Front WEB

API

API

Reporting

Alerting

LATENCE

VOLUME

Page 182: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

KPI

Front WEB

API

COHERENCE

Page 183: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Cloud

PET vs CATTLE

Page 184: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Rsyslog + ES + Kibana

rsyslog

Page 185: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Riemann ?

Page 186: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Sensu ?

Page 187: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Monitoring Zookeeper Akka Cluster

Kafka

Mesos

Page 188: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Bilan Charge variable

Haute dispo

Page 189: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Bilan Tolérance aux pannes

Déploiement service à chaud

Page 190: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Bilan A/B testing

Schemaless

Facile à exploiter

En  cours  de  réflexion,  développement

Page 191: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Améliorations

Minimum Vertical Slice

Event Sourcing

Page 192: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Provider B

Améliorations

Device

Provider A

API

APIGateway Front

WEB

Reporting

Alerting

API

stream

stream

Page 193: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Améliorations

Page 194: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Prise de recul

Déploiements

Mise en place de tests

Granularité des services

Culture du client

Page 195: 3h à l'assaut d'une application réactive - Devoxx 2015

@njozwiak @xbucchiotty @vspiewak#3ReactApp

Bibliographie

http://www.se-radio.net/2014/10/episode-213-james-lewis-on-microservices/

Standing on the shoulders of giants

Page 196: 3h à l'assaut d'une application réactive - Devoxx 2015

@YourTwitterHandle@YourTwitterHandle@njozwiak @xbucchiotty @vspiewak#3ReactApp

QUESTIONS ?