Integrating Node.js Into Your Ecosystem

100
Integrating Node into your ecosystem

Transcript of Integrating Node.js Into Your Ecosystem

Page 1: Integrating Node.js Into Your Ecosystem

Integrating Nodeinto your ecosystem

Page 2: Integrating Node.js Into Your Ecosystem

hello worldAlex Liu @stinkydofu [email protected]

Page 3: Integrating Node.js Into Your Ecosystem
Page 4: Integrating Node.js Into Your Ecosystem
Page 5: Integrating Node.js Into Your Ecosystem
Page 6: Integrating Node.js Into Your Ecosystem
Page 7: Integrating Node.js Into Your Ecosystem
Page 8: Integrating Node.js Into Your Ecosystem
Page 9: Integrating Node.js Into Your Ecosystem
Page 10: Integrating Node.js Into Your Ecosystem
Page 11: Integrating Node.js Into Your Ecosystem
Page 12: Integrating Node.js Into Your Ecosystem

node.js

Page 13: Integrating Node.js Into Your Ecosystem

$ npm install service-discovery npm ERR! 404 Not Found

$ npm install dynamic-config npm ERR! 404 Not Found

$ npm install metrics-client npm ERR! 404 Not Found

Page 14: Integrating Node.js Into Your Ecosystem
Page 15: Integrating Node.js Into Your Ecosystem

What is your goal?answer the simple questions first.

Page 16: Integrating Node.js Into Your Ecosystem

“ I want to use …

Page 17: Integrating Node.js Into Your Ecosystem

“ I want to use node.js

Page 18: Integrating Node.js Into Your Ecosystem

“ I don’t want to rebuild my entire app

Page 19: Integrating Node.js Into Your Ecosystem

“ I want to move incrementally

Page 20: Integrating Node.js Into Your Ecosystem

“ I am going off the paved road

Page 21: Integrating Node.js Into Your Ecosystem

The 6 Step Plan( aka, The Netflix Story™ )

Page 22: Integrating Node.js Into Your Ecosystem

1Identify your ecosystem.

Page 23: Integrating Node.js Into Your Ecosystem

What does your ecosystem look like?

your answer can make a difference!

Page 24: Integrating Node.js Into Your Ecosystem

monolithic applicationA single-tiered software application in which the user interface and data access code are combined into a single program from a single platform.

Page 25: Integrating Node.js Into Your Ecosystem

data access logic

business logic

UI

database

Page 26: Integrating Node.js Into Your Ecosystem

data access logic

business logic

UI

Page 27: Integrating Node.js Into Your Ecosystem

data access logic

business logic

UI

Page 28: Integrating Node.js Into Your Ecosystem

SOA (service oriented architecture)

A design pattern based on distinct pieces of software providing application functionality as services to other applications via a protocol.

Page 29: Integrating Node.js Into Your Ecosystem

UI

service

business logic

serviceservice

business logicbusiness logic

Page 30: Integrating Node.js Into Your Ecosystem

REST all the things!

Page 31: Integrating Node.js Into Your Ecosystem

service

service

service

Page 32: Integrating Node.js Into Your Ecosystem

service

service

service

Page 33: Integrating Node.js Into Your Ecosystem

service

service

service

Page 34: Integrating Node.js Into Your Ecosystem

service

service

service

Page 35: Integrating Node.js Into Your Ecosystem

2Use configurable

routing

Page 36: Integrating Node.js Into Your Ecosystem

reverse proxy

/home

/test

service

service

service

Page 37: Integrating Node.js Into Your Ecosystem

Use a reverse proxy as a configurable

routing layer.top tip

Page 38: Integrating Node.js Into Your Ecosystem

/home

/profile

Page 39: Integrating Node.js Into Your Ecosystem

Control

Test

Page 40: Integrating Node.js Into Your Ecosystem

90%

10%

Page 41: Integrating Node.js Into Your Ecosystem

US

EU

Page 42: Integrating Node.js Into Your Ecosystem

ON

Page 43: Integrating Node.js Into Your Ecosystem

OFF

Page 44: Integrating Node.js Into Your Ecosystem

Avoid subdomains.

top tip

Page 45: Integrating Node.js Into Your Ecosystem

3Identify necessary

ecosystem services.

Page 46: Integrating Node.js Into Your Ecosystem

service discoverydiscover, and be discovered

Page 47: Integrating Node.js Into Your Ecosystem

service discovery> registration > health check> client discovery

Page 48: Integrating Node.js Into Your Ecosystem

configurationconfiguration management on

a per environment basis

Page 49: Integrating Node.js Into Your Ecosystem

configuration> storage > (de-)centralized config> dynamic config

Page 50: Integrating Node.js Into Your Ecosystem

observability is of the utmost importance

metrics

Page 51: Integrating Node.js Into Your Ecosystem

> observability > real time metrics> monitoring > alerts > logging vs. metrics

metrics

Page 52: Integrating Node.js Into Your Ecosystem

determine your minimum units of deployment

build + deploy

Page 53: Integrating Node.js Into Your Ecosystem

> VMs > AMIs> CI + CD> Docker

build + deploy

Page 54: Integrating Node.js Into Your Ecosystem

What are our options?

Page 55: Integrating Node.js Into Your Ecosystem

4Rebuild or reuse?

Page 56: Integrating Node.js Into Your Ecosystem

Measure success by the cost of maintenance.

top tip

Page 57: Integrating Node.js Into Your Ecosystem

Rebuild

Page 58: Integrating Node.js Into Your Ecosystem

It’s an opportunity for a fresh start.

Rebuild

Page 59: Integrating Node.js Into Your Ecosystem

Lightweight modules are great for prototyping.

Rebuild

Page 60: Integrating Node.js Into Your Ecosystem

Don’t rebuild your entire ecosystem.

Rebuild

Page 61: Integrating Node.js Into Your Ecosystem

Chicken, meet Egg.

Page 62: Integrating Node.js Into Your Ecosystem

Reuse

Page 63: Integrating Node.js Into Your Ecosystem

You’re not reinventing the wheel.

Reuse

Page 64: Integrating Node.js Into Your Ecosystem

You can reduce overall platform

maintenance cost.

Reuse

Page 65: Integrating Node.js Into Your Ecosystem

It’s a medium-term migration strategy.

Reuse

Page 66: Integrating Node.js Into Your Ecosystem

You can stay focused on your goal.

Reuse

Page 67: Integrating Node.js Into Your Ecosystem

> reverse proxy / configurable routing > service discovery> service client(s) > configuration > metrics > build + deployment

Page 68: Integrating Node.js Into Your Ecosystem

But it’s not JavaScript. :(

Page 69: Integrating Node.js Into Your Ecosystem
Page 70: Integrating Node.js Into Your Ecosystem

5Add a sidecar to

reuse existing code.

Page 71: Integrating Node.js Into Your Ecosystem

sidecarA process which runs on instance along with your application, hosting all the things necessary for it to integrate seamlessly within an existing ecosystem.

Page 72: Integrating Node.js Into Your Ecosystem

main process sidecar

Page 73: Integrating Node.js Into Your Ecosystem

J

Page 74: Integrating Node.js Into Your Ecosystem

main process sidecar

Page 75: Integrating Node.js Into Your Ecosystem

service

service

service

Page 76: Integrating Node.js Into Your Ecosystem
Page 77: Integrating Node.js Into Your Ecosystem

Don’t add new functionality in your sidecar.

sidecar top tip

Page 78: Integrating Node.js Into Your Ecosystem

> configuration > metrics collection

ReuseRebuild> dynamic configuration > configurable routing > service discovery> builds + deployment > metrics reporting

Page 79: Integrating Node.js Into Your Ecosystem

Use light weight modules.

sidecar top tip

Page 80: Integrating Node.js Into Your Ecosystem

[LIGHT] config client

[FULL] config client

Page 81: Integrating Node.js Into Your Ecosystem

http://127.0.0.1/config?id=configA&id=configB&id=configC

[LIGHT] config client

[FULL] config client

Page 82: Integrating Node.js Into Your Ecosystem

http://127.0.0.1/config?id=configA&id=configB&id=configC

[LIGHT] config client

[FULL] config client config

service

Page 83: Integrating Node.js Into Your Ecosystem

[LIGHT] config client

[FULL] config client

> serialization > deserialization > caching + TTL > retries > env logic

> REST calls

config service

Page 84: Integrating Node.js Into Your Ecosystem

The sidecar is a black box.

sidecar top tip

Page 85: Integrating Node.js Into Your Ecosystem

[LIGHT] config client

[FULL] config client

> serialization > deserialization > caching + TTL > retries > env logic

> REST calls

config service

Page 86: Integrating Node.js Into Your Ecosystem

[LIGHT] config client

> REST calls

config service

Page 87: Integrating Node.js Into Your Ecosystem

[LIGHT] config client

> REST calls

config service

Page 88: Integrating Node.js Into Your Ecosystem

config service

[FULL] config client

> serialization > deserialization > caching + TTL > retries > env logic

Page 89: Integrating Node.js Into Your Ecosystem

metrics [collection]

metrics [reporting]

Page 90: Integrating Node.js Into Your Ecosystem

Watch your resource

management.sidecar top tip

Page 91: Integrating Node.js Into Your Ecosystem

inbound outbound

Page 92: Integrating Node.js Into Your Ecosystem

inbound outbound

Page 93: Integrating Node.js Into Your Ecosystem

inbound outbound

Page 94: Integrating Node.js Into Your Ecosystem

inbound outbound

Page 95: Integrating Node.js Into Your Ecosystem

Real time metrics are a must.

sidecar top tip

Page 96: Integrating Node.js Into Your Ecosystem

Sidecar

Pranahttps://github.com/Netflix/Prana

Page 97: Integrating Node.js Into Your Ecosystem
Page 98: Integrating Node.js Into Your Ecosystem

6node.js it up!

Page 99: Integrating Node.js Into Your Ecosystem

Don’t worry, I got it.

Page 100: Integrating Node.js Into Your Ecosystem

thank youAlex Liu @stinkydofu [email protected]