I don't always write reactive application but when I do, it run on raspberry pi
-
Upload
adelegue -
Category
Devices & Hardware
-
view
199 -
download
0
description
Transcript of I don't always write reactive application but when I do, it run on raspberry pi
![Page 1: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/1.jpg)
Mathieu ANCELIN Alexandre DELEGUE
![Page 2: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/2.jpg)
Mathieu ANCELIN
• Développeur @SERLI
• Scala, Java, web & OSS
• ReactiveCouchbase, Weld-OSGi, Weld, etc ...
• Poitou-Charentes JUG
• Membre de l’expert group CDI 1.1 (JSR-346)
• Membre de l’expert group OSGi Enterprise
• @TrevorReznik
![Page 3: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/3.jpg)
Alexandre DELEGUE
• Développeur @ SERLI
• Java
• Scala
• Web
• spring, play, …
• @chanksleroux
![Page 4: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/4.jpg)
SERLI
• Société de conseil et d’ingénierie du SI
• 75 personnes
• 80% de business Java
• Contribution à des projets OSS
• 10% de la force de travail sur l’OSS
• Membre de l’EG JSR-346
• Membre de l’OSGi Alliance
• www.serli.com @SerliFr
![Page 5: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/5.jpg)
Les technologies présentées sont inspirées de technologies réelles!
Les applications qui en découlent sont fictives!Toute ressemblance avec des applications existantes n’est
que fortuite!
![Page 6: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/6.jpg)
ALEX
![Page 7: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/7.jpg)
![Page 9: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/9.jpg)
Mobile infrastructure
![Page 10: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/10.jpg)
Mobile infrastructure
Raspberry pi x 7
Routeur wifi
Switch
![Page 11: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/11.jpg)
Demo
![Page 12: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/12.jpg)
Résister à la charge
![Page 13: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/13.jpg)
Résister aux pannes
![Page 14: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/14.jpg)
Absorber une hausse de trafic
![Page 15: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/15.jpg)
Approche classique
![Page 16: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/16.jpg)
Monolithique
bouquetin
faisan
???
hornbill
![Page 17: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/17.jpg)
Latence
![Page 18: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/18.jpg)
Bloquant
![Page 19: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/19.jpg)
Charge
![Page 20: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/20.jpg)
Scalabilité
![Page 21: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/21.jpg)
Reactive Manifesto
![Page 22: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/22.jpg)
Reactive Manifesto
![Page 23: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/23.jpg)
Reactive manifesto
• react to event : the event-driven nature enables the following qualities
• react to load : focus on scalability by avoiding contention on shared resources
• react to failure : build resilient systems with the ability to recover at all levels
• react to user : honor response time guarantees regardless of load
![Page 24: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/24.jpg)
Scalable / React to load
![Page 25: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/25.jpg)
![Page 26: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/26.jpg)
Overview
Frontend
Cart
Identity
Backend
![Page 27: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/27.jpg)
Datas
![Page 28: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/28.jpg)
Mini / Micro Services
• Une application par domaine fonctionnel
• store-frontend : présentation du contenu
• store-identity : authentification / gestion de compte
• store-cart : panier
• store-backend : administration du site
![Page 29: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/29.jpg)
Stateless
• Chaque application est stateless
• aucune donnée n’est stockée dans l’application (pas de cache, pas de fichier …)
• Chaque application peut être clonée
Session
![Page 30: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/30.jpg)
Frontend
}- 100 % html - Indexation par les
moteurs de recherche - stateless - une url == un contenu
![Page 31: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/31.jpg)
Limiter la charge
![Page 32: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/32.jpg)
Cache
Frontend
Cache Browser CDN nginx/http varnish
![Page 33: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/33.jpg)
Optimisations
Cache +
recherche full text
Base de données ?
![Page 34: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/34.jpg)
Modèle de données
{ id: "04abe480-2521-11e4-acde-f7b0d99b8321", label: "Product number 1", description: "A description …", image: "image.jpeg", price: 1.5, fragments: [{ type: "search", html: " <div >...</div>" },{ type: "cart", html: " <tr >...</tr>" } ]}
}}
Données indexées pour la
recherche
HTML pré-généré
![Page 35: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/35.jpg)
Recherche
GET /products?q=some%20text Frontend Search some text
- Concat fragments - Include into main
template
![Page 36: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/36.jpg)
Créer / mettre à jour
BackendFrontendUpdateProduct ProductUpdated EventSource
ProductUpdated
![Page 37: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/37.jpg)
Resilient / react to failure
![Page 38: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/38.jpg)
![Page 39: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/39.jpg)
![Page 40: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/40.jpg)
Infrastructure
Identity
Frontend
Identity Backend
Cart
Cart
Frontend
Identity
Backend
![Page 41: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/41.jpg)
Infrastructure
Identity
Frontend
Identity Backend
Cart
Cart
Frontend
Identity
Backend
![Page 42: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/42.jpg)
Infrastructure
Identity
Frontend
Identity Backend
Cart
Cart
Frontend
Identity
Backend
![Page 43: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/43.jpg)
Infrastructure
Identity
Frontend
Identity Backend
Cart
Cart
Frontend
Identity
Backend
![Page 44: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/44.jpg)
Demo !
Let It Crash !!!
![Page 45: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/45.jpg)
Event-driven / react to event
![Page 46: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/46.jpg)
![Page 47: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/47.jpg)
Akka
• Akka
• Modèle acteur
• Un acteur = Une entité statefull
• Communication entre acteurs par messages (même à distance)
• Un acteur peut créer/détruire des enfants
• Un acteur peut surveiller d’autres acteurs
• Plus de problèmes de concurrence, asynchrone par nature
• Résistant aux pannes
• Java or Scala
![Page 48: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/48.jpg)
Akka
Actor
Actor
Actor
Actor
messages ActorFils
Fils
Fils
Fils
ActorFils
ActorFils
Server 1
Server 2
messages
![Page 49: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/49.jpg)
Akka messages
import akka.actor.{Props, ActorSystem, ActorLogging, Actor}case class Greeting(who: String) class GreetingActor extends Actor with ActorLogging { def receive = { case Greeting(who) ⇒ log.info("Hello " + who) }} val system = ActorSystem("MySystem") val greeter = system.actorOf(Props[GreetingActor], name = "greeter") greeter ! Greeting("Charlie Parker")
![Page 50: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/50.jpg)
Play 2
• Framework web
• java or scala
• Support pour les websocket et le server sent event
• Asynchrone
• pré-requis pour une application orientée événements
![Page 51: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/51.jpg)
Play async
case class ListProductsQuery()class ProductView extends Actor { override def receive: Receive = { case ListProductsQuery() => models.Product.list() pipeTo sender() }} !class ProductsController extends Controller { private def listProducts(): Future[List[models.Product]] = { (Actors.productView() ? ListProductsQuery()).mapTo[List[models.Product]] } def index() = Action.async { listProducts().map(products => Ok(views.html.index(products))) }}
![Page 52: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/52.jpg)
Messages
Frontend
Cart
Identity
Backend
CheckAuth
UpdateProduct
OrderCartAddProductToCart
ProductAddedToCart
ProductUpdated
WebSocket
Messages Akka
Server sent event
![Page 53: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/53.jpg)
Cluster
• Utilisation de Akka-cluster
• Librairie permettant de former un cluster de systèmes d’acteurs
• simple service d’adhésion
• tolérant aux pannes
• décentralisé (P2P, gossip)
• pas de SPOF
• pas de SPOB
• détection des pannes
![Page 54: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/54.jpg)
Cluster services• Librairie de découverte de services distribués
• Exposition descripteurs de services (URL, protocole, version, nom)
• Repose sur les memberships du cluster Akka
• Clients de services
• HTTP, Akka, Thrift, Memcached …
• Petits plus
• Monitoring
• Load balancing (pas très intelligent)
• Retry with exponential back off
![Page 55: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/55.jpg)
Cluster services
Client spécifique
Client Générique Monitoring
Load balancer +
retry
Service instance 1
Service instance 1
Service instance 1
![Page 56: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/56.jpg)
Cluster services
Client spécifique
Client Générique Monitoring
Load balancer +
retry
Service instance 1
Service instance 1
Service instance 1
![Page 57: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/57.jpg)
Cluster services
Client spécifique
Client Générique Monitoring
Load balancer +
retry
Service instance 1
Service instance 1
Service instance 1
![Page 58: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/58.jpg)
CQRS & EventSourcing
• Command Query Responsibility Segregation
• Command : Enregistrement
• Query : Lecture
• 2 modèles distincts
• Séparation des services
• Event sourcing
• Stockage des événements
![Page 59: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/59.jpg)
Persistence
JournalEvent source processor
eventcommand event event
View 1
View 2
View 3
![Page 60: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/60.jpg)
Exemple
AddProductToCart
Journal
ProductAddedToCart ProductAddedToCart ProductAddedToCartWebSocket
ActorProducts
ViewsProducts Processor
![Page 61: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/61.jpg)
Responsive
![Page 62: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/62.jpg)
![Page 63: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/63.jpg)
Frontend réactif
![Page 64: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/64.jpg)
Demo !
Realtime web!
![Page 65: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/65.jpg)
Et les perfs dans tout ca ?
![Page 66: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/66.jpg)
Les chiffres
367 998 456 756
![Page 67: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/67.jpg)
Les chiffres
367 998 456 756 €
![Page 68: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/68.jpg)
200 clients
![Page 69: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/69.jpg)
400 clients
![Page 70: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/70.jpg)
Metrics everywhere !!!
![Page 71: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/71.jpg)
Les problèmes rencontrés
![Page 72: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/72.jpg)
Nginx / mongo …
![Page 73: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/73.jpg)
Cassandra
![Page 74: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/74.jpg)
Bench web socket
![Page 75: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/75.jpg)
Configuration akka-cluster
![Page 76: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/76.jpg)
Conclusion
![Page 77: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/77.jpg)
scala
![Page 78: I don't always write reactive application but when I do, it run on raspberry pi](https://reader036.fdocuments.net/reader036/viewer/2022062705/556ecb91d8b42adb678b4dd4/html5/thumbnails/78.jpg)
This is the end ...