Where Netflix Started: The BFF Era

The Netflix Architecture guide ends its discussion of duplicate fetches with one line: give something the whole query plan, a federated GraphQL gateway, and it will fetch member 42 once. This guide picks up that line and tests it. It covers what Netflix's API layer looked like before GraphQL, what a federation query planner actually merges (with real plans printed from the planner), what Netflix actually did and why, a worked phase-by-phase migration of the TV home page off its BFF, and where each of the BFF's jobs has to go when the BFF is gone. It deliberately leaves out GraphQL basics you can get from the spec, and client-side caching (Relay/Apollo Client normalised caches).

Four Generations of the Edge

Every row below is sourced. The column that matters is the third one: who writes the code that knows what a TV home page looks like, and in which process it runs.

GenerationWhenWhere the device-specific code livesWhat broke
One-size-fits-all REST2008 → ~2012On the device. The API team owns generic, resource-shaped endpoints; the device calls many of them and assembles the page itself.Chattiness: every call pays WAN latency. The API team is the bottleneck for every device's needs.
API.NEXT — Groovy adapters2012 → ~2017On the server, inside the API's JVM. Each UI team uploads adapter scripts ("dynamic endpoints"); the API team owns the Java service layer beneath them.Thousands of scripts in one shared runtime: one script's leak takes down everyone; no local testing.
Node.js BFFs2016 → still migrating in 2021In its own container per app, still written by the UI team. It talks over the network to the Java API, now called the Remote Service Layer, using Falcor.Aggregation logic duplicated across device apps; the Falcor API behind them grows into "a logic-heavy monolith with over a decade of tech debt".
Federated GraphQLStudio 2019 →; mobile apps 2020–2022In the client's query (payload shape) and in domain-owned subgraphs (data). Whether any per-device server code survives is the question of the Where the BFF's jobs go part.The rest of this guide.

API.NEXT: Client Code That Runs on the Server

Jacobson's 2012 post gives the reason for the redesign in one number: the streaming service ran on more than 800 device types, and a one-size-fits-all API "is to make it convenient for the API provider, not the API consumer." Devices differ in memory, screen space, and whether they want a flat or a nested document. His answer had four parts. The most important one is "Redefine the Border Between 'Client' and 'Server'": the device makes one call to "a dedicated client adapter that resides on the server behind the custom endpoint", and that adapter is written by the device's UI team. The post walks through the PS3 home screen, labelling each step with the team that owns it:

  1. PS3 UI team: the device makes one request. A Groovy adapter parses it and "explodes that one request into many requests that call the Java API".
  2. API team: each Java API method calls its backend service, concurrently when it can. If a service is down or returns 4xx/5xx, the Java API "returns a fallback and/or an error code to the adapter".
  3. PS3 UI team again: the adapter takes the results and prunes out the fields it doesn't want. It handles errors and formats "everything needed for the PS3 home screen in the single payload".

That sequence is the whole BFF pattern, three years before the term caught on. It splits the work into content gathering (the API team's generic Java service layer) and content formatting and delivery (each device team's adapter). Christensen's January 2013 follow-up gives the mechanics:

Dynamic endpointsDefined at runtime. Each client team develops, tests, canaries and deploys its own, with no coordination with the API team, unless the endpoint needs new service-layer functionality.
StorageEndpoint code is published through an Endpoint Management API into a globally replicated Cassandra cluster, and loaded into the running servers from there.
LanguageAny JVM language in principle. Groovy was the first because of closures, list and map literals, performance and debuggability.
ConcurrencyA fully asynchronous Java API, composed with a reactive model based on Rx Observables (this became RxJava). Every backend call goes through Hystrix.
Scale"A Java application running on hundreds of servers processing 2+ billion incoming requests a day."
API.NEXT: one JVM, two owners, one process boundary
API.NEXT: one JVM, two owners, one process boundary

Look at what sits in one process here. The TV adapter asks for member 42 on five branches: entitlements, maturity level, language, avatar and plan. All five calls go to the same service layer, inside one request, inside one JVM. That is exactly the situation the Netflix Architecture guide's Hystrix request cache was built for: one HystrixRequestContext around the HTTP request, so five getProfile(42) calls become one network call. In the Groovy era, the edge could dedupe the edge's own duplicates. That matters when you test the "only a gateway can dedupe" claim in the query planner part.

Why the Scripts Left the JVM

Jacobson's 2012 post already named the risk: UI teams writing server code "have the potential to bring down the servers through infinite loops or other processes that are resource intensive." By 2016 it had arrived. Yunong Xiao's Node.js Interactive talk described "literally thousands of scripts sharing the same space". Running out of memory, CPU or I/O headroom was common, and "if a script had a memory leak … it could bring down the system for everyone." The developer loop was bad too: scripts couldn't be run locally, so every test meant uploading to a test environment. Xiao put the loop at "tens of minutes".

Probst's QCon 2016 interview stated the plan in one paragraph. It is the most compact primary source for the BFF split:

"The Node scripts will run in their own containers. They will be scaled separately and have process isolation so they will no longer put each other or API at any operational risk. They will talk to our API via something that is called Falcor." — Katharina Probst, QCon New York 2016

The new shape had some notable details. The Java side was renamed the Remote Service Layer. Each device's data-access scripts became individual Node.js apps in Docker containers. Routing to them used semver: a client asks for a major or minor version, and the router picks the newest matching app, the same way npm resolves packages. Xiao explained why: app-store clients live "for a very long time and don't ever really get updated", so the server has to keep old versions resolvable. Kim Trott named the cost at the time: "we're introducing another hop". The adapter-to-service-layer call used to be a function call. Now it was a network call. Netflix looked at ReactiveSocket channels to make the chatty BFF-to-API traffic cheaper.

Node BFF era: the ownership line became a network hop
Node BFF era: the ownership line became a network hop

Falcor: Netflix's First Query Language

Falcor was Netflix's first attempt at letting the client say what it needs as data rather than as code. It was open-sourced as a developer preview in August 2015, about six weeks after Facebook published the GraphQL spec draft. Its model is JSON Graph: all the app's data is treated as one virtual JSON object. Each entity lives at exactly one identity path, such as videosById[80057281]. Anywhere else it appears, it appears as a reference, { $type: "ref", value: ["videosById", 80057281] }, which works like a Unix symlink. The client asks for paths, not endpoints:

A Falcor request for two rows of a home page (path syntax per the Falcor docs; key names illustrative)

model.get(
  "lolomo[0..1][0..9]['title','boxart']",   // rows 0-1, titles 0-9, two fields
  "member['maturityLevel','language']"
)
// Router on the server matches route patterns such as
//   "videosById[{integers:ids}]['title','boxart']"
// and returns a JSON Graph fragment; refs are followed on the client.

Three Falcor properties matter for the rest of this guide:

PropertyWhat Falcor didIts GraphQL counterpart
Dedupe in the payloadEach entity is sent once and referenced everywhere else, so there are no stale duplicate copies in the client cache.Client-side cache normalization by type + id (Apollo Client, Relay). The server response itself does repeat the object.
Dedupe and batch in the requestThe Falcor Model batches many small gets into one request and "dedupes requests": if a path is already in flight, no second request is made.DataLoader, but on the server (see What GraphQL changes).
ContractNone beyond the path strings. The router matches patterns at runtime. There is no schema, no types, no introspection, and no build-time check that a path exists.The schema (see What GraphQL changes). This is the gap Netflix itself pointed to.

What BFFs Bought, and What They Cost

Bought

Device-shaped payloads. A TV home page and a phone home page differ in rows, titles per row, artwork sizes and document shape. One adapter per device gets each exactly right. Autonomy. "API innovation is now in the hands of the UI teams!" (Jacobson). A device team ships its endpoint without waiting on the API team. Isolation (Node era only): one team's leak kills only that team's containers.

Cost

Orchestration written N times. Every device app has its own code that fetches rows, then videos, then artwork and bookmarks, with its own bugs and its own fallbacks. A monolith in the middle. Behind every BFF sits one API owned and operated by one team. Probst and Becker (2016): "only the API team is responsible for the full operations of the API … it goes against our principle of teams owning and operating in production what they build." Old versions pile up. App-store clients pin old BFF versions.

"Member 42 fetched five times" is the Netflix guide's headline cost of this era. It needs more care than it usually gets, because the duplication happens in three different places, and each one has a different fix:

Where the duplicate happensExampleWho could dedupe it in the BFF era
Inside one BFF requestThe TV adapter's five branches each ask the service layer for member 42.Already solved. Groovy era: Hystrix request cache in the shared JVM. Node era: the Falcor Model's in-flight dedupe, plus the request cache inside the RSL. Reasoned from how both mechanisms work; not measured in any Netflix post.
Across device BFFsThe TV, Android and web apps each contain their own "fetch member, then entitlements" code.Nobody. This is duplicated code, not duplicated calls. Each request still fetches member 42 only once, but the logic is maintained N times.
Below the edgePersonalization, playback-authz and artwork services each call the profile service for member 42 themselves (layer 2 of the ~700-call tree).Nobody at the edge. These calls happen inside other services' processes. Only EVCache makes them cheap (the Netflix Architecture guide's Hystrix part).

Of those three, a federated graph's main target is the second row. It shifts assembly from per-device code to a shared schema. It does not remove the third row. Calls that personalization or artwork make to the profile service happen inside their own resolvers, where the query planner can't see them. The planner works from the query's shape and never sees values such as "member 42", so in Netflix's own A–E scenario member 42 is still fetched five times after federation. The query planner part shows this with printed query plans.

Netflix's Own Diagnosis

Two Netflix sources explain why the next step was GraphQL, not a fifth kind of adapter. In January 2021 Kavitha Srinivasan described the streaming side as still finishing its Node BFF migration, "all this still with Falcor". Meanwhile Studio was on federated GraphQL with "a lot of community support". She then made the organizing claim of this guide: "GraphQL is supposed to do that very thing. It's supposed to do the job of the BFF." On the Falcor side she said "we don't have community support", while GraphQL "lends itself to better self documentation" with "much better tooling". Bruce Wang's Apollo webinar (as Apollo wrote it up) frames the consumer decision as a choice between building "on top of our existing system — Falcor" and adopting what Studio Edge had pioneered.

The staff-level reading: Falcor already gave clients declarative, deduped, batched data fetching. What it lacked was a typed contract that many teams could own pieces of. That missing piece is where The What GraphQL changes part starts.

The Invariants

  • Guarantees: In every generation, the device-specific decisions (which rows, how many titles, which artwork sizes, which fields to prune) were made by the device's team. Each generation only changed where that code ran: device, shared JVM, own container. In the Groovy and Node eras, one home-page request had one place where its own duplicate lookups could be memoized.
  • Does not guarantee: That per-device BFFs duplicated backend calls within a request (mostly they duplicated code). That Falcor had a schema. That the ~700-call tree below the edge was visible to, or dedupable by, any edge tier. That "BFF" at Netflix ever meant one service per device: it was first scripts in one JVM, then many semver-routed Node apps.