Netflix API - Separation of Concerns

40
SEPARATION OF CONCERNS Daniel Jacobson @daniel_jacobson http://www.linkedin.com/in/ danieljacobson http://www.slideshare.net/ danieljacobson

description

Most API providers focus on solving all three of the key challenges for APIs: data gathering, data formatting and data delivery. All three of these functions are critical for the success of an API, however, not all should be solved by the API provider. Rather, the API consumers have a strong, vested interest in the formatting and delivery. As a result, API design should be addressed based on the true separation of concerns between the needs of the API provider and the various API consumers. This presentation goes into the separation of concerns. It also goes into depth in how Netflix has solved for this problem through a very different approach to API design. This presentation was given at the following API Meetup in SF: http://www.meetup.com/API-Meetup/events/171255242/

Transcript of Netflix API - Separation of Concerns

Page 1: Netflix API - Separation of Concerns

SEPARATIONOFCONCERNS

Daniel Jacobson@daniel_jacobson

http://www.linkedin.com/in/danieljacobsonhttp://www.slideshare.net/danieljacobson

Page 2: Netflix API - Separation of Concerns

APIs DoLots of Things!

Page 3: Netflix API - Separation of Concerns

Data Gathering

Data Formatting

Data Delivery

Security

Authorization

Authentication

System Scaling

Discoverability

Data Consistency

Translations

Throttling

Orchestration

APIs DoLots of Things!

These are some of themany things APIs do.

Page 4: Netflix API - Separation of Concerns

Data Gathering

Data Formatting

Data Delivery

Security

Authorization

Authentication

System Scaling

Discoverability

Data Consistency

Translations

Throttling

Orchestration

APIs DoLots of Things!

These three are at the core.All others ultimately

support them.

Page 5: Netflix API - Separation of Concerns

Definitions

• Data Gathering– Retrieving the requested data from one or many local

or remote data sources

• Data Formatting– Preparing a structured payload to the requesting agent

• Data Delivery– Delivering the structured payload to the requesting

agent

Page 6: Netflix API - Separation of Concerns

Meanwhile…

There are two players in APIs

Page 7: Netflix API - Separation of Concerns

API Provider

Page 8: Netflix API - Separation of Concerns

API Provider API Consumer

Page 9: Netflix API - Separation of Concerns

API Provider

PROVIDES

API Consumer

CONSUMES

Traditional API Interactions

Page 10: Netflix API - Separation of Concerns

API Provider

PROVIDES EVERYTHING

API Consumer

CONSUMES

Everything means, API Provider does:• Data Gathering• Data Formatting• Data Delivery• (among other things)

Traditional API Interactions

Page 11: Netflix API - Separation of Concerns

Why do most API providers provide everything?

• API design tends to be easier for teams closer to the source

• Centralized API functions makes them easier to support

• Many APIs have a large set of unknown and external developers

Page 12: Netflix API - Separation of Concerns

Why do most API providers provide everything?

• API design tends to be easier for teams closer to the source

• Centralized API functions makes them easier to support

• Many APIs have a large set of unknown and external developers

At Netflix, we see it a different way…

Page 13: Netflix API - Separation of Concerns

Data Gathering Data Formatting Data Delivery

API Consumer

API Provider

Separation of Concerns

To be a better provider, the API should address the separation of concerns of the three core functions

Page 14: Netflix API - Separation of Concerns

Data Gathering Data Formatting Data Delivery

API ConsumerDon’t care how data is gathered, as long

as it is gathered

API ProviderCare a lot about how the data is

gathered

Separation of Concerns

Page 15: Netflix API - Separation of Concerns

Data Gathering Data Formatting Data Delivery

API ConsumerDon’t care how data is gathered, as long

as it is gathered

Each consumer cares a lot about the format for that specific use

API ProviderCare a lot about how the data is

gathered

Only cares about the format to the extent it

is easy to support

Separation of Concerns

Page 16: Netflix API - Separation of Concerns

Data Gathering Data Formatting Data Delivery

API ConsumerDon’t care how data is gathered, as long

as it is gathered

Each consumer cares a lot about the format for that specific use

Each consumer cares a lot about how payload

is delivered

API ProviderCare a lot about how the data is

gathered

Only cares about the format to the extent it

is easy to support

Only cares about delivery method to the

extent it is easy to support

Separation of Concerns

Page 17: Netflix API - Separation of Concerns

Because of our separation of concerns, the Netflix API team is

enabled to focus on different charters

Page 18: Netflix API - Separation of Concerns

Key Responsibilities

• Broker data between services and UIs

• Maintain a resilient front-door

• Scale the system vertically and horizontally

• Maintain high velocity

• Provide detailed insights into the system health

Page 19: Netflix API - Separation of Concerns

Brokering Data to 1,000+ Device Types

Page 20: Netflix API - Separation of Concerns

Most API Providers

Page 21: Netflix API - Separation of Concerns
Page 22: Netflix API - Separation of Concerns

Screen Real Estate

Page 23: Netflix API - Separation of Concerns

Controller

Page 24: Netflix API - Separation of Concerns

Technical Capabilities

Page 25: Netflix API - Separation of Concerns

One-Size-Fits-AllAPI

Request

RequestRequest

Request

Request

Request

RequestRequest

Request

Request

RequestRequest

Request

Request

Request

Request

Page 26: Netflix API - Separation of Concerns

Courtesy of South Florida Classical Review

Page 27: Netflix API - Separation of Concerns
Page 28: Netflix API - Separation of Concerns

Resource-Based API

vs.

Experience-Based API

Page 29: Netflix API - Separation of Concerns

Resource-Based Requests

• /users/<id>/ratings/title• /users/<id>/queues• /users/<id>/queues/instant• /users/<id>/recommendations• /catalog/titles/movie• /catalog/titles/series• /catalog/people

Page 30: Netflix API - Separation of Concerns

REST API

RECOMMENDATIONS

MOVIE DATA

SIMILAR MOVIES

AUTH MEMBERDATA

A/B TESTS

START-UP

RATINGS

Network Border Network Border

Page 31: Netflix API - Separation of Concerns

RECOMMENDATIONS

MOVIE DATA

SIMILAR MOVIES

AUTH MEMBERDATA

A/B TESTS

START-UP

RATINGS

OSFA API

Network Border Network Border

SERVER CODE

CLIENT CODE

Page 32: Netflix API - Separation of Concerns

RECOMMENDATIONS

MOVIE DATA

SIMILAR MOVIES

AUTH MEMBERDATA

A/B TESTS

START-UP

RATINGS

OSFA API

Network Border Network Border

DATA GATHERING,FORMATTING,AND DELIVERY

USER INTERFACERENDERING

Page 33: Netflix API - Separation of Concerns
Page 34: Netflix API - Separation of Concerns
Page 35: Netflix API - Separation of Concerns

Experience-Based Requests

• /ps3/homescreen

Page 36: Netflix API - Separation of Concerns

JAVA API

Network Border Network Border

RECOMMENDATIONS

MOVIE DATA

SIMILAR MOVIES

AUTH MEMBERDATA

A/B TESTS

START-UP

RATINGS

Groovy Layer

Page 37: Netflix API - Separation of Concerns

RECOMMENDATIONSA

ZXSXX C CCC

MOVIE DATA

SIMILAR MOVIES

AUTH MEMBERDATA

A/B TESTS

START-UP

RATINGS

JAVA API

SERVER CODE

CLIENT CODE

CLIENT ADAPTER CODE(WRITTEN BY CLIENT TEAMS, DYNAMICALLY UPLOADED TO SERVER)

Network Border Network Border

Page 38: Netflix API - Separation of Concerns

RECOMMENDATIONSA

ZXSXX C CCC

MOVIE DATA

SIMILAR MOVIES

AUTH MEMBERDATA

A/B TESTS

START-UP

RATINGS

JAVA API

DATA GATHERING

DATA FORMATTINGAND DELIVERY

USER INTERFACERENDERING

Network Border Network Border

Page 39: Netflix API - Separation of Concerns
Page 40: Netflix API - Separation of Concerns

SEPARATIONOFCONCERNS

Daniel Jacobson@daniel_jacobson

http://www.linkedin.com/in/danieljacobsonhttp://www.slideshare.net/danieljacobson

Want to help us solve some of our concerns?

http://www.netflix.com/jobs