liveBook · Manning

Backend-for-frontend pattern

As explained in Fast by Default

A Backend for Frontend is an architectural pattern that provides a backend service tailored to the needs of a particular client application or interface.

A Backend for Frontend (BFF) is a lightweight backend service tailored to one client type or interface. Instead of making a mobile, web, or desktop client assemble a screen through several service calls, the BFF performs the orchestration and returns the exact combined response that client needs. section 5.3.4

The pattern targets round-trip latency. Five sequential calls from a mobile device over a cellular network accumulate delay at every hop; the BFF can make equivalent service calls within the data center and send one response back to the client. Separate BFFs also let client teams evolve their APIs without forcing one shared public API to compromise between conflicting web, mobile, and partner needs. section 5.3.4

Keep a BFF thin and focused on client-facing orchestration:

  • Aggregate data from existing services and return a combined, client-specific payload. section 5.3.4
  • Fetch independent service calls in parallel as the layer takes over orchestration. section 5.5.1
  • Handle gateway concerns such as rate limiting, authentication, and cache control where appropriate. section 5.3.4
  • Introduce the layer without changing the APIs it aggregates when an independent improvement is possible. section 5.5

Migrating away from sequential client calls

A strangler fig migration can begin with a BFF that only proxies requests to existing services. It can then aggregate calls, fetch multiple services in parallel, and return one response while the frontend switches to the BFF. Old APIs remain available until the new path has taken over gradually. section 5.5.1

Use performance targets to decide whether the added layer is worthwhile. For example, reducing page load time from four seconds to under two may justify aggregating API calls. During longer migrations, account for the cost of running old and new systems together, including synchronization, routing, and maintaining expertise in both. section 5.5.2

Figure 5.8 Architectural improvement decision tree. If you can improve one piece without touching others, prefer incremental changes like caching or query optimization, which are lower risk and deliver quick wins. If every change forces coordinated modifications across the system, larger architectural changes become necessary despite longer timelines and coexistence costs.

Use the decision tree to distinguish a low-risk independent improvement from a structural change that requires coordinated architectural work. A BFF is a candidate when reducing network hops cannot be solved by isolated tactical fixes. section 5.5

How Fast by Default covers it

How deep it goes
Defines client-specific BFFs and elaborates incremental proxy, aggregation, parallelization, and migration steps.
Examples
Uses SoundCloud’s separate Mobile, Web, and partner APIs and a gradual sequential-call migration scenario.
What you can do after
Apply it by introducing a thin aggregation layer that lets clients replace sequential service calls with one tailored response.
How it connects
Connects BFFs with API gateways, caching, strangler fig migration, facade patterns, and parallel requests.

Also explained in

Compare how 6 books explain backend-for-frontend pattern →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Fast by Default. The section links point to the parts of the book it draws on.