skip to content

Would you choose REST, GraphQL or gRPC for a travel-booking mobile app used on slow roaming networks, argued from the device?

level: middleimportance: must knowfreq 46%

answer

  1. argue from the screens first
  2. round trips per screen
  3. who shapes the response
  4. what HTTP caching survives
  5. proxy debugging and generated types

basics

~20 s

Argue from round trips per screen on a slow radio: REST keeps HTTP caching and easy debugging but needs screen-shaped endpoints, GraphQL fetches one screen's fields in one request, and gRPC brings binary messages and codegen but needs HTTP/2 end to end.

solid answer

~50 s

I'd start from the screens: search results, a hotel detail with photos, reviews and rooms, and booking, all on roaming links where a round trip takes hundreds of milliseconds. **REST** over plain resources makes the detail screen several calls, so I'd only choose it with screen-shaped endpoints; in return it keeps `GET` caching with `ETag` revalidation and is easy to read in a debugging proxy. **GraphQL** lets each screen select exactly its fields in one request and gives typed client code from the schema, but it is usually sent as a `POST` to one URL, which shared HTTP caches do not reuse, and query cost moves to the server. **gRPC** gives compact binary messages and generated clients, but every call is a `POST` over HTTP/2 with trailers, so caches don't help and every intermediary must pass HTTP/2 intact. For this app I'd pick GraphQL or screen-shaped REST, and name what I'd measure to revisit it.

go deeper

for a junior

Recall what each style looks like on the wire: resources over HTTP methods, one query endpoint, or generated methods over HTTP/2. Then name one strength and one cost of each.

for a middle

Walk the five device questions for each screen: round trips, response shaping, codegen, readability in a proxy, HTTP caching. Make a choice for this app and say what it gives up.

for a senior

Bring the path into the answer: hotel and airport proxies, HTTP/2 end to end for gRPC, cacheable search, and the server cost of client-shaped queries. Say what would change your mind.

for a principal

Frame it as a contract choice that outlives many builds: a style the organisation can operate, debug and evolve, with one mobile-facing layer that can change without app releases.

## Start from the screens and the link A protocol choice for an installed app is argued from what the device lives with, not from which style is fashionable on the server. The travel-booking app has four kinds of screen: - **Search results** for flights and hotels — lists, often the same for many users with the same query. - **A hotel detail screen** — the hotel record, photos, a review summary and room options with live prices. - **Booking** — a single write that takes money and must not be duplicated. - **Background refreshes** of a saved trip. And it runs abroad on **slow, roaming mobile networks**: high and variable latency, low throughput, metered data, and networks the app does not control, including hotel and airport Wi-Fi behind proxies. ## Five device-side questions to ask of each style 1. **How many round trips does each screen need?** On a 400 ms link, every dependent call costs a visible pause. 2. **Who shapes the response?** If the server decides, screens over- or under-fetch unless endpoints are shaped per screen; if the client decides, the server must resolve arbitrary selections. 3. **What does the client get from tooling?** Generated, typed models from a schema remove hand-written parsing and catch contract drift at build time. 4. **Can an engineer read the traffic?** Text over plain HTTP is readable in a debugging proxy; binary frames need the schema to decode. 5. **What survives of HTTP caching?** Responses to `GET` are cacheable and revalidate with `ETag`; a response to a `POST` cannot satisfy a later `POST`. ## How the three compare from the device | Concern | REST | GraphQL | gRPC | |---|---|---|---| | Round trips per screen | several, unless endpoints are screen-shaped | usually one per screen | one per method; composition is the server's job | | Response shaping | the server's choice per endpoint | the client selects fields | fixed by the message schema | | Client codegen | optional, from an API description | from the schema and the app's queries | from the service definition, built in | | Reading traffic | text, easy in a proxy | text, but every call hits one URL | binary frames, needs the schema | | HTTP caching | full `GET` caching and revalidation | lost for `POST`; recovering it is a caching design of its own | lost: every call is a `POST` | | What the path must support | any HTTP version | any HTTP version | HTTP/2 with trailers, end to end | | App size | an HTTP client and a JSON parser | plus a query client and cache | plus the format's runtime and generated code | Two facts in that table are worth stating precisely. The GraphQL specification describes a request whose response "contains exactly what a client asks for and no more", which is why it fits a composed screen; that specification does not define an HTTP transport, so "one `POST` URL" is common practice rather than a rule. The gRPC protocol fixes the method to `POST` and carries the call's final status in **trailers**, and sends `te: trailers` so that incompatible proxies can be detected. ## A defended choice for this app No style always wins, so the answer is a choice tied to the screens: - **Search results** benefit most from HTTP caching and small, shaped rows. A `GET` per search query keeps that cheap for repeated queries. - **Hotel detail** is the screen that punishes under-fetching: one composed request, either a GraphQL query or a screen-shaped endpoint behind a composer, is the goal. - **Booking** is one write either way; how it is retried safely is the request pipeline's concern, not the protocol's. A reasonable answer is GraphQL for the composed screens with care for search caching, or REST with screen-shaped endpoints. gRPC is a strong choice when the team owns both ends, wants binary payloads and generated clients, and has verified that the networks between the phone and the server pass HTTP/2 intact; on hotel and airport Wi-Fi that last check is real work. ## Where a persistent socket fits A socket held open from the device is warranted for server-initiated updates, such as a price that changes while the user watches, not for request-response calls. Which live transport to use per feature is a separate decision about real-time delivery. ## What makes the answer strong - It names the screens before the protocol. - It counts round trips and bytes on the slowest link the app supports. - It says what each option gives up: caching, readability, server cost or path requirements. - It ends with what to measure: per-screen load time on slow links, round trips per screen, cache hit rate for search, and parse time on the lowest-end device.

  • The backend already speaks gRPC between its services. Does that decide what the mobile app should use?
    No, it is one input. Internal calls run inside a data centre on clean HTTP/2; the phone crosses radios, unknown proxies and builds that live for years. Many teams keep gRPC inside and put a mobile-facing layer in front, or expose the same service in two styles. Choose the device's protocol from its screens and network path.
  • What would you measure after the first release to know whether the protocol choice was right?
    Per-screen time to a usable render on slow links, round trips and bytes per screen, parse time on the lowest-end supported device, error rates by network type, and the cache hit rate for search. If detail screens still take several round trips or search never hits cache, fix response shaping before changing protocols.
  • Could one persistent socket replace HTTP calls for the whole travel app?
    Not sensibly. A socket earns its place for updates the server starts, such as a live price or a hold that is about to expire, and the OS limits it while the app is in the background. Request-response calls keep HTTP's status codes, caching and tooling. Which live transport each feature gets is a separate decision.

  • GraphQL always beats REST on mobile because it removes over-fetching.
  • gRPC responses are cached by shared HTTP caches like any GET.
  • The style the backend uses internally must be the one the app uses.
  • A persistent socket is the fastest choice for every request-response call.
  • REST cannot shape a response to one screen.