Transcript
Page 1: API World 2013 - Transforming the Netflix API

Transforming the Netflix API

Ben Schmaus, NetflixOctober 2013, API World

[email protected] || @schmaus

Page 2: API World 2013 - Transforming the Netflix API

Streaming TV Shows & Movies Globally

Page 3: API World 2013 - Transforming the Netflix API

> 1000 Devices

Page 4: API World 2013 - Transforming the Netflix API

1/3 ofInternet at peak

Page 5: API World 2013 - Transforming the Netflix API

ExclusiveContent

Page 6: API World 2013 - Transforming the Netflix API

Almost 38 million subscribers in over

40 countries

Page 7: API World 2013 - Transforming the Netflix API

PersonalizationEngine User Info Movie

Metadata Ratings SimilarMovies

InstantQueue

A/B TestEngine

API

Page 8: API World 2013 - Transforming the Netflix API

PersonalizationEngine User Info Movie

Metadata Ratings SimilarMovies

InstantQueue

A/B TestEngine

APIEnable UX Innovation

Insulate from Failure

Page 9: API World 2013 - Transforming the Netflix API

It wasn’t always this way

Page 10: API World 2013 - Transforming the Netflix API

FosterInnovation

fromOutside

Page 11: API World 2013 - Transforming the Netflix API

REST for Easy Interop, Integration

RESTful API

Page 12: API World 2013 - Transforming the Netflix API

REST for Easy Interop, Integration

RESTful API

Model resources like users, movies, series, ratings, etc

Page 13: API World 2013 - Transforming the Netflix API

REST for Easy Interop, Integration

RESTful API

/catalog/titles/catalog/titles/movies/catalog/titles/series

/catalog/titles/series/episodes

Page 14: API World 2013 - Transforming the Netflix API

REST for Easy Interop, Integration

RESTful API

/users/lists/users/title_states

/users/ratings

Page 15: API World 2013 - Transforming the Netflix API

EnterStreaming

Devices

Page 16: API World 2013 - Transforming the Netflix API
Page 17: API World 2013 - Transforming the Netflix API

Lots of devices, lots of variety across platforms

Page 18: API World 2013 - Transforming the Netflix API
Page 19: API World 2013 - Transforming the Netflix API

External apps

Page 20: API World 2013 - Transforming the Netflix API

1 /apps/{app_id}/config1 /users/{user_id}1 /users/{user_id}/queues/instant/available1 /users/{user_id}/lists26 /catalog/titles?...

Page 21: API World 2013 - Transforming the Netflix API

Doesn’t include JS, CSS, images, etc.

1 /apps/{app_id}/config1 /users/{user_id}1 /users/{user_id}/queues/instant/available1 /users/{user_id}/lists26 /catalog/titles?...

Page 22: API World 2013 - Transforming the Netflix API

Device variance: interaction models

Page 23: API World 2013 - Transforming the Netflix API

Device variance: interaction models & form factors

Page 24: API World 2013 - Transforming the Netflix API

A/B Tests Add to the Challenge

Page 25: API World 2013 - Transforming the Netflix API

“Bolt on” functionality

expand=@queue_item@title,@box_art_exists,@short_synopsis,@directors,@cast,@episodes,@formats,@format_availability,@subtitle_languages,@languages_and_audio,@maturity_ratings

Page 26: API World 2013 - Transforming the Netflix API

Resource-based API wasn’t scaling

Page 27: API World 2013 - Transforming the Netflix API

Model Resources/catalog, /users

Model Experiences/tv/home

Page 28: API World 2013 - Transforming the Netflix API

Reduce network chattiness

Support device optimizations

Enable fast dev iterations

Page 29: API World 2013 - Transforming the Netflix API

GET/users/{user_id}/lists

apiGateway.getLists(userId)

Page 30: API World 2013 - Transforming the Netflix API
Page 31: API World 2013 - Transforming the Netflix API

Discrete HTTP requests pay WAN tax repeatedly

Page 32: API World 2013 - Transforming the Netflix API
Page 33: API World 2013 - Transforming the Netflix API

Single, optimized request; pay WAN tax once

Page 34: API World 2013 - Transforming the Netflix API

Single, optimized request; pay WAN tax once

Client data assembly logic pushed to server

Page 35: API World 2013 - Transforming the Netflix API

Add server-side scripting capability

Enable independent dev and device optimization

Page 36: API World 2013 - Transforming the Netflix API
Page 37: API World 2013 - Transforming the Netflix API

API

Internet /tv/home

Page 38: API World 2013 - Transforming the Netflix API

API

/tv/home

Client Server

Internet

Page 39: API World 2013 - Transforming the Netflix API

API

Application

Client Server

Internet /tv/home

Page 40: API World 2013 - Transforming the Netflix API

API

Client Server

Internet

UI Teams

Application

/tv/home

Page 41: API World 2013 - Transforming the Netflix API

API

API Team

Client Server

Internet

UI Teams

Application

/tv/home

Page 42: API World 2013 - Transforming the Netflix API

APIUI

Teams

API Team

Mid-tierServices

Client Server

Internet

Application

/tv/home

Page 43: API World 2013 - Transforming the Netflix API

RxJava Hystrix

API Team

Java Service Layer

Mid-tierServices

UI Teams

Client Server

Internet

Application

/tv/home

Page 44: API World 2013 - Transforming the Netflix API

ELB ZuulMid-tier Services

ScriptableBackend

ScriptableBackend

+

API Layer

Page 45: API World 2013 - Transforming the Netflix API

https://github.com/Netflix/Hystrixresilience patterns for distributed systems

https://github.com/Netflix/RxJavaasync, event-based programming

https://github.com/Netflix/zuuldynamic request routing, realtime monitoring, resiliency

Page 46: API World 2013 - Transforming the Netflix API

Need well-appointed toolkit

Page 47: API World 2013 - Transforming the Netflix API

Cassandra

upload script.groovyfor /script

Page 48: API World 2013 - Transforming the Netflix API

Cassandra

Cassandra

activate /script

upload script.groovyfor /script

Page 49: API World 2013 - Transforming the Netflix API

Cassandra

Cassandra

activate /script

CassandraScriptableBackend

load /script

upload script.groovyfor /script

Page 50: API World 2013 - Transforming the Netflix API

Cassandra

Cassandra

activate /script

CassandraScriptableBackend

load /script

upload script.groovyfor /script

ScriptableBackend

DeviceClient

GET/script

Page 51: API World 2013 - Transforming the Netflix API
Page 52: API World 2013 - Transforming the Netflix API
Page 53: API World 2013 - Transforming the Netflix API

Deployment & Ops

Page 54: API World 2013 - Transforming the Netflix API

Historical & realtime metrics, sort realtime by error/request rate

Page 55: API World 2013 - Transforming the Netflix API

Distributed grep + tail

2013-05-09.20:38:54 MX 200 us-east-1c i-1824cb73 i-1c61b77f prod NFPS3-001-8G50FJCX... 288404769389848058 90ms api-global.netflix.com GET /tvui/release/470/plus/pathEvaluator -amazon.ami-id: ami-502eb039amazon.availability-zone: us-east-1camazon.instance-id: i-1824cb73amazon.instance-type: m2.2xlargeamazon.local-ipv4: 10.6.213.112amazon.public-hostname: ec2-54-243-4-69.compute-1.amazonaws.comamazon.public-ipv4: 54.243.4.69cookie_esn: NFPS3-001-8G50FJCX...country: MXcurrentTime: 1368131934468duration-millis: 90esn: NFPS3-001-8G50FJCX...geo.city: CIUDADOBREGON...

$ ./simple_stream.py -f -q 'e["country"]=="MX" && e["esn"]==~/NFPS3.*/' -r us

Page 56: API World 2013 - Transforming the Netflix API

Go for haystack handing you the needle

Page 57: API World 2013 - Transforming the Netflix API

Or at least be able to make smaller haystacks

Page 58: API World 2013 - Transforming the Netflix API
Page 59: API World 2013 - Transforming the Netflix API

Run 1% of your traffic on the new code and see how it does

Page 60: API World 2013 - Transforming the Netflix API

API ami-123 API ami-456

2xx4xx5xx

latencybusy threads

load...

Page 61: API World 2013 - Transforming the Netflix API

Confidence score for each AMI based on comparison of 1000+ metrics

Page 62: API World 2013 - Transforming the Netflix API

Scannable visualization of metric space

More important

Less important

Page 63: API World 2013 - Transforming the Netflix API

Your basic red/black push

Page 64: API World 2013 - Transforming the Netflix API
Page 65: API World 2013 - Transforming the Netflix API
Page 66: API World 2013 - Transforming the Netflix API
Page 67: API World 2013 - Transforming the Netflix API
Page 68: API World 2013 - Transforming the Netflix API

Doing red/black by hand for multiple clusters across multiple regions is

not fun

Page 69: API World 2013 - Transforming the Netflix API

Automate multi-cluster/region pushes

Page 70: API World 2013 - Transforming the Netflix API

Automate multi-cluster/region pushes

Don't forget to automate

rollbacks, too!

Page 71: API World 2013 - Transforming the Netflix API

$Who, $What, $Where, $When

e.g., "bschmaus, ami-123, Sandbox Canary, 2013-05-06 19:05"

Latest prod change in chat topic

Page 72: API World 2013 - Transforming the Netflix API

Quickly see status of all clusters in a region

Page 73: API World 2013 - Transforming the Netflix API

API for APIs

Control network interactions

Device optimization

Development agility

Automation & insights

Page 74: API World 2013 - Transforming the Netflix API

Continuously experiment to make hard things easier

Page 75: API World 2013 - Transforming the Netflix API

[email protected]@schmaus

GreatEngineersWanted!

jobs.netflix.com


Top Related