Download - Démo – Node - people.redhat.compeople.redhat.com/.../june2017/DemoAppNodejsAutoscalingv1-2.pdf · Sylvain Lavoie Version 1.0 - juin 2017 Démo – Node.js Autoscaling App Node.js

Transcript
Page 1: Démo – Node - people.redhat.compeople.redhat.com/.../june2017/DemoAppNodejsAutoscalingv1-2.pdf · Sylvain Lavoie Version 1.0 - juin 2017 Démo – Node.js Autoscaling App Node.js

Sylvain LavoieVersion 1.0 - juin 2017

Démo – Node.jsAutoscaling App Node.js sur Openshift

Page 2: Démo – Node - people.redhat.compeople.redhat.com/.../june2017/DemoAppNodejsAutoscalingv1-2.pdf · Sylvain Lavoie Version 1.0 - juin 2017 Démo – Node.js Autoscaling App Node.js

Agenda

2

Notre site web « Ma filmothèque »2

Préparation de l’environnement OpenShift3

Outil de charge « httperf »4

Présentation de la plateforme « Node.js »1

Page 3: Démo – Node - people.redhat.compeople.redhat.com/.../june2017/DemoAppNodejsAutoscalingv1-2.pdf · Sylvain Lavoie Version 1.0 - juin 2017 Démo – Node.js Autoscaling App Node.js

Historique

Écrit par Ryan Dahl en 2009.

Il a été inspiré par une barre de progression dans un navigateur qui est déconnecté du serveur.

Projet « open source » et multiplateforme.

Caractéristiques

C’est un « JavaScript runtime » s’appuyant sur l’engin « Chrome's V8 JavaScript ».

Modèle « I/O non-blocking ».

Architecture évènementielle (Event-driven).

Un des plus gros écosystèmes de librairie « open source » avec « NPM ».

• Plusieurs frameworks dont Express, React, Angular, Meteor.

Applications écrites en JavaScript sous Node.js (https://electron.atom.io/apps/) Microsoft Visual Studio Code.

Atom A hackable text editor.

GitHub Desktop.

Plus de 1400 contributeurs au projet, dont plusieurs compagnies.

Stack MEAN (MongoDB Express Angular Node.js)

Présentation de la plateforme « Node.js »

3

1

Page 4: Démo – Node - people.redhat.compeople.redhat.com/.../june2017/DemoAppNodejsAutoscalingv1-2.pdf · Sylvain Lavoie Version 1.0 - juin 2017 Démo – Node.js Autoscaling App Node.js

Voir la stack des autres compagnies ( https://stackshare.io/ )

Les utilisateurs de Node.js

4

1

Page 5: Démo – Node - people.redhat.compeople.redhat.com/.../june2017/DemoAppNodejsAutoscalingv1-2.pdf · Sylvain Lavoie Version 1.0 - juin 2017 Démo – Node.js Autoscaling App Node.js

Site Web sous Node.js.

Sources sur Github : https://github.com/sylvoie/testoc.git

Déploiement et recréation de l’environnement :

Selon le fichier configuration « package.json »

Exécute commande « npm install »

• Installation « dependencies »

• Création répertoire « node_modules »

Exécute « start »: « node app.js »

Framework :

Bootstrap

Express

Embedded JavaScript templates (EJS)

Résultat de l’application

Un page Web

28 requêtes HTTP

• Dont 19 images

Poids 496.8 KB

Notre site web « Ma filmothèque »

5

2

package.json

Page 6: Démo – Node - people.redhat.compeople.redhat.com/.../june2017/DemoAppNodejsAutoscalingv1-2.pdf · Sylvain Lavoie Version 1.0 - juin 2017 Démo – Node.js Autoscaling App Node.js

Hands-on OpenShift

6

Page 7: Démo – Node - people.redhat.compeople.redhat.com/.../june2017/DemoAppNodejsAutoscalingv1-2.pdf · Sylvain Lavoie Version 1.0 - juin 2017 Démo – Node.js Autoscaling App Node.js

Création de notre projet

7

3

Page 8: Démo – Node - people.redhat.compeople.redhat.com/.../june2017/DemoAppNodejsAutoscalingv1-2.pdf · Sylvain Lavoie Version 1.0 - juin 2017 Démo – Node.js Autoscaling App Node.js

Choix d’un langage dans le catalogue

8

3

Page 9: Démo – Node - people.redhat.compeople.redhat.com/.../june2017/DemoAppNodejsAutoscalingv1-2.pdf · Sylvain Lavoie Version 1.0 - juin 2017 Démo – Node.js Autoscaling App Node.js

Précision du langage

9

3

Page 10: Démo – Node - people.redhat.compeople.redhat.com/.../june2017/DemoAppNodejsAutoscalingv1-2.pdf · Sylvain Lavoie Version 1.0 - juin 2017 Démo – Node.js Autoscaling App Node.js

https://github.com/sylvoie/testoc.git

Identifier notre projet et la source de note app

10

3

Page 11: Démo – Node - people.redhat.compeople.redhat.com/.../june2017/DemoAppNodejsAutoscalingv1-2.pdf · Sylvain Lavoie Version 1.0 - juin 2017 Démo – Node.js Autoscaling App Node.js

Paramètre de route pour rejoindre notre site web

11

3

Page 12: Démo – Node - people.redhat.compeople.redhat.com/.../june2017/DemoAppNodejsAutoscalingv1-2.pdf · Sylvain Lavoie Version 1.0 - juin 2017 Démo – Node.js Autoscaling App Node.js

Paramètre de déploiement et construction

12

3

Page 13: Démo – Node - people.redhat.compeople.redhat.com/.../june2017/DemoAppNodejsAutoscalingv1-2.pdf · Sylvain Lavoie Version 1.0 - juin 2017 Démo – Node.js Autoscaling App Node.js

Paramètres d’élasticité

13

3

Page 14: Démo – Node - people.redhat.compeople.redhat.com/.../june2017/DemoAppNodejsAutoscalingv1-2.pdf · Sylvain Lavoie Version 1.0 - juin 2017 Démo – Node.js Autoscaling App Node.js

Ajout d’une limitation des ressources CPU et RAM

14

3

Page 15: Démo – Node - people.redhat.compeople.redhat.com/.../june2017/DemoAppNodejsAutoscalingv1-2.pdf · Sylvain Lavoie Version 1.0 - juin 2017 Démo – Node.js Autoscaling App Node.js

Ajout d’étiquette

15

3

Page 16: Démo – Node - people.redhat.compeople.redhat.com/.../june2017/DemoAppNodejsAutoscalingv1-2.pdf · Sylvain Lavoie Version 1.0 - juin 2017 Démo – Node.js Autoscaling App Node.js

Votre projet est complété

16

3

Page 17: Démo – Node - people.redhat.compeople.redhat.com/.../june2017/DemoAppNodejsAutoscalingv1-2.pdf · Sylvain Lavoie Version 1.0 - juin 2017 Démo – Node.js Autoscaling App Node.js

Ajout d’un moniteur de santé

17

3

Page 18: Démo – Node - people.redhat.compeople.redhat.com/.../june2017/DemoAppNodejsAutoscalingv1-2.pdf · Sylvain Lavoie Version 1.0 - juin 2017 Démo – Node.js Autoscaling App Node.js

Ajout d’un moniteur de santé

18

3

Page 19: Démo – Node - people.redhat.compeople.redhat.com/.../june2017/DemoAppNodejsAutoscalingv1-2.pdf · Sylvain Lavoie Version 1.0 - juin 2017 Démo – Node.js Autoscaling App Node.js

Projet « open source » à l’origine développé par HP.

Outil CLI pour mesurer la performance d’un serveur Web en générant de la charge.

Sources sur Github : https://github.com/httperf/httperf

Pour l’invoquer :

httperf --server lesite --port 80 --num-conns 1000 --num-cal 100 --timeout 1 --hog --rate 100

Pour une description des autres options, voir le man httperf.

Autre outil « open source » : AB (Apache HTTP server benchmarking tool)

ab -k -n 1000 -c 10 -s 1 testoc-syltest2.apps.ose3sandbox.com/

man ab

Utilisation de HTTPERF (Invocation)

19

4

Options Description

--num-conn 3000 instructs httperf to make 3000 connections.

--num-cal 100 instructs httperf to issue 100 requests per connection.

--rate 200 specifies how many new connections are made every second, 200 in our case.

--timeout 1 instructs httperf to report as errors any requests that aren’t answered within X seconds.

--client=x/2 Specifies that the machine httperf is running on is client I out of a total of N clients.

Page 20: Démo – Node - people.redhat.compeople.redhat.com/.../june2017/DemoAppNodejsAutoscalingv1-2.pdf · Sylvain Lavoie Version 1.0 - juin 2017 Démo – Node.js Autoscaling App Node.js

Pour l’interprétation du résultat, voir : https://github.com/httperf/httperf

Utilisation de HTTPERF (Résultat)

20

4

Page 21: Démo – Node - people.redhat.compeople.redhat.com/.../june2017/DemoAppNodejsAutoscalingv1-2.pdf · Sylvain Lavoie Version 1.0 - juin 2017 Démo – Node.js Autoscaling App Node.js

Utilisation de HTTPERF

21

4

Page 22: Démo – Node - people.redhat.compeople.redhat.com/.../june2017/DemoAppNodejsAutoscalingv1-2.pdf · Sylvain Lavoie Version 1.0 - juin 2017 Démo – Node.js Autoscaling App Node.js

Période de questions

22

Pour toutes questions veuillez écrire à :[email protected]