netflix api - separation of concerns
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
SEPARATIONOFCONCERNS
Daniel Jacobson@daniel_jacobson
http://www.linkedin.com/in/danieljacobsonhttp://www.slideshare.net/danieljacobson
APIs DoLots of Things!
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.
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.
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
Meanwhile…
There are two players in APIs
API Provider
API Provider API Consumer
API Provider
PROVIDES
API Consumer
CONSUMES
Traditional API Interactions
API Provider
PROVIDES EVERYTHING
API Consumer
CONSUMES
Everything means, API Provider does:• Data Gathering• Data Formatting• Data Delivery• (among other things)
Traditional API Interactions
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
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…
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
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
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
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
Because of our separation of concerns, the Netflix API team is
enabled to focus on different charters
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
Brokering Data to 1,000+ Device Types
Most API Providers
Screen Real Estate
Controller
Technical Capabilities
One-Size-Fits-AllAPI
Request
RequestRequest
Request
Request
Request
RequestRequest
Request
Request
RequestRequest
Request
Request
Request
Request
Courtesy of South Florida Classical Review
Resource-Based API
vs.
Experience-Based API
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
REST API
RECOMMENDATIONS
MOVIE DATA
SIMILAR MOVIES
AUTH MEMBERDATA
A/B TESTS
START-UP
RATINGS
Network Border Network Border
RECOMMENDATIONS
MOVIE DATA
SIMILAR MOVIES
AUTH MEMBERDATA
A/B TESTS
START-UP
RATINGS
OSFA API
Network Border Network Border
SERVER CODE
CLIENT CODE
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
Experience-Based Requests
• /ps3/homescreen
JAVA API
Network Border Network Border
RECOMMENDATIONS
MOVIE DATA
SIMILAR MOVIES
AUTH MEMBERDATA
A/B TESTS
START-UP
RATINGS
Groovy Layer
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
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
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