Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

Node Interactive: Node.js Performance and Highly Scalable Micro-Services

415 vues

Publié le

The fundamental performance characteristics of Node.js, along with the improvements driven through the community benchmarking workgroup, makes Node.js ideal for highly performing micro-service workloads. Translating that into highly responsive, scalable solutions however is still far from easy. This session will discuss why Node.js is right for micro-services, introduce the best practices for building scalable deployments, and show you how to monitor and profile your applications to identify and resolve performance bottlenecks.

Publié dans : Logiciels
  • Soyez le premier à commenter

Node Interactive: Node.js Performance and Highly Scalable Micro-Services

  1. 1. Highly Scalable
 Node.js Microservices 
 
 Chris Bailey (@Chris__Bailey) 
 Node.js and Swift Runtimes Chris Vignola (@ChrisVignola) 
 Cloud Native Node.js
  2. 2. : Key Technologies
  3. 3. : Key Technologies Container
  4. 4. : Key Technologies Container Orchestration
  5. 5. : Key Technologies Container Orchestration Package and Deploy
  6. 6. : Key Technologies Container Orchestration MonitoringPackage and Deploy
  7. 7. : Key Technologies Container Orchestration Monitoring Distributed TracingPackage and Deploy
  8. 8. MICROSERVICES: Key Performance Characteristics IO Speed • Performance • Scale
  9. 9. 0 300 600 900 200 0 1,150 IO Speed • Performance • Scale MICROSERVICES: Key Performance Characteristics
  10. 10. 0 300 600 900 200 0 1,150 IO Speed • Performance • Scale MICROSERVICES: Key Performance Characteristics
  11. 11. 0 300 600 900 200 897 1,150 MICROSERVICES: Key Performance Characteristics IO Speed • Performance • Scale
  12. 12. 0 300 600 900 200 897 1,150 Startup • Availability • Scaling MICROSERVICES: Key Performance Characteristics IO Speed • Performance • Scale
  13. 13. 0 300 600 900 200 897 1,150 00.9 Startup • Availability • Scaling MICROSERVICES: Key Performance Characteristics IO Speed • Performance • Scale
  14. 14. 0 300 600 900 200 897 1,150 13.7 0.9 Startup • Availability • Scaling MICROSERVICES: Key Performance Characteristics IO Speed • Performance • Scale
  15. 15. 0 300 600 900 200 897 1,150 13.7 0.9 Startup • Availability • Scaling Memory • Efficiency • Cost MICROSERVICES: Key Performance Characteristics IO Speed • Performance • Scale
  16. 16. 0 300 600 900 200 897 1,150 13.7 0.9 023.6 Startup • Availability • Scaling Memory • Efficiency • Cost MICROSERVICES: Key Performance Characteristics IO Speed • Performance • Scale
  17. 17. 0 300 600 900 200 897 1,150 13.7 0.9 422 23.6 Startup • Availability • Scaling Memory • Efficiency • Cost MICROSERVICES: Key Performance Characteristics IO Speed • Performance • Scale
  18. 18. Startup • Availability • Scaling Memory • Efficiency • Cost Benchmarking WG: Performance Gains IO Speed • Performance • Scale
  19. 19. Startup • Availability • Scaling Memory • Efficiency • Cost 3,049 2,914 2,076 1,866 4.x master6.x 8.x Benchmarking WG: Performance Gains IO Speed • Performance • Scale
  20. 20. Startup • Availability • Scaling Memory • Efficiency • Cost 50,42052,640 42,500 71,000 3,049 2,914 2,076 1,866 4.x master6.x 8.x 4.x master6.x 8.x Benchmarking WG: Performance Gains IO Speed • Performance • Scale
  21. 21. Startup • Availability • Scaling Memory • Efficiency • Cost 50,42052,640 42,500 71,000 89,024 92,84091,47688,9603,049 2,914 2,076 1,866 4.x master6.x 8.x 4.x master6.x 8.x 4.x master6.x 8.x Benchmarking WG: Performance Gains IO Speed • Performance • Scale
  22. 22. Building Scalable Microservices
  23. 23. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 public/* test/* server/server.js package.json README.md .gitignore
  24. 24. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 public/* test/* server/server.js package.json README.md .gitignore const appName = require('./../package').name; const express = require('express'); const log4js = require(‘log4js'); const logger = log4js.getLogger(appName); const app = express(); app.get('/', function (req, res) { res.send('Hello World!') }) const port = process.env.PORT || 3000; app.listen(port, function(){ logger.info(`Express listening on: ` + port); });
  25. 25. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 public/* test/* server/server.js package.json README.md .gitignore Dockerfile Dockerfile-tools .dockerignore
  26. 26. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 public/* test/* server/server.js package.json README.md .gitignore Dockerfile Dockerfile-tools .dockerignore FROM ibmcom/ibmnode ENV NODE_ENV production ENV PORT 3000 WORKDIR "/app" # Install app dependencies COPY package.json /app/ RUN cd /app; npm install # Bundle app source COPY . /app EXPOSE 3000 CMD ["npm", "start"]
  27. 27. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 public/* test/* server/server.js package.json README.md .gitignore Dockerfile Dockerfile-tools .dockerignore node_modules/ npm-debug.log
  28. 28. $ docker build -t <your username>/node-app .

  29. 29. $ docker build -t <your username>/node-app .
 $ docker run -p 49160:3000 -d <your username>/node-app
  30. 30. $ docker build -t <your username>/node-app .
 $ docker run -p 49160:3000 -d <your username>/node-app
  31. 31. $ docker build -t <your username>/node-app .
 $ docker run -p 49160:3000 -d <your username>/node-app
  32. 32. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 public/* test/* server/server.js package.json README.md .gitignore Dockerfile Dockerfile-tools .dockerignore chart/node-app/Chart.yaml chart/node-app/templates/deployment.yaml chart/node-app/templates/hpa.yaml chart/node-app/templates/service.yaml chart/node-app/values.yaml HELM CHARTS
  33. 33. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 public/* test/* server/server.js package.json README.md .gitignore Dockerfile Dockerfile-tools .dockerignore chart/node-app/Chart.yaml chart/node-app/templates/deployment.yaml chart/node-app/templates/hpa.yaml chart/node-app/templates/service.yaml chart/node-app/values.yaml HELM CHARTS apiVersion: v1 description: A Helm chart for Kubernetes name: node-app version: 1.0.0
  34. 34. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 public/* test/* server/server.js package.json README.md .gitignore Dockerfile Dockerfile-tools .dockerignore chart/node-app/Chart.yaml chart/node-app/templates/deployment.yaml chart/node-app/templates/hpa.yaml chart/node-app/templates/service.yaml chart/node-app/values.yaml HELM CHARTS apiVersion: extensions/v1beta1 kind: Deployment metadata: name: “node-app-deployment" labels: chart: “node-app-1.0.0” spec: replicas: “5” revisionHistoryLimit: “1” template: metadata: labels: app: “node-app-selector" version: “1.0.0” spec: containers: - name: “node-app” image: “repository:1.0.0” imagePullPolicy: Always livenessProbe: httpGet: path: /health port: 3000 initialDelaySeconds: 3000 periodSeconds: 1000 resources: requests: cpu: "200m" memory: "300Mi" env: - name: PORT value : “3000”
  35. 35. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 public/* test/* server/server.js package.json README.md .gitignore Dockerfile Dockerfile-tools .dockerignore chart/node-app/Chart.yaml chart/node-app/templates/deployment.yaml chart/node-app/templates/hpa.yaml chart/node-app/templates/service.yaml chart/node-app/values.yaml HELM CHARTS apiVersion: autoscaling/v2alpha1 kind: HorizontalPodAutoscaler metadata: name: “node-app-hpa-policy" namespace: default spec: scaleTargetRef: apiVersion: apps/v1beta1 kind: Deployment name: “node-app-deployment" minReplicas: 5 maxReplicas: 10 metrics: - type: Resource resource: name: cpu targetAverageUtilization: 70 - type: Resource resource: name: memory targetAverageUtilization: 70
  36. 36. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 public/* test/* server/server.js package.json README.md .gitignore Dockerfile Dockerfile-tools .dockerignore chart/node-app/Chart.yaml chart/node-app/templates/deployment.yaml chart/node-app/templates/hpa.yaml chart/node-app/templates/service.yaml chart/node-app/values.yaml HELM CHARTS apiVersion: v1 kind: Service metadata: name: “node-app“ labels: chart: “node-app-1.0.0” spec: type: NodePort ports: - port: 3000 selector: app: “node-app-selector"
  37. 37. $ helm package ./chart/node-app
  38. 38. $ helm package ./chart/node-app $ helm install ./node-app-1.0.0.tgz
  39. 39. $ helm package ./chart/node-app $ helm install ./node-app-1.0.0.tgz
  40. 40. $ helm package ./chart/node-app $ helm install ./node-app-1.0.0.tgz
  41. 41. Understanding Microservices Performance
  42. 42. PUBLIC NETWORK CLOUD NETWORK CATALOG ORDER INVENTORY USER MySQL MongoDB SPARK ELASTICSEARCH BACKEND FOR
 FRONTEND MICROSERVICES SERVICES LOAD
 BALANCER
  43. 43. PUBLIC NETWORK CLOUD NETWORK CATALOG ORDER INVENTORY USER MySQL MongoDB SPARK ELASTICSEARCH BACKEND FOR
 FRONTEND MICROSERVICES SERVICES LOAD
 BALANCER
  44. 44. PUBLIC NETWORK CLOUD NETWORK CATALOG ORDER INVENTORY USER MySQL MongoDB SPARK ELASTICSEARCH BACKEND FOR
 FRONTEND MICROSERVICES SERVICES LOAD
 BALANCER
  45. 45. PUBLIC NETWORK CLOUD NETWORK CATALOG ORDER INVENTORY USER MySQL MongoDB SPARK ELASTICSEARCH BACKEND FOR
 FRONTEND MICROSERVICES SERVICES LOAD
 BALANCER
  46. 46. PUBLIC NETWORK CLOUD NETWORK CATALOG ORDER INVENTORY USER MySQL MongoDB SPARK ELASTICSEARCH BACKEND FOR
 FRONTEND MICROSERVICES SERVICES LOAD
 BALANCER
  47. 47. PUBLIC NETWORK CLOUD NETWORK CATALOG ORDER INVENTORY USER MySQL MongoDB SPARK ELASTICSEARCH BACKEND FOR
 FRONTEND MICROSERVICES SERVICES LOAD
 BALANCER
  48. 48. PUBLIC NETWORK CLOUD NETWORK CATALOG ORDER INVENTORY USER MySQL MongoDB SPARK ELASTICSEARCH BACKEND FOR
 FRONTEND MICROSERVICES SERVICES LOAD
 BALANCER
  49. 49. BROWSER TIME
  50. 50. BROWSER LOAD BALANCER TIME
  51. 51. BROWSER LOAD BALANCER WEB BFF TIME
  52. 52. BROWSER LOAD BALANCER WEB BFF ORDER SERVICE TIME
  53. 53. BROWSER LOAD BALANCER WEB BFF ORDER SERVICE MongoDB TIME
  54. 54. BROWSER LOAD BALANCER WEB BFF ORDER SERVICE MongoDB INVENTORY SERVICE TIME
  55. 55. MySQL BROWSER LOAD BALANCER WEB BFF ORDER SERVICE MongoDB INVENTORY SERVICE TIME
  56. 56. MySQL BROWSER LOAD BALANCER WEB BFF ORDER SERVICE MongoDB INVENTORY SERVICE MongoDB TIME
  57. 57. • Collects data from each enabled service
 • Propagates correlation ID using HTTP headers
 • Provides sampling, tracing, and debug capabilities • Collects microsecond timestamps
 • Correlates data in Zipkin server • Presents data in Zipkin dashboard Request Tracking: OpenTracing and Zipkin
  58. 58. const zipkin = require(‘appmetrics-zipkin’); const rest = require(‘rest'); const express = require('express'); const app = express(); app.get('/', (req, res) => { rest('http://localhost:9000/api') .then(response => res.send(response.entity)) .catch(err => console.error('Error', err.stack)); }); const port = process.env.PORT || 3000; app.listen(port, function(){ logger.info(`Express listening on: ` + port); });
  59. 59. • Collects data from each enabled service
 • Requires /metrics endpoint providing data
 • Provides storage and correlation capabilities • Provide customisable dashboard
 • Integrates with Graphana, Graphite, etc Microservice Metrics: Prometheus
  60. 60. const zipkin = require(‘appmetrics-zipkin’); const prometheus = require(‘appmetrics-prometheus’).attach(); const rest = require(‘rest'); const express = require('express'); const app = express(); app.get('/', (req, res) => { rest('http://localhost:9000/api') .then(response => res.send(response.entity)) .catch(err => console.error('Error', err.stack)); }); const port = process.env.PORT || 3000; app.listen(port, function(){ logger.info(`Express listening on: ` + port); });
  61. 61. • ‘appmetrics-dash’ provides self-hosted monitoring
 • Inbound and Outbound request performance • Resource and event loop monitoring • Request a node-report
 • Enable profiling and flame graphs Deep Analysis: ‘appmetrics-dash’ and Flame Graphs
  62. 62. const zipkin = require(‘appmetrics-zipkin’); const prometheus = require(‘appmetrics-prometheus’).attach(); const dash = require(‘appmetrics-dash’).attach(); const rest = require(‘rest'); const express = require('express'); const app = express(); app.get('/', (req, res) => { rest('http://localhost:9000/api') .then(response => res.send(response.entity)) .catch(err => console.error('Error', err.stack)); }); const port = process.env.PORT || 3000; app.listen(port, function(){ logger.info(`Express listening on: ` + port); }); ‘appmetrics-dash’
  63. 63. ‘appmetrics-dash’
  64. 64. ‘appmetrics-dash’
  65. 65. $ yo nodeserver$ yo nodeserver
  66. 66. developer.ibm.com/node
  67. 67. const rest = require(‘rest'); const express = require('express'); const CLSContext = require('zipkin-context-cls'); const {Tracer} = require('zipkin'); const {recorder} = require('./recorder'); const ctxImpl = new CLSContext('zipkin'); const tracer = new Tracer({ctxImpl, recorder}); const app = express(); const zipkinMiddleware = require('zipkin-instrumentation-express').expressMiddleware; app.use(zipkinMiddleware({tracer, serviceName: 'frontend'})); const {restInterceptor} = require('zipkin-instrumentation-cujojs-rest'); const zipkinRest = rest.wrap(restInterceptor, {tracer, remoteServiceName: ‘backend'});
 app.get('/', (req, res) => { zipkinRest('http://localhost:9000/api') .then(response => res.send(response.entity)) .catch(err => console.error('Error', err.stack)); });

×