+ All Categories
Home > Documents > Battle Ready! - Hardening Node.js for the...

Battle Ready! - Hardening Node.js for the...

Date post: 05-Aug-2020
Category:
Upload: others
View: 2 times
Download: 0 times
Share this document with a friend
41
Battle Ready! - Hardening Node.js for the Enterprise Jeff Barczewski codewinds.com
Transcript
Page 1: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

Battle Ready! - HardeningNode.js for the Enterprise

Jeff Barczewski

codewinds.com CodeWinds

Page 4: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

Why build scalable, durableapps?

Page 5: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full
Page 6: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full
Page 7: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full
Page 8: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

Who am I?25 yrs professional developer3 yrs full time with Node.jsMasterCard, Elsevier, RGA, USAFCodeWinds Podcast and Training

Page 9: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

Elsevier Education PlatformRapid Development AppsNode.jsIsomorphic Javascript

Page 10: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

MasterCard CaaSCrypto as a ServiceNode.js plus addon HSMREST APIHighly scalable and availableReporting, Administration

Page 11: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

MasterCard / Apple Pay LaunchComplex deployment, many third partiesField testingUS public launch - "It just worked"

Page 12: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

Other Enterprise UseWalmartPay Pal, LinkedinYahoo, ebay, Uber, Netflixhttp://nodejs.org/industry/

Page 13: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

Legacy Code & Stagnation

Page 14: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

"Inspire with your actions"

Page 15: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

How to Introduce Node.jsSimple beginnings

CLI toolsBatch processingAdmin applicationsGreen field projects, REST, SPA

Page 16: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

Smart API reverse proxy

by API Proxy Yury Baranovsky

SSO, batchingOrchestration, cachingDevice specific contentMigration, AB Testing

Page 17: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

Inspired

Page 19: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

F15 Video - I shared an edited

portion of this video in my talkFull F15 video from 67FS

Page 20: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

Life happens

Page 21: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

F15 Single Wing Landing

by History ChannelF-15 Single wing landing

Page 22: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

Traits that inspire mePerformantAdaptabilityDurabilityTrusted

Page 23: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

Design and FoundationsWhat frameworks and tools?

Hapi, Express, RestifyIs it battle tested? Quality? Community? License?Prototype with APIJoi, Wreck

Page 24: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

Express & Hapi

Licensed Army Car Garage by U.S. Army CC BY-SA 2.0

Stingray by Jeff Barczewski

Page 25: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

Express Example p1var express = require('express');

var compression = require('compression')

var logger = require('morgan');

var cookieParser = require('cookie-parser');

var bodyParser = require('body-parser');

var app = express();

app.use(compression())

app.use(logger('dev'));

app.use(bodyParser.json());

app.use(bodyParser.urlencoded({ extended: false }));

app.use(cookieParser());

Page 26: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

Express Example p2app.get('/', function (req, res) {

res.send({ hello: 'world' });

});

// catch 404 and forward to error handler

app.use(function(req, res, next) {

var err = new Error('Not Found');

err.status = 404;

next(err);

});

app.listen(3000, function(){

console.log('Express server listening on port ' + 3000); });

Page 27: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

Hapi Examplevar Hapi = require('hapi');

var server = new Hapi.Server(3000);

server.route({

method: 'GET', path: '/',

handler: function (request, reply) {

reply({ hello: 'world' });

}

});

server.start(function () {

console.log('Server running at:', server.info.uri);

});

Page 28: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

Design and FoundationsWhere to store data?

Redis - caching, sessions, queuesREST services - SQL (postgres), noSQL (riak,dynamo, leveldb)async libraries, uses, verifySharding plan

Page 29: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

Design and FoundationsReducing risk

RDD, Test API, CIGit pull requests, shrinkwrapjshint, markdown, jsdocNode.js / JS training

Page 30: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

How do we scale up?Node.js evented architectureCluster, Child processes, Containers, ZonesLoad balancer, nginx, HA proxy, apache

Page 31: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

How do we know it will scale?Load Test, stress test, vary workloadbench-rest, wrk, abload runner, blitz.iobenchmark frequently

Page 32: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

bench-rest // unique PUT and then a GET for each iteration

var flow = {

main: [

{ put: 'http://localhost:8000/foo_#{INDEX}',

json: 'mydata_#{INDEX}' },

{ get: 'http://localhost:8000/foo_#{INDEX}' }

]

};

module.exports = flow;

Page 34: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

ResilienceHow do we make this durable?

child processes, cluster_master_extDetect process exit, restartDB failures, reconnect generic-pool, backoffMonit, upstart, forever, nscale

Page 35: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

cluster_master_extvar clusterMaster = require("cluster-master-ext");

clusterMaster({

exec: "worker.js", // script to run

size: 5, // number of workers

env: { SOME: "environment_vars" },

args: [ "--deep", "doop" ],

silent: true,

signals: true

});

Page 36: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

How to make this hotdeployable?

Rolling restartHandle shutdown, exit cleanly, fail safe timeoutSignals: TERM, INT - shutdown, HUP - rollingrestart

Page 37: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

How do we monitor?Logging? Events?Bunyan, jeffbski/hapi-bunyan-liteMonit, upstart, forever, nscaleNotifying, dtrace, vasyncCharting - Rickshaw, zag, statsd/graphite,influxdb

Page 38: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

Demonstration

Page 39: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

True Friend

Page 40: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

Resilient Solutions

Licensed Properties of Resilient Systems by DoD CC BY-NC-ND 3.0

StrongReliableTrustedAdaptable

Page 41: Battle Ready! - Hardening Node.js for the Enterprisecodewinds.com/assets/article/battle-ready-hardening-nodejs-enterprise.pdfapps? Who am I? 25 yrs professional developer 3 yrs full

To learn more

CodeWinds - Resilient [email protected]@codewinds @jeffbski

http://codewinds.com/nodevember


Recommended