ibm cloud university: build, deploy and scale node.js microservices

Post on 22-Jan-2018

169 Views

Category:

Software

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Chris Bailey STSM, Runtime Technologies

Enterprise Node.js: Build, Deploy and Scale

: Key Technologies

: Key Technologies

Container

: Key Technologies

Container Orchestration

: Key Technologies

Container Orchestration

Package and Deploy

: Key Technologies

Container Orchestration

MonitoringPackage and Deploy

: Key Technologies

Container Orchestration

Monitoring Distributed TracingPackage and Deploy

MICROSERVICES: Key Performance Characteristics

IO Speed • Performance • Scale

0300600900

1200

0

1,150

IO Speed • Performance • Scale

MICROSERVICES: Key Performance Characteristics

0300600900

1200

0

1,150

IO Speed • Performance • Scale

MICROSERVICES: Key Performance Characteristics

0300600900

1200897

1,150

MICROSERVICES: Key Performance Characteristics

IO Speed • Performance • Scale

0300600900

1200897

1,150

Startup • Availability • Scaling

MICROSERVICES: Key Performance Characteristics

IO Speed • Performance • Scale

0300600900

1200897

1,150

00.9

Startup • Availability • Scaling

MICROSERVICES: Key Performance Characteristics

IO Speed • Performance • Scale

0300600900

1200897

1,150 13.7

0.9

Startup • Availability • Scaling

MICROSERVICES: Key Performance Characteristics

IO Speed • Performance • Scale

0300600900

1200897

1,150 13.7

0.9

Startup • Availability • Scaling

Memory • Efficiency • Cost

MICROSERVICES: Key Performance Characteristics

IO Speed • Performance • Scale

0300600900

1200897

1,150 13.7

0.9 023.6

Startup • Availability • Scaling

Memory • Efficiency • Cost

MICROSERVICES: Key Performance Characteristics

IO Speed • Performance • Scale

0300600900

1200897

1,150 13.7

0.9

422

23.6

Startup • Availability • Scaling

Memory • Efficiency • Cost

MICROSERVICES: Key Performance Characteristics

IO Speed • Performance • Scale

Startup • Availability • Scaling

Memory • Efficiency • Cost

IO Speed • Performance • Scale

Release to Release Performance Gains

Startup • Availability • Scaling

Memory • Efficiency • Cost

3,0492,914

2,0761,866

4.x master6.x 8.x

Release to Release Performance Gains

IO Speed • Performance • Scale

Startup • Availability • Scaling

Memory • Efficiency • Cost

50,42052,64042,500

71,0003,0492,914

2,0761,866

4.x master6.x 8.x 4.x master6.x 8.x

IO Speed • Performance • Scale

Release to Release Performance Gains

Startup • Availability • Scaling

Memory • Efficiency • Cost

50,42052,64042,500

71,00089,02492,84091,47688,9603,0492,914

2,0761,866

4.x master6.x 8.x 4.x master6.x 8.x 4.x master6.x 8.x

IO Speed • Performance • Scale

Release to Release Performance Gains

Building Scalable Microservices

func add(_ a: Int, to b: Int) -> Void { print(a + b) }

let a = ”5” let b = 3

public/*test/*server/server.jspackage.jsonREADME.md.gitignore

LoopBack/

func add(_ a: Int, to b: Int) -> Void { print(a + b) }

let a = ”5” let b = 3

public/*test/*server/server.jspackage.jsonREADME.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);});

LoopBack/

func add(_ a: Int, to b: Int) -> Void { print(a + b) }

let a = ”5” let b = 3

public/*test/*server/server.jspackage.jsonREADME.md.gitignore

DockerfileDockerfile-tools.dockerignore

func add(_ a: Int, to b: Int) -> Void { print(a + b) }

let a = ”5” let b = 3

public/*test/*server/server.jspackage.jsonREADME.md.gitignore

DockerfileDockerfile-tools.dockerignore

FROM ibmcom/ibmnode

ENV NODE_ENV productionENV PORT 3000

WORKDIR "/app"

# Install app dependenciesCOPY package.json /app/RUN cd /app; npm install

# Bundle app sourceCOPY . /app

EXPOSE 3000CMD ["npm", "start"]

func add(_ a: Int, to b: Int) -> Void { print(a + b) }

let a = ”5” let b = 3

public/*test/*server/server.jspackage.jsonREADME.md.gitignore

DockerfileDockerfile-tools.dockerignore

node_modules/npm-debug.log

$ docker build -t <your username>/node-app .

$ docker build -t <your username>/node-app . $ docker run -p 49160:3000 -d <your username>/node-app

$ docker build -t <your username>/node-app . $ docker run -p 49160:3000 -d <your username>/node-app

$ docker build -t <your username>/node-app . $ docker run -p 49160:3000 -d <your username>/node-app

func add(_ a: Int, to b: Int) -> Void { print(a + b) }

let a = ”5” let b = 3

public/*test/*server/server.jspackage.jsonREADME.md.gitignore

DockerfileDockerfile-tools.dockerignore

chart/node-app/Chart.yamlchart/node-app/templates/deployment.yamlchart/node-app/templates/hpa.yamlchart/node-app/templates/service.yamlchart/node-app/values.yaml

HELM CHARTS

func add(_ a: Int, to b: Int) -> Void { print(a + b) }

let a = ”5” let b = 3

public/*test/*server/server.jspackage.jsonREADME.md.gitignore

DockerfileDockerfile-tools.dockerignore

chart/node-app/Chart.yamlchart/node-app/templates/deployment.yamlchart/node-app/templates/hpa.yamlchart/node-app/templates/service.yamlchart/node-app/values.yaml

HELM CHARTS

apiVersion: v1description: A Helm chart for Kubernetesname: node-appversion: 1.0.0

func add(_ a: Int, to b: Int) -> Void { print(a + b) }

let a = ”5” let b = 3

public/*test/*server/server.jspackage.jsonREADME.md.gitignore

DockerfileDockerfile-tools.dockerignore

chart/node-app/Chart.yamlchart/node-app/templates/deployment.yamlchart/node-app/templates/hpa.yamlchart/node-app/templates/service.yamlchart/node-app/values.yaml

HELM CHARTS

apiVersion: extensions/v1beta1kind: Deploymentmetadata: 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”

func add(_ a: Int, to b: Int) -> Void { print(a + b) }

let a = ”5” let b = 3

public/*test/*server/server.jspackage.jsonREADME.md.gitignore

DockerfileDockerfile-tools.dockerignore

chart/node-app/Chart.yamlchart/node-app/templates/deployment.yamlchart/node-app/templates/hpa.yamlchart/node-app/templates/service.yamlchart/node-app/values.yaml

HELM CHARTS

apiVersion: autoscaling/v2alpha1kind: HorizontalPodAutoscalermetadata: name: “node-app-hpa-policy" namespace: defaultspec: 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

func add(_ a: Int, to b: Int) -> Void { print(a + b) }

let a = ”5” let b = 3

public/*test/*server/server.jspackage.jsonREADME.md.gitignore

DockerfileDockerfile-tools.dockerignore

chart/node-app/Chart.yamlchart/node-app/templates/deployment.yamlchart/node-app/templates/hpa.yamlchart/node-app/templates/service.yamlchart/node-app/values.yaml

HELM CHARTS

apiVersion: v1kind: Servicemetadata: name: “node-app“ labels: chart: “node-app-1.0.0”spec: type: NodePort ports: - port: 3000 selector: app: “node-app-selector"

$ helm package ./chart/node-app

$ helm package ./chart/node-app$ helm install ./node-app-1.0.0.tgz

$ helm package ./chart/node-app$ helm install ./node-app-1.0.0.tgz

$ helm package ./chart/node-app$ helm install ./node-app-1.0.0.tgz

Deploying Scalable Microservices

func add(_ a: Int, to b: Int) -> Void { print(a + b) }

let a = ”5” let b = 3

public/*test/*server/server.jspackage.jsonREADME.md.gitignore

Jenkinsfile

func add(_ a: Int, to b: Int) -> Void { print(a + b) }

let a = ”5” let b = 3

public/*test/*server/server.jspackage.jsonREADME.md.gitignore

Jenkinsfile

#!groovy

@Library('MicroserviceBuilder') _microserviceBuilderPipeline { image = 'node-frontend'}

func add(_ a: Int, to b: Int) -> Void { print(a + b) }

let a = ”5” let b = 3

public/*test/*server/server.jspackage.jsonREADME.md.gitignore

Jenkinsfile

.bluemix/deploy.json

.bluemix/pipeline.yml

.bluemix/toolchain.yml

DevOps

func add(_ a: Int, to b: Int) -> Void { print(a + b) }

let a = ”5” let b = 3

public/*test/*server/server.jspackage.jsonREADME.md.gitignore

Jenkinsfile

.bluemix/deploy.json

.bluemix/pipeline.yml

.bluemix/toolchain.yml

stages:- name: Build Stage inputs: - type: git branch: master service: ${REPO} jobs: - name: Build type: builder artifact_dir : ''- name: Deploy Stage inputs: - type: job stage: Build Stage job: Build triggers: - type: stage jobs: - name: Deploy type: deployer target: region_id: ${REGION_ID} organization: ${ORGANIZATION} space: ${SPACE} application: ${APP} script: |- #!/bin/bash

DevOps

func add(_ a: Int, to b: Int) -> Void { print(a + b) }

let a = ”5” let b = 3

public/*test/*server/server.jspackage.jsonREADME.md.gitignore

Jenkinsfile

.bluemix/deploy.json

.bluemix/pipeline.yml

.bluemix/toolchain.yml

version: 0.2required: - deploy - repo

toolchain: name: node-app

# Github reposrepo: service_id: hostedgit parameters: repo_url: "{{zip_url}}" repo_name: "{{toolchain.name}}" type: clone has_issues: true enable_traceability: true

# Pipelinesbuild: service_id: pipeline parameters: name: "{{name}}" ui-pipeline: true configuration: content: $file(pipeline.yml) env:

DevOps

Understanding Microservices Performance

PUBLIC NETWORK CLOUD NETWORK

CATALOG

ORDER

INVENTORY

USER

MySQL

MongoDB

SPARK

ELASTICSEARCH

BACKEND FOR FRONTEND MICROSERVICES SERVICES

LOAD BALANCER

PUBLIC NETWORK CLOUD NETWORK

CATALOG

ORDER

INVENTORY

USER

MySQL

MongoDB

SPARK

ELASTICSEARCH

BACKEND FOR FRONTEND MICROSERVICES SERVICES

LOAD BALANCER

PUBLIC NETWORK CLOUD NETWORK

CATALOG

ORDER

INVENTORY

USER

MySQL

MongoDB

SPARK

ELASTICSEARCH

BACKEND FOR FRONTEND MICROSERVICES SERVICES

LOAD BALANCER

PUBLIC NETWORK CLOUD NETWORK

CATALOG

ORDER

INVENTORY

USER

MySQL

MongoDB

SPARK

ELASTICSEARCH

BACKEND FOR FRONTEND MICROSERVICES SERVICES

LOAD BALANCER

PUBLIC NETWORK CLOUD NETWORK

CATALOG

ORDER

INVENTORY

USER

MySQL

MongoDB

SPARK

ELASTICSEARCH

BACKEND FOR FRONTEND MICROSERVICES SERVICES

LOAD BALANCER

PUBLIC NETWORK CLOUD NETWORK

CATALOG

ORDER

INVENTORY

USER

MySQL

MongoDB

SPARK

ELASTICSEARCH

BACKEND FOR FRONTEND MICROSERVICES SERVICES

LOAD BALANCER

PUBLIC NETWORK CLOUD NETWORK

CATALOG

ORDER

INVENTORY

USER

MySQL

MongoDB

SPARK

ELASTICSEARCH

BACKEND FOR FRONTEND MICROSERVICES SERVICES

LOAD BALANCER

BROWSER

TIME

BROWSER

LOAD BALANCER

TIME

BROWSER

LOAD BALANCER

WEB BFF

TIME

BROWSER

LOAD BALANCER

WEB BFF

ORDER SERVICE

TIME

BROWSER

LOAD BALANCER

WEB BFF

ORDER SERVICE

MongoDB

TIME

BROWSER

LOAD BALANCER

WEB BFF

ORDER SERVICE

MongoDB

INVENTORY SERVICE

TIME

MySQL

BROWSER

LOAD BALANCER

WEB BFF

ORDER SERVICE

MongoDB

INVENTORY SERVICE

TIME

MySQL

BROWSER

LOAD BALANCER

WEB BFF

ORDER SERVICE

MongoDB

INVENTORY SERVICE

MongoDB

TIME

• 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

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);});

• 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

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);});

• ‘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

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’

‘appmetrics-dash’

‘appmetrics-dash’

$ yo nodeserver$ yo nodeserver

DEMO

Common Microservices Approach

Config Fault Tolerance Health Check Health Metrics JWT Propagation

externalize configuration to improve portability

build robust behavior to cope with unexpected

failures

common format to determine service

availability

common REST endpoints for monitoring

service health

interoperable authentication and role-based access control

Config Fault Tolerance Health Check Health Metrics JWT Propagation

externalize configuration to improve portability

build robust behavior to cope with unexpected

failures

common format to determine service

availability

common REST endpoints for monitoring

service health

interoperable authentication and role-based access control

ibm-cloud-env hystrix-js /health appmetrics-prometheus jsonwebtoken

Microservice Builder for Java: From development to productionDevelopment Deployment Runtime

Liberty App Accelerator

MicroProfile Programming Model

Developer CLI Jenkins Pipeline

Zipkin Distributed Trace Server

Certificate key and trust store

key.jks trust.jks

IBM Cloud private

Entitled with WAS ND or IBM Cloud PrivateFree

Development Deployment Runtime

Liberty App Accelerator

Developer CLI Jenkins Pipeline

Zipkin Distributed Trace Server

Certificate key and trust store

key.jks trust.jks

IBM Cloud private

Entitled with WAS ND or IBM Cloud PrivateFree

Express or Loopback Frameworks

LoopBack

Microservice Builder for Node.js: From development to production

Development Deployment Runtime

Liberty App Accelerator

Jenkins Pipeline

Zipkin Distributed Trace Server

Certificate key and trust store

key.jks trust.jks

IBM Cloud private

Entitled with WAS ND or IBM Cloud PrivateFree

Express or Loopback Frameworks

LoopBack

Developer CLI (yo nodeserver or IDT)

Microservice Builder for Node.js: From development to production

Development Deployment Runtime

Jenkins Pipeline

Zipkin Distributed Trace Server

Certificate key and trust store

key.jks trust.jks

IBM Cloud private

Entitled with WAS ND or IBM Cloud PrivateFree

Express or Loopback Frameworks

LoopBack

Developer CLI (yo nodeserver or IDT)

Cloud App Service

Microservice Builder for Node.js: From development to production

Development Deployment Runtime

Cloud App Service

Express or Loopback Frameworks

Developer CLI (yo nodeserver or IDT) Jenkins Pipeline

Zipkin Distributed Trace Server

Certificate key and trust store

key.jks trust.jks

IBM Cloud private

Entitled with IBM Advanced Support for Runtimes or IBM Cloud PrivateFree

LoopBack

Microservice Builder for Node.js: From development to production

Enterprise Support

85

IBM Foundation Support for Runtimes

generator-nodeserverappmetrics monitoring

generator-swiftserverswiftmetrics monitoringjavametrics monitoring

IBM Support for Runtimes

Enterprise Support: Node.js Runtime

86

LoopBack

IBM Foundation Support for Runtimes

generator-nodeserverappmetrics monitoring

generator-swiftserverswiftmetrics monitoringjavametrics monitoring

IBM Support for Runtimes

IBM Advanced Support for Runtime Frameworks

Enterprise Support: Frameworks

87

LoopBack

IBM Foundation Support for Runtimes

IBM Advanced Support for Runtime Frameworks

generator-nodeserverappmetrics monitoring

generator-swiftserverswiftmetrics monitoringjavametrics monitoring

IBM Support for Runtimes

Enterprise Support: Module Ecosystem

developer.ibm.com/node

top related