Integrating Node.js Into Your Ecosystem

Preview:

Citation preview

Integrating Nodeinto your ecosystem

hello worldAlex Liu @stinkydofu aliu@netflix.com

node.js

$ 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

What is your goal?answer the simple questions first.

“ I want to use …

“ I want to use node.js

“ I don’t want to rebuild my entire app

“ I want to move incrementally

“ I am going off the paved road

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

1Identify your ecosystem.

What does your ecosystem look like?

your answer can make a difference!

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.

data access logic

business logic

UI

database

data access logic

business logic

UI

data access logic

business logic

UI

SOA (service oriented architecture)

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

UI

service

business logic

serviceservice

business logicbusiness logic

REST all the things!

service

service

service

service

service

service

service

service

service

service

service

service

2Use configurable

routing

reverse proxy

/home

/test

service

service

service

Use a reverse proxy as a configurable

routing layer.top tip

/home

/profile

Control

Test

90%

10%

US

EU

ON

OFF

Avoid subdomains.

top tip

3Identify necessary

ecosystem services.

service discoverydiscover, and be discovered

service discovery> registration > health check> client discovery

configurationconfiguration management on

a per environment basis

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

observability is of the utmost importance

metrics

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

metrics

determine your minimum units of deployment

build + deploy

> VMs > AMIs> CI + CD> Docker

build + deploy

What are our options?

4Rebuild or reuse?

Measure success by the cost of maintenance.

top tip

Rebuild

It’s an opportunity for a fresh start.

Rebuild

Lightweight modules are great for prototyping.

Rebuild

Don’t rebuild your entire ecosystem.

Rebuild

Chicken, meet Egg.

Reuse

You’re not reinventing the wheel.

Reuse

You can reduce overall platform

maintenance cost.

Reuse

It’s a medium-term migration strategy.

Reuse

You can stay focused on your goal.

Reuse

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

But it’s not JavaScript. :(

5Add a sidecar to

reuse existing code.

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

main process sidecar

J

main process sidecar

service

service

service

Don’t add new functionality in your sidecar.

sidecar top tip

> configuration > metrics collection

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

Use light weight modules.

sidecar top tip

[LIGHT] config client

[FULL] config client

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

[LIGHT] config client

[FULL] config client

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

[LIGHT] config client

[FULL] config client config

service

[LIGHT] config client

[FULL] config client

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

> REST calls

config service

The sidecar is a black box.

sidecar top tip

[LIGHT] config client

[FULL] config client

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

> REST calls

config service

[LIGHT] config client

> REST calls

config service

[LIGHT] config client

> REST calls

config service

config service

[FULL] config client

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

metrics [collection]

metrics [reporting]

Watch your resource

management.sidecar top tip

inbound outbound

inbound outbound

inbound outbound

inbound outbound

Real time metrics are a must.

sidecar top tip

Sidecar

Pranahttps://github.com/Netflix/Prana

6node.js it up!

Don’t worry, I got it.

thank youAlex Liu @stinkydofu aliu@netflix.com

Recommended