Vincent Thavonekham et Philippe Guédez de VISEO,
Reactive Extension Rx.Net architecture to overcome the SigFox limits and absorb the heavy IoT load with BigData (using ASP.Net Core Microservices). ALL TECHNICAL DETAILS unveailed.
Objet direct 2013-05-11 Microsoft ALM 2013 Software Factory
Retour d'expérience Large IoT project / BigData : détail du cas réel de HagerServices
1. RETOUR D'EXPÉRIENCE "LARGE IOT PROJECTS".
FOCUS SUR HAGERSERVICES
Cloud Practice Manager chez VISEO
Vincent Thavonekham, MVP Azure
@vThavo, vincent.thavonekham@viseo.com
Senior architect BigData / Data Science chez VISEO
Philippe Guédez
v4
3. MIEUX VOUS CONNAITRE
• Qui connait l’ IoT d’Azure ?
• Qui connait l’architecture Lambda ?
• Qui fait du microservices ?
• Qui utilise AWS ? (le IaaS, le PaaS)
5. Début de l’aventure IoT: « Naissance des idées »
« Une idée, cela peut changer le monde.
Mais comment la trouver? » Cédric Villani
• La documentation
• La motivation
• L’environnement
• Les échanges
• Les contraintes
• La chance
• La persévérance
• Selon Cédric Villani, Pr Maths, Médaille Fields
Retour d'expérience "large IoT projects", Focus sur HagerServices
6. Retour d'expérience "large IoT projects", Focus sur HagerServices
Par où commencer en IoT / BigData ?
Genèse pour réussir ces projets
Votre perception
de l’IoT/BigData
« C’est facile, on réfléchit
et ça coûte tant !
Et le ROI du projet
est x-k€ sur 2 ans »
Credits: starwars.wikia.com
Droit d’auteur "Fair Use"
2010
8. • Croisement des informations sur trois axes
Des méthodologies
et architectures éprouvées
IoT and BigData : IoT Azure at scale - Featuring HagerServices and AgileIoT
Provenance de ces retours d’expériences IoT
9. RETOURS SUR UN PROJET
AZURE IOT EN PARTICULIER
Hagerservices
10. HAGER SERVICES
WHAT WAS THE NEED
Hager wanted to launch new services based on
sensors connected to the SigFox network.
They needed experts to help choosing the right
architecture and technology to handle this new
flow of data.
They turned to us to create the platform that will
be able to gather numerous data in the coming
years.
11. BESOIN HAGERSERVICES: Capteurs incendie
« connectés »
– Directeur du projet : Simon ANDRE
– Equipe de 6 personnes
– Architecture fortement inspirée des architecture
dites « Lambda » pour de l’IoT / BigData
Témoignage client : hagerservices
Retour d'expérience "large IoT projects", Focus sur HagerServices
12. • Exigence Sigfox
– Taille des trames Sigfox : 12 octets
– 140 messages / 24h / device
– 20 minutes entre deux trames
• Exigence Hager
– Permettre aux devices d’envoyer
des messages supérieurs à cette limite
Témoignage client : hagerservices
Retour d'expérience "large IoT projects", Focus sur HagerServices
13. • Exigence Hager
– Plate-forme IoT « générique »
• Démarrage avec les détecteurs d’incendie
• Mais plateforme ouverte permettant d’intégrer de
nouveaux produits, nouveaux services
Témoignage client : hagerservices
Retour d'expérience "large IoT projects", Focus sur HagerServices
14. Simplifié :
• Azure WebJob + WebApp basés sur ASP.Net Core 1.0
• Architecture micro-services asynchrone et event-based
• DAL basée sur micro-ORM Dapper
Architecture : forte volumétrie + traitements « near-temps réel »
Témoignage client : hagerservices
Event Hub
Utilisateurs
Assemblage Routage Traitement
et stockage
Retour d'expérience "large IoT projects", Focus sur HagerServices
15. Le problème du réassemblage des trames
15
Enterprise integration patterns
• Slitter côté Device
Retour d'expérience "large IoT projects", Focus sur HagerServices
16. Le problème du réassemblage des trames
16
Retour d'expérience "large IoT projects", Focus sur HagerServices
17. Premier prototype avec StreamAnalytics
– Opérateur d’agrégation CollectTOP
• Grouper par deviceId, hagerMessageId
– SlidingWindow
• Gestion des timeout
– Trames SigFox pré-parsées par IoT Hub
– Syntaxe SQL-like
Le problème du réassemblage des trames
Retour d'expérience "large IoT projects", Focus sur HagerServices
18. StreamAnalytics / Sliding Windows (glissant)
Le problème du réassemblage des trames
Retour d'expérience "large IoT projects", Focus sur HagerServices
1 5 8
8
51
9
51 9
1
Exemple
Par topic, donne-moi le nombre
de tweets qui ont été twittés plus
de 10 fois dans les 10 dernières
secondes
SELECT Topic, COUNT(*) FROM TwitterStream
TIMESTAMP BY CreatedAt
GROUP BY Topic, SlidingWindow(second, 10)
HAVING COUNT(*) > 10
19. Retour d'expérience "large IoT projects", Focus sur HagerServices
Le problème du réassemblage des trames
20. POC StreamAnalytics non concluant
– API limitée
• Absence d’opérateurs binaires pour analyser la
« payload » Hager
• Absence d’opérateurs pour réassembler les trames
• Bien moins riche que SQL
– Besoin de traitements spécifiques
Le problème du réassemblage des trames
Retour d'expérience "large IoT projects", Focus sur HagerServices
21. Notre choix final s’est porté sur
Reactive Extensions (Rx.NET) …
Le problème du réassemblage des trames
Retour d'expérience "large IoT projects", Focus sur HagerServices
22. “Rx done right”
“ReactiveX is a combination of the best ideas
from the Observer pattern (Gang of Four),
the Iterator pattern, and functional programming”
http://reactivex.io/22
Similaire à Linq mais streams asynchrones + opérateurs pour gérer le temps
Linq
Retour d'expérience "large IoT projects", Focus sur HagerServices
24. Le problème du réassemblage des trames
Opérateur de transformation “GroupBy”: Observable set of Observables
http://reactivex.io/documentation/operators/groupby.html24
Retour d'expérience "large IoT projects", Focus sur HagerServices
25. Microsoft-referenced architecture: Stream Analytics remplacé par Rx
Sources : https://azure.microsoft.com/en-us/documentation/articles/iot-suite-what-are-preconfigured-solutions/
Retour d'expérience "large IoT projects", Focus sur HagerServices
Architecture candidate
Event Hub
Storage
Web/Mobile App
IoT Hub Web Jobs
Devices DocumentDB
SQL
Database
Redis
Cache
Web Jobs
Back-end
systems
and
processes
26. • Reactive Extensions (Rx.Net)
Témoignage Simon ANDRE, IoT Cloud Manager :
- « Traitement lourds ‘temps réels’ devenus possibles ; trier/réassembler Trames »
- « Usage intensif des custom middleware côté API »
- « Pour les Tests Unitaires, on est à 100% de couverture »
Retour d'expérience "large IoT projects", Focus sur HagerServices
Architecture candidate
Event Hub
27. • Architecture micro-services
– Traitement différencié des trames en fonction
• Du produit
• De leur priorité (alarmes avant les trames de fil de l’eau)
– Faciliter l’intégration de nouveaux
produits, de nouveaux services
Sources : https://github.com/Azure-Samples/service-fabric-dotnet-iot
https://azure.microsoft.com/en-us/documentation/articles/service-fabric-overview-microservices
https://azure.microsoft.com/fr-fr/documentation/samples/service-fabric-dotnet-iot/
Retour d'expérience "large IoT projects", Focus sur HagerServices
Architecture candidate
Event Hub
28. Retour d'expérience "large IoT projects", Focus sur HagerServices
Architecture candidate
Event Hub
– Approche microservices : une partition par usage
• Alarmes
• Appairage
• Télémétrie
– Partitions consommées par des WebJobs
– Les WebJobs prennent en charge le traitement des
messages et leur stockage en base de données
Event Hub
29. Retour d'expérience "large IoT projects", Focus sur HagerServices
Architecture candidate
Azure SQL Server
– Sharding géré avec Elastic Database client library
– Un shard par produit
DocumentDB
– Non retenu car choix fait il y a 1 an et demi
– Solution aujourd’hui en prod chez nos clients
30. Simon ANDRE, IoT Cloud Manager
Témoignage client : hagerservices
« Timing très court … nous
devions faire des choix pra
gmatiques … »
« Nous sommes très satisfaits
des performances »
« Jeunesse SigFoxAzure
IoT : Quelques ajuste-
ments »
« ASP.Net Core 1.0 Web Apps
= Globalement un bon choix »
Retour d'expérience "large IoT projects", Focus sur HagerServices
33. AgileIoT Philosophy
The AgileIoT philosophy is the same as the renaissance workshop one, the cell wher
e everything needed was made to realize a new handiwork: starting from the design
to the marketing, going through the learning and the production.
Team’s members are pushed to behave like renaissance craftsmen, with ability they
use various materials, techniques and tools to satisfy the handiwork’s customer.
AgileIoT brings the customer’s need to the center, harmonizing competencies, appro
aches and various technologies by defining a main-set of economically-sustainable t
ools to create an IoT solutions.
Retour d'expérience "large IoT projects", Focus sur HagerServices
34. AgileIoT Principles
It’s not software, hardware or service: it’s about jobs to be done!
It’s not the completion of a software or hardware project but a smart solution, base
d on both, to solve a need in an effective and efficient way.
Think less and do it!
Reduce to the bare minimum the time dedicated to the analysis phase, in favor of a
quick startup of development’s activities related to the solution.
Simple is better!
Simpler is the solution, more chance we have to evolve it according to stakeholders
needs.
If you can’t remember it, you can’t improve it!
Using visual management system to monitoring the state of the solution
development.
Retour d'expérience "large IoT projects", Focus sur HagerServices
35. AgileIoT Practices
Fast Prototyping
Validate the overall sustainability of the solution.
Make-Measure-Learn
This loop aims to fast experiment different hypotheses and assumptions:
Flashback
Match the state of the project with a fast alignment, where the observer team will
check the work of another team directly.
Continuous Improvement
Reduce to the minimum the changes to the hardware side, which is a long-term and
expensive task.
Continuous Integration
Integrate continuously (and as soon as possible) every change, in order
to identify problems and resolve them in a timely fashion.
Retour d'expérience "large IoT projects", Focus sur HagerServices
36. AgileIoT Duttile Poster
Prototype Phase (timing: typically, 2
-4 weeks), it’s the first phase of the p
rocess. There’s the Vision definition,
Fast Prototypization and Product Bac
klog definition using a specific planni
ng phase;
Engineering Phase (timing: time needed for reaching
the Value). In this step, the solution is engineerized a
nd developed. It’s, as one could deduct, the most imp
ortant and complex phase of the whole process;
Workout Phase (timing: Typically,
1-2 weeks). It’s the last phase, focal
ized onto the Deployment, Support
and the Continuous Improvement
of the product.
Retour d'expérience "large IoT projects", Focus sur HagerServices
38. AgileIoT Fast Prototyping
Energy: focused on the energetic-based aspects as a function o
f the needs of the operational continuity of smart devices;
Hardware : focused on the validation of the hardware through o
ne or more Evaluation Kits (EVK).
Code: focused on the prototyping of the firmware of the devices and
the services made for acquiring the main data/events.
Data Flow: focused on the aspects related to the gathering, clea
ning-up and managing of the Raw Data that comes from the devi
ces.
Cloud: focused on the Cloud aspects of the solution, as a data/e
vent management platform.
Security: focused on the verification of the security aspects, which a
ffect the solution as well as the development.
Delivery Prototyping: focused on the deploy of the elements of
the solution, speaking about both hardware items and services o
nes.
Legal: focused on the analysis of the law and regulations, national a
nd international, which the solution must consider in order to becom
e a marketable product.
Retour d'expérience "large IoT projects", Focus sur HagerServices
40. CE QUE NOUS AVONS APPRIS
1. Bien respecter les « Best Practices » IoT pour éviter les échecs
– Pensez idéation, valeur métier, … (cf « Agile IoT »)
2. Le projet ne s’arrête pas à la fin des développements !
– Ne pas se concentrer uniquement sur le projet « informatique »
– Budget Qualité / Prod : PRA, ITIL v3, « vrai » DevOps à terme
– Principe de précaution de la Loi de Murphy :
« Tout ce qui est susceptible de mal tourner tournera nécessairement mal. ». Prévoir les « Single
point of Failure » (SPOF)
3. Pilotage d’un projet IoT : pas uniquement les Dev et la R&D
– C’est un projet de transformation de l’entreprise : Implication Direction
4. Succès grâce à une avance technologique
– Lire, s’ouvrir, travailler avec Microsoft Corp, …
Retour d'expérience "large IoT projects", Focus sur HagerServices
@vThavo et PhilippeG vous présentent #REX #AzureIoT #LargeProjects #Hager au #MSCloudSummit
V1.1: ajout de Philippe
Ari
Considérations, erreurs ou cul de sac par rapport au besoin: Cassandra, Azure Container Services, Entity Framework, AKKA.Net, Azure IoT Suite, ASP.Net 4, Stream Analytics, Azure functions, …
L’autre ORMlite que j’avais proposé était Simple.Data
Dapper a été retenu par Simon pour ses performances et son modèle beaucoup plus ouvert que Simple.Data.
Cependant, il a passé du temps à écrire la DAL car Dapper ne gère pas par exemple les requêtes par critères ou la gestion de cache (fonctionnalités qu’on retrouve avec EF / NHibernate).
The Observable type adds two missing semantics to the Gang of Four’s Observer pattern, to match those that are available in the Iterable type:
the ability for the producer to signal to the consumer that there is no more data available (a foreach loop on an Iterable completes and returns normally in such a case; an Observable calls its observer’sonCompleted method)
the ability for the producer to signal to the consumer that an error has occurred (an Iterable throws an exception if an error takes place during iteration; an Observable calls its observer’s onError method)
Sharding géré avec Elastic Database client library côté .NET (https://docs.microsoft.com/en-us/azure/sql-database/sql-database-elastic-scale-introduction)
ASP .NET Core
Au départ, on s’appuyait sur le framework .NET 4.5.1 car trop peu de frameworks étaient compatible avec .NET Core. Aujourd’hui, je pense que Hager s’appuie sur .NET Core 1.0.
Les outils de build ont changé : DNX .NET CLI
Et le format des projets : project.json retour au format csproj.
Hager
Architectures candidates
IoT Hub
Objectif : collecter les trames Sigfox
Ré-assemblage des trames (voir point suivant aussi)
Objectif : parser / ré-assembler les trames en messages / router vers la "bonne" partition de l'Event Hub
Attention : à cette étape, aucune logique métier, le but est de minimiser le temps entre la consommation de l'événement sur l'IoT Hub et l'envoi du message parsé sur Event Hub
- Solution 1 : derrière l'IoT Hub, on branche un WebJob + Rx.NET pour consommer / parser / ré-assembler les messages / router
- Solution 2 : derrière l'IoT Hub, on branche Stream Analytics - dans ce cas là, il faut qu'on POC rapidement la faisabilité de la solution expliquée ci-dessus. Le parsing des trames est fait par Sigfox.
Event Hub + Web Jobs
Objectif : traiter les messages (business logic)
- 1 partition par usage (ex : une partition pour les alarmes, une autres pour les gérer les trames d'appairage, une autre pour les indicateurs)
- Ces partitions sont consommées par des WebJobs
- Les WebJobs prennent en charge le stockage en base de données.
Base de données : Azure SQL Server
Sharding géré avec Elastic Database client library côté .NET (https://docs.microsoft.com/en-us/azure/sql-database/sql-database-elastic-scale-introduction)
ORM : Dapper
L’autre ORMlite que j’avais proposé était Simple.Data
Dapper a été retenu par Simon pour ses performances et son modèle beaucoup plus ouvert que Simple.Data.
Cependant, il a passé du temps à écrire la DAL car Dapper ne gère pas par exemple les requêtes par critères ou la gestion de cache (fonctionnalités qu’on retrouve avec EF / NHibernate).
ASP .NET Core
Au départ, on s’appuyait sur le framework .NET 4.5.1 car trop peu de frameworks étaient compatible avec .NET Core. Aujourd’hui, Hager s’appuie sur .NET Core 1.0.
Les outils de build ont changé : DNX .NET CLI
Et le format des projets : project.json retour au format csproj.
Problème du ré-assemblage des trames
Opérateur StreamAnalytics qu’on aurait pu utiliser pour réordonner les trames :
CollectTOP : https://msdn.microsoft.com/en-us/library/azure/dn966243.aspx
Couplé au SlidingWindow et au fait que Sifgox "parse" les trames pour vous, on pourrait s'en sortir.
Pb : besoin de parser les trames reçues (car au format Hager) pour en extraire les infos nécessaires au ré-assemblage. Les opérateurs binaires de StreamAnalytics étaient à l’époque très limités (et semblent le rester)
L’autre solution aurait consisté à utiliser des WebJobs pour parser les trames et à envoyer les trames « parsées » dans un EventHub pour qu’elles soient ensuite ré-assemblées par StreamAnalytics. Pas retenu car usine à gaz.
La solution Rx avec les opérateurs :
Rx GroupBy: http://reactivex.io/documentation/operators/groupby.html