Stippl is the social AI travel planner. To show a profile picture, our backend fetched the person's Firebase account through a DataLoader batch function that made one call per person, and threw the photo away when our own profile had one. We read the profile first, stopped calling where only an id was needed, and batched and cached the rest: Firebase lookups per request fell 87%.
In the week to 23 November, our GraphQL backend asked Firebase for a person's account 0.43 times per request, at about 160 ms a call. The feed of who is travelling right now made almost five such calls per request, one per person, because our DataLoader batch function sent every key to Firebase on its own. In two of our busiest operations, not one of those calls was needed.
This is how we found them, why the loader did not help, and why batching ended up as the last of three fixes instead of the first. A week later, Firebase lookups per request are down 87%.
The count per operation
On 23 November I measured where our request time goes. No load test: a week of production traces in Sentry, which samples one request in ten, read per operation. The external call that took the most time in total was not a travel API. It was Firebase Authentication's account lookup, accounts:lookup, the call behind the Admin SDK's getUser(uid).
Every face in our social travel platform has a picture: on a profile, in a follow list, in the feed of who is travelling now, on a shared trip. For each one, the backend loaded that person's Firebase account. Read per operation, the week before the fix looked like this:
Follow status was the one that made me stop. Its answer lives entirely in our own database, and it still waited on Firebase for every request: 154 ms for the middle request, the p50.
A DataLoader that only remembered
DataLoader is the small library most GraphQL servers use against the N+1 problem. You call loader.load(key) from as many resolvers as you like. It collects every load made in the same tick of the event loop, calls your batch function once with all their keys, and remembers each answer for as long as the loader lives. We create ours per request, as its README recommends.
The library does the collecting. What happens to the keys is up to the batch function, and ours was this: Promise.all(uids.map((uid) => getUserByUid(uid))). One Firebase call per key. The comment above it was honest about it: "a per-request memo rather than a bulk fetch".
So the loader did deduplicate. The same person shown three times on one page cost one call. But ten different people cost ten calls, and a feed is made of different people. That is where the 4.88 came from.
The obvious fix was to batch: Firebase Admin has getUsers, which takes up to 100 identifiers per call. We had the change half planned before we asked the question that mattered more: what did we do with the answer?
The photo we threw away
The code that builds what we show of a person, from our profile and the Firebase account, had one line that settled it: the picture is our own profile's picture, and Firebase's photo only when the profile has none, for someone who never set one with us.
But the code fetched both every time, in parallel, before it knew which one it would use. For every person with a picture on their Stippl profile, we waited on a Firebase account and threw its photo away. The profile's picture is written only by our own profile update, so there is no case where Firebase holds a newer one.
Two more calls were needed even less:
- Follow status. To answer "do I follow this person?", the resolver loaded the caller's profile through a method that also asks Firebase for a name and a picture. It then used one field of the result: the profile's id.
- Your own email. Showing a traveller their own address loaded their Firebase account, while the request already carried a verified ID token with that address in it.
Three layers, in order

Where a picture comes from now
The fix is three layers, and the order matters: each one shrinks what the next has to handle.
First, read the profile you own. The picture resolver now loads the profile first and asks Firebase only when it has no picture: const firebaseUser = profile?.picture ? null : await loaders.firebaseUser.load(firebaseId). The name works the same way. Both picture resolvers now share that one helper, so they cannot drift apart.
Second, no Firebase where an id is enough. Follow status, follow requests and recommendations read the caller's own profile through the request's profile loader, which never touches Firebase. Follow status answers NONE when there is no profile, where the old code queried with an undefined follower. Your own email comes from the verified token.
Third, batch and cache what is left. The loader's batch function now reads all its keys from Redis in one MGET. Only the misses go to Firebase, through getUsers, in chunks of at most 100. What comes back is stored as a slim record (uid, email, name, photo and the provider list) for ten minutes.
One detail matters here. DataLoader needs its batch function to return one value per key, in the order of the keys. Firebase's getUsers returns the accounts it found in no guaranteed order, and lists the ones it did not find separately. So the results are mapped back by uid, and a uid Firebase does not know answers null. Tests pin the shape: N concurrent loads make one call with the distinct uids, and 250 uids go out as 100, 100 and 50.
The trade-offs we took
Ten minutes of staleness. Our backend never writes a name, photo or email to Firebase; those change on the traveller's device. So the TTL is the only bound on how old a cached name or photo can be. The one write the server does make is deleting an account, and that removes the cached record too.
A slow cache never slows a request. Our Redis client retries forever (maxRetriesPerRequest: null), so a read during a Redis outage would wait as long as the outage. The cache read is raced against 150 ms. When it loses, or Redis is not ready, the lookup goes straight to Firebase. A cache problem costs speed, never an error.
A missing account is not cached. A uid that Firebase does not know is asked again the next time it appears. That costs a call each time such a uid appears. We kept the first version simple: only accounts that exist are cached.
A failed batch fails wider. One failing getUser used to cost one picture. One failing getUsers can cost a hundred. Each chunk fails on its own, and a failure is logged and never cached, so the next request asks again. It happened once on the first day: Google answered one batched call with a 500, and the people in it showed without their Firebase fallback in that one response.
The numbers after
The change went live on 23 November at 18:35. I compared the seven days before with the six and a half days after, from the same 10% sample of traces, as lookups per request so traffic cannot flatter it (it was about 5% lower in the week after).

Lookups per request, before and after
Every operation went down. The two that reached zero are the two where Firebase was never needed: the feed, through our own profiles, and follow status, through an id. The rest still go through the batch and the cache.

One feed request, before and after
The feed and follow status have made no Firebase lookup at all since 25 November. The few in their after column came from the first day, while the deploy rolled out.
The time these operations spend:
A trip got faster too, from 247 to 135 ms at p50. I do not credit that to this change: two other fixes to the trip query went out the same day, one to its weather calls and one to its image queries. In the first hour after the deploy the trip's p95 even went up, from 557 to 716 ms. That was the weather calls on long trips, which became the next fix.
What is left sits mostly on two public pages, a shared trip and a public profile. I have not finished reading which of their paths still call Firebase.
What I would do differently
Two things.
I would ship the layers separately. They went out in one change, so I cannot split the 87% between them. The per operation numbers give part of the answer. The feed and follow status reached zero, and a cache cannot do that: a ten minute cache still misses once per person every ten minutes. There, reading our own profile and not calling at all did all the work. For the rest, I can only say all three helped together.
And I would ask what a call's answer is used for before asking how to make the call cheaper. Our first plan was the batch. It would have turned 4.88 calls per feed request into one, and we would have called that a win. Reading the line that used the answer is what showed that the right number was zero.
The takeaway
A DataLoader in your code tells you nothing about batching: read its batch function. And before you batch or cache a call to someone else's API, check that you need its answer at all. Count the calls per operation, then find the field that makes them.
Our first plan was the batch. Reading the line that used the answer showed that the right number was zero.Robin, CTO of Stippl
Questions people ask
Does DataLoader batch requests by itself?
It collects the loads of one tick and calls your batch function once with all their keys. If that function then makes one request per key, you get deduplication within a request, not batching.
How many accounts can Firebase Admin getUsers fetch in one call?
Up to 100 identifiers per call. It returns the accounts it found, in no guaranteed order, and a list of the identifiers it did not find, so map the results back by uid.
Can DataLoader replace a Redis cache?
No. Its memo lives as long as the loader, which you normally create per request, so only a shared cache such as Redis keeps an answer from one request to the next.
Stippl is the social AI travel planner. Travellers describe a trip in their own words, the AI builds the plan, and the people they travel with join to plan, book and share it together. More than 1.5 million travellers have planned their trips with Stippl. It is free on iOS, Android and the web.



