In a travel-booking mobile app, what does a backend-for-frontend composing the hotel detail screen save the device, and what does it cost?
answer
- one radio round trip, cheap inner hops
- fan-out moves into the data centre
- change composition without a release
- every live build pins a shape
- one more service to run
basics
~20 sIt turns several dependent calls into one radio round trip carrying only the screen's fields, and lets the server change composition without an app release. It costs a service to own, an extra hop, and response shapes old builds pin.
solid answer
~50 sWithout one, the hotel detail screen calls hotel, photos, reviews and room availability itself: several round trips on a roaming link, some of them dependent, plus joining and trimming logic duplicated in every client. A mobile backend-for-frontend does that fan-out inside the data centre, where a hop costs milliseconds, and returns one response sized for the screen, so the phone pays one radio round trip and parses less. It also gives the server a lever an installed app lacks: composition, field mapping and a degraded section can change without shipping a build. The costs are real: another service to build, deploy, monitor and keep on call, an extra hop on every request, and a contract coupled to app versions, because each screen-shaped response must keep working for every build still in the field. I'd add one when screens need several services, not before.
code
json · 7 lines{
"hotel": { "id": "h_48213", "name": "Harbour View", "rating": 4.4,
"photos": [ { "url": "https://img.example.com/h_48213/1_800.jpg", "width": 800 } ] },
"rooms": [ { "id": "r_1", "name": "Double room", "refundable": true,
"price": { "amount": 12950, "currency": "EUR" } } ],
"reviews": { "status": "unavailable" }
}go deeper
Recall what a backend-for-frontend is: a server layer built for one client experience that calls other services and returns one response shaped for a screen.
Explain the saving in numbers: dependent calls over a slow radio versus one round trip plus cheap data-centre hops, and fewer bytes parsed on the phone.
Bring the costs: an on-call service, an extra hop, endpoint sprawl, and response shapes pinned by years-old builds. Show the degraded-section contract and when you would not build one.
Decide ownership: who owns the composer and its contract across platforms and app generations, and how its shapes evolve without forking per build or per operating system.
## The screen without a composer The hotel detail screen of the travel app needs four things: the hotel record, its photos, a review summary and live room availability. If each comes from its own service and the app calls them directly, the device pays for it: - **Dependent waves.** Availability needs room or rate identifiers from the hotel record, so the calls form at least two waves; with the scenario's 400 ms roaming round trip, three dependent waves spend about 1.2 s waiting before any server work is counted. - **Joining on the phone.** The app merges four responses, trims what it does not draw and handles four separate failures. - **Internal shapes exposed.** Four internal services become the public contract of every installed build. ## What the backend-for-frontend saves the device A **backend-for-frontend (BFF)** is a server-side layer built for one client experience. For this screen it calls the four services from inside the data centre and returns one response: - **One radio round trip.** The phone waits about 400 ms plus the composer's own fan-out, which runs over a data-centre network where each hop typically costs a few milliseconds. - **Fewer bytes and less parsing.** The response carries only what the screen draws, in the shape it draws it. - **A lever without a release.** Field mapping, which section comes first, and what to send when one service is down can change on the server; the installed app cannot be redeployed, so this lever matters more for mobile than for a web page. - **Private internal services.** Services behind the composer can split, merge or rename without breaking builds in the field. ## What it costs | Cost | Why it is real | How teams contain it | |---|---|---| | Another service | it must be built, deployed, monitored and kept on call | keep it thin: composition and mapping only, no business rules | | An extra hop | every request now passes through one more server | run it close to the services it calls and fan out concurrently | | Coupling to app versions | each response shape becomes a contract that years-old builds read | evolve shapes additively and describe sections, not pixels | | Endpoint sprawl | one shape per screen multiplies endpoints | group by screen family, or put a query layer behind it | | Ownership friction | the mobile team needs server skills or a partner team | give the mobile team ownership of the composer's contract | The coupling cost is the one specific to installed clients. A web BFF can change its response and its page in the same deploy; a mobile BFF must keep answering the shape that a two-year-old build expects. How long that window lasts and how builds are retired is the versioning discussion's, but the composer is where that promise is kept. ## Partial failure: return a screen, not an error When the reviews service is slow, failing the whole response throws away the hotel and rooms the user came for. A composer returns what it has and marks the missing section, and the app renders a placeholder for it. The general timeout and fallback design for aggregating services belongs to the server-side patterns; from the device's seat the rule is that the response contract has an explicit way to say a section is unavailable. ## When to add one, and when not 1. **Add it** when screens need data from several services, when some calls are dependent, and when the slow-link round trips are measurable in the screen's load time. 2. **Add it** when the team wants to change composition without waiting for app releases and store review. 3. **Hold off** when each screen already maps to one small endpoint that one team owns; the composer would be a pass-through with an on-call rotation. 4. **Share it across platforms**: both native apps and a cross-platform build draw the same screens, so one mobile composer usually serves all of them; splitting by operating system duplicates logic that then drifts. ## What to say in the interview - Quantify the saving in round trips on the scenario's link. - Name the version coupling as the mobile-specific cost. - Show the degraded-section contract. - Say when you would not build one.
- Why not let the mobile app call the four services directly, in parallel over HTTP/2?Parallelism helps only independent calls; dependent ones still serialise across the radio. Direct calls also put joining and failure handling in every build, where it cannot change without a release, and turn internal services into a contract for years-old builds. A composer keeps the radio cost to one round trip and the services private.
- How does a mobile backend-for-frontend interact with app versions that stay installed for years?Each response shape becomes something a live build reads, so changes must be additive, and the composer may serve more than one shape until old builds age out. The support window itself is a versioning decision. Shapes that describe sections rather than layout details survive more builds without forking.
- Should each mobile platform get its own backend-for-frontend?Usually not. A BFF serves an experience, and both native apps and any cross-platform build draw the same screens, so one mobile composer serves them all. Splitting by operating system duplicates mapping logic that drifts. Split when experiences genuinely differ, such as the web app versus the mobile app.
- A backend-for-frontend adds a hop, so it always makes the screen slower.
- Once a mobile BFF exists, its response shapes can change freely with each server deploy.
- Calling the services in parallel from the phone is the same as composing them on the server.
- Every app needs its own backend-for-frontend from day one, whatever the backend looks like.