slaying monoliths with node and docker

59
November 2016 Slaying Monoliths with & Yunong Xiao Principal Engineer @yunongx http://yunong.io

Upload: yunong-xiao

Post on 16-Apr-2017

778 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Slaying Monoliths with Node and Docker

November 2016

Slaying Monoliths with &

Yunong XiaoPrincipal Engineer

@yunongxhttp://yunong.io

Page 2: Slaying Monoliths with Node and Docker
Page 3: Slaying Monoliths with Node and Docker

#netflixeverywhere

Page 4: Slaying Monoliths with Node and Docker

Subscriber Growth

20M

33M

46M

59M

72M

85M

2011 2012 2013 2014 2015 2016

Page 5: Slaying Monoliths with Node and Docker

API Evolution

Page 6: Slaying Monoliths with Node and Docker

So You Want to Watch Netflix

Page 7: Slaying Monoliths with Node and Docker

So You Want to Watch Netflix

Page 8: Slaying Monoliths with Node and Docker

Watch Anywhere

Page 9: Slaying Monoliths with Node and Docker

In The Beginning…

Page 10: Slaying Monoliths with Node and Docker

Java Web Server

❖ Java based web server

❖ Renders UI

❖ Accesses data

❖ Individual clients for each service

❖ Different behavior for each client

Java Web server

Route A

Route B

Route C

Route D

Route N

Client Library A

Client Library B

Client Library C

Client Library N

Backend Service A

Backend Service B

Backend Service C

Backend Service N

Page 11: Slaying Monoliths with Node and Docker

Spot the Monolith

Java Web server

Route A

Route B

Route C

Route D

Route N

Client Library A

Client Library B

Client Library C

Client Library N

Backend Service A

Backend Service B

Backend Service C

Backend Service N

MONO

LITH

Page 12: Slaying Monoliths with Node and Docker

New Devices

Page 13: Slaying Monoliths with Node and Docker

API Evolution

Page 14: Slaying Monoliths with Node and Docker

Java Web Server

Java Web server

Route A

Route B

Route C

Route D

Route N

Client Library A

Client Library B

Client Library C

Client Library N

Backend Service A

Backend Service B

Backend Service C

Backend Service N

MONO

LITH

Page 15: Slaying Monoliths with Node and Docker

REST API

REST API

Backend Service A

Backend Service B

Backend Service C

Backend Service N

Page 16: Slaying Monoliths with Node and Docker

REST API

❖ Inflexible: waiting for weeks between API changes.

❖ Inefficient: multiple round trips

❖ Complex API: hard to maintain

Page 17: Slaying Monoliths with Node and Docker

API Evolution

Page 18: Slaying Monoliths with Node and Docker

Design for Innovation

❖ Rapid innovation

❖ More AB tests and devices

❖ Customized API

❖ Performance matters

Page 19: Slaying Monoliths with Node and Docker

REST API

REST API

Backend Service A

Backend Service B

Backend Service C

Backend Service N

Page 20: Slaying Monoliths with Node and Docker

API.NEXT

API Server

Script A

Script B

Script C

Script D

Script N

Client Library A

Client Library B

Client Library C

Client Library N

Backend Service A

Backend Service B

Backend Service C

Backend Service N

MONO

LITH

Page 21: Slaying Monoliths with Node and Docker

Scale

❖ 42.5 billion hours watched in 2015

❖ “Massive” RPS: Billions/day

❖ 1000s of scripts active in prod, 10000s in test

❖ 100s of changes/day

❖ 100s of AB tests with many variants/test

Page 22: Slaying Monoliths with Node and Docker

All Scripts Live in One Process

❖ Vertical Scale: Running out of headroom

❖ Memory

❖ I/O

❖ Instance cost: Largest instances $ can buy

Page 23: Slaying Monoliths with Node and Docker

HappySad Together?

❖ Resource contention

❖ 1 bad script takes out everyone

❖ Conflicting dependencies

Page 24: Slaying Monoliths with Node and Docker

API Server

Script A

Script B

Script C

Script D

Script N

Client Library A

Client Library B

Client Library C

Client Library N

Backend Service A

Backend Service B

Backend Service C

Backend Service N

Developer ErgonomicsUI Engineering Systems Engineering

Page 25: Slaying Monoliths with Node and Docker

API Evolution

Page 26: Slaying Monoliths with Node and Docker

Requirements

❖ Scalability

❖ Availability

❖ Developer productivity

Page 27: Slaying Monoliths with Node and Docker

Runtime Scalability & Availability

❖ Process isolation

❖ Separation of data access scripts and API servers

❖ Reduce infrastructure costs

❖ Horizontally scalable architecture

❖ Faster startup times

❖ Immutable deployment artifacts

Page 28: Slaying Monoliths with Node and Docker

Developer Productivity

❖ JS to rule them all

❖ Run and debug scripts locally, set breakpoints, step through code

❖ Fast, incremental builds

❖ As closely mirrors production as possible

Page 29: Slaying Monoliths with Node and Docker

API Evolution

API Server

Script A

Script B

Script C

Script D

Script N

Client Library A

Client Library B

Client Library C

Client Library N

Backend Service A

Backend Service B

Backend Service C

Backend Service N

MONO

LITH

Page 30: Slaying Monoliths with Node and Docker

API Server

Script A

Script B

Script C

Script D

Script N

Client Library A

Client Library B

Client Library C

Client Library N

Backend Service A

Backend Service B

Backend Service C

Backend Service N

Natural SeparationUI Engineering Systems Engineering

Page 31: Slaying Monoliths with Node and Docker

Next Generation Data Access API

TV

iOS

Android

Windows

Browsers

Remote Service Layer

Search

MAP

GPS

Playback

Clients Node API Edge API Backend Services

Page 32: Slaying Monoliths with Node and Docker

Node API Platform

❖ Set of JS data access scripts

❖ Running Node.js + restify

❖ Inside of a Docker

/browse/search/account/signup

Unified Remote Service Layer

/bootstrap/search/account/login

Unified Remote Service Layer

Page 33: Slaying Monoliths with Node and Docker

Evolutionary Traits

❖ Runtime platform

❖ Application management

❖ Container infrastructure

❖ Developer tools

“Production”

Page 34: Slaying Monoliths with Node and Docker

Evolutionary Traits

❖ Runtime platform

❖ Application management

❖ Container infrastructure

❖ Developer tools

“Production”

Page 35: Slaying Monoliths with Node and Docker

-Twitter

“A full-stack developer is one who can add technical debt to any layer of the

application”

Page 36: Slaying Monoliths with Node and Docker

Aim: Paved Path for Data Access Apps

❖ Metrics

❖ Alerts

❖ Autoscaling

❖ Load balancing

❖ Discovery

❖ Analytics

Page 37: Slaying Monoliths with Node and Docker

Node Runtime: Platform as a Service

❖ Production ready Node platform

❖ Just bring JS business logic

❖ Everything else is “free”

❖ No servers/infrastructure to manage

nf-iso-properties

Properties Discovery RPC

nf-eureka-client

reactive-datasource

Insight

nf-atlas-client

bunyan-suro

(data-pipeline)

bunyan (logging)

nf-salp

Web serverRuntime

reactive-socket-lb

HTTP Client

Page 38: Slaying Monoliths with Node and Docker

Evolutionary Traits

❖ Runtime platform

❖ Application management

❖ Container infrastructure

❖ Developer tools

“Production”

Page 39: Slaying Monoliths with Node and Docker

Aim: Simple App Management

❖ Versioning

❖ Deployment

❖ Operational Insights

Page 40: Slaying Monoliths with Node and Docker

Versioning: Current Problems

❖ APIs change all the time

❖ 100000s different versions

❖ 1000s live in prod

Page 41: Slaying Monoliths with Node and Docker

Versioning: Inconsistency

api.netflix.com/tvui/1469577600021

api.netflix.com/web/6dbd361

api.netflix.com/ios/1.3.2

api.netflix.com/android/1234

Build Timestamp

Git sha

App version

Integer

Page 42: Slaying Monoliths with Node and Docker

Aim: Consistent Versions & Reproducible Builds

Page 43: Slaying Monoliths with Node and Docker

Solution: Use SemVer

Page 44: Slaying Monoliths with Node and Docker

Versioning: Node API Index

Page 45: Slaying Monoliths with Node and Docker

Routing

api.netflix.com/tvui/1469577600021

api.netflix.com/web/6dbd361

api.netflix.com/ios/1.3.2

api.netflix.com/android/1234

Build Timestamp

Git sha

App version

Integer

Page 46: Slaying Monoliths with Node and Docker

Problem: API Upgrades

api.netflix.com/ios/1.3.2 1.3.2

1.3.3

Path immutably baked into client

Page 47: Slaying Monoliths with Node and Docker

Solution: SemVer Routing

api.netflix.com/ios/^1.0.0

1.3.2

1.3.3

1.4.0

1.6.5

nq.netflix.com

api.netflix.com/ios/1.3.2

^1.0.0

^1.0.0

1.3.2 1.3.2

Page 48: Slaying Monoliths with Node and Docker

Operational Insights

❖ List and view deployed apps and routes

❖ Deployment history

❖ Metrics: RPS, latency, errors, …

❖ Analytics

Page 49: Slaying Monoliths with Node and Docker

Generated Dashboards

Page 50: Slaying Monoliths with Node and Docker

Evolutionary Traits

❖ Runtime platform

❖ Application management

❖ Container infrastructure

❖ Developer tools

“Production”

Page 51: Slaying Monoliths with Node and Docker

Titus: Container Management & Scheduling

Fenzo

Page 52: Slaying Monoliths with Node and Docker

Evolutionary Traits

❖ Runtime platform

❖ Application management

❖ Container infrastructure

❖ Developer tools

“Production”

Page 53: Slaying Monoliths with Node and Docker

Aim: Developer Productivity

❖ Run and debug scripts locally

❖ Fast, incremental builds

❖ Local “prod” environment

Page 54: Slaying Monoliths with Node and Docker

Local Development: Builds are Slow

Build depsCommit to SCM

DocumentJS NQ Scripts

Build Docker Image

Tens of Minutes

Page 55: Slaying Monoliths with Node and Docker

Rapid Local Development: Debug in SecondsDeveloper Laptop (Mac OSX)

Virtual Box (Linux)Running Docker Host

Docker Server

ContainerRunning MyApp Image MyApp Image

MyApp scripts & config

NodeQuark Image

Prana Image

NodeJS Image

Ubuntu Image

Page 56: Slaying Monoliths with Node and Docker

Recap: Containers

❖ Process isolation❖ Layered dependency management❖ Portability across environments:

prod->test❖ Fast deployment❖ Single deployment artifact: Docker

image

Page 57: Slaying Monoliths with Node and Docker

Recap: Node.js

❖ JS everywhere: client & server❖ Performant❖ Lightweight & efficient: run

locally❖ Non blocking❖ Superb ecosystem (npm)❖ Built for the web

Page 58: Slaying Monoliths with Node and Docker

Recap: Node Platform❖ Developer productivity

❖ Fast incremental builds❖ Run, debug, and test locally❖ Local prod like environment

❖ Scalability & availability❖ Monolith -> micro-services❖ Process isolation: better availability❖ Horizontally scalable architecture❖ Immutable deployment artifacts

Unified Remote Service Layer

Backend Service A

Backend Service B

Backend Service C

Backend Service N

Page 59: Slaying Monoliths with Node and Docker

Thanks!

❖ Interested? is hiring! ❖ @yunongx❖ [email protected]❖ yunong.io