Backend for frontend (BFF)

Backends for mobile apps Mid-level Python 3.13+ PostgreSQL 17+ Reviewed By Best Latest Apps

Pick the fix

The home screen makes 6 sequential API calls on 3G and takes 4 s. Best backend change?

Options
Hint 1 of 1

What costs most on a slow network?

Choose an answer, then open Show answer below to check it.

Show answer

Answer: A A BFF endpoint that fetches the 6 sources in parallel and returns one screen payload

Correct. One round trip from the phone.

On mobile networks every round trip costs hundreds of milliseconds. A BFF makes the six calls from the data centre in parallel, where latency is low, and returns one payload made for the screen.

Why not the others?
  • B Make each of the 6 endpoints return more data. Still 6 round trips.
  • C Add a CDN for the JSON. Personalised data rarely caches.
  • D Ask users to use Wi-Fi. Not a fix.

30-second answer

A backend-for-frontend is an API shaped for one client. It aggregates several internal services into one call per screen, trims payloads to what the app shows, and handles mobile concerns like versioning for old app releases and image sizes. That cuts round trips on slow networks and lets the mobile team change their API without negotiating with every service. The cost is another service to run; GraphQL is an alternative way to let clients shape responses.

Practise saying it · 30 s. No recording, just a timer

Explain BFF.

Say your answer out loud, then check which of these points you covered:

  • Client-shaped API
  • Aggregate in parallel
  • Trim payloads
  • Version for old apps
  • Rules stay in services

Deep dive

One BFF per client type (iOS and Android often share one).

Keep business rules in the core services, not in the BFF.

Fan out to services in parallel with timeouts, and degrade partially.

Old app versions stay in use for months, so BFF responses must stay compatible.

Common mistakes

  • Putting business logic in the BFF.
  • A BFF that just proxies one-to-one.
  • Serial calls to five services per screen.

Senior take & follow-ups

One client-shaped API: aggregation, trimming, versioning; keep rules in core services.

Follow-up questions

Think of your answer first, then open the hint.

  1. BFF or GraphQL?

    Show hint

    Both reduce round trips; GraphQL moves shaping to the client, a BFF keeps it server-side.

  2. What if one service is slow?

    Show hint

    Return the rest with a partial section and a timeout.

Similar on iOS: URLSessionConfiguration The iOS page tunes the networking client; here the server cuts the number of round trips it has to make.

Suggest a fix if something here is wrong or out of date.