It started with a feeling that events showed up late. Before fixing anything, we measured. We made a measuring build that blocked every request except GET on a real account, and logged each request that actually left, to the millisecond, under the adapter that calls the server. Each case ran three times and we used the median. When we were done we deleted that build.
Here is what we saw first.
- Opening the app sent 12 requests: rules, calendars, plan, home and each month separately.
- Coming back to the app within a minute re-asked for months that had just answered "unchanged".
- Every edit re-asked for all five months the app held.
Results first
We barely touched the screen and model code. Screens still ask "this month, please" and "home, please" separately. What changed is a set of rules for asking less, and one adapter layer that calls the server.
Ask less
The first step was to stop asking what didn't need asking.
- A month answered within the last minute isn't asked again. That holds when paging stops, when the app opens and when it comes back to the foreground. Coming back within a minute went from 6 requests to 1.
- After an edit, ask only for the current month and the edited month. Months held on either side are checked when they come into view.
The cost is that edits by people sharing a calendar can show up to a minute late. Edits you make on another device or the web send a change push, so those are fetched right away.
One request per moment
When the app opens, several places call the server at nearly the same moment, and each request repeats the sign-in check and settings read. So we collect those calls into one batch request (GET /api/v1/view) and split the answer back to each caller in its original shape. It's the DataLoader pattern, well known from the GraphQL world. The web uses the open-source dataloader as is; iOS uses a small adapter in the same style.
Batching happens only inside the adapter that calls the server. Screens and models call the way they always did and don't know batches exist.
- A very short window. Months and home are collected only within 10 ms, so batching never delays the month on screen.
- Things that can wait ride the same batch. Rules, calendars and plan, fetched once on open, wait 150 ms so they join the board fetch.
- Many months, one request. Prefetching the months on either side used to be capped at two at a time so we wouldn't flood the server. In a batch that cap no longer means anything: one batch holds up to seven months, so four neighbors are one request.
- One copy of the same GET, and push-device registration only when it changes.
The unbatched paths stay. A single call goes out as the original request, and the separate month and home routes (/days, /home) are still there. Writes (POSTs like calendar sync) never join a read batch. And tests check that batching on and off give the same answers.
After edits and pushes
With reads batched, what was left was the time after writes.
- Home and months in the same moment. After an edit, home and the months to re-fetch are called in the same moment and go out as one batch.
- A burst of pushes, one fetch. When the web or a connected tool makes several edits in a row, pushes arrive in a row too. We fetch once after 1.5 s of quiet, and never later than 5 s after the first push. Five pushes in one second went from 10 requests to 1.
- A burst of edits, one fetch. Moving several events in a row fetches once after 500 ms of quiet. The screen has already changed optimistically, so nothing looks different while it waits.
There's a reason checking off a task is 2 requests and not 1: one write and one fetch. The server doesn't push an iOS write back to the device that made it, so that device has to fetch on its own.
Why writes don't return the board
There was a way to make a check-off 1 request instead of 2: put the changed board in the write response, so no re-fetch is needed. We dropped it on purpose. Once a performance device shapes the write response, every caller of the write API (web, iOS, connected tools) has to know about it.
A performance device must not touch the domain. Turned off, requests go out separately, and on or off must give the same answer.
Opening a sheet: 4 requests to 1
Tapping an event opened a sheet that asked separately for details, tags, prerequisites and what's inside. We added an item's parts to the batch request, and on the web, the fetch slot of openapi-fetch batches GETs for one item made in the same moment. The sheet code and the separate routes are unchanged. A missing part comes back as a 404, just as a separate request would, and a test assembles both for real and checks the batched parts match the separate routes.
On iOS, batching alone didn't cut anything. The picker values and tag reads left about 620 ms late, while the sheet was drawing, and missed the batch. In Swift 6, a child task started with async let had to hop back to the main thread before its request left, and the main thread was busy drawing the first frame. Only after requests left right where they were called did they land in one batch. The detail request also moved up, from 620–730 ms after opening the sheet to 153–165 ms.
The server reads less too
- The sign-in check is remembered for 60 seconds. We compared other ways to the same goal (Clerk's 60-second tokens, Better Auth's secondary storage) and settled on 60 seconds. The trade is that a revoked session can live up to 60 seconds.
- Connected tools (MCP) read only what they need. The plan is read only when a tool is called, not when connecting or listing tools. The DB round trips before a tool call went from 5–6 to 1–2.
There's a place we chose not to cut. Remembering a connected tool's consent across requests would save one more read, but a permission the user revoked would stay alive for a while. So consent is read once per request, never across requests.
Wasted work in sync
In production logs we found a single calendar sync taking over 10 seconds. Two of Google's holiday calendars returned all 151 events every time, even on an incremental sync (syncToken). Nothing had changed, yet each time we rewrote the bindings, attendees and history 302 times. Now an event that comes back with the same version (etag) as the one we stored is neither read nor written.
These calendars also refused every attempt to set up change notifications (pushNotSupportedForRequestedResource), on every sync. We record the refusal as a fact and don't try again for six days.
A deploy stalled production for three minutes
Deploying that sync fix caused an incident. A migration that added a column (alter table) waited for a lock another connection held. In Postgres, every request that reads the table queues behind the one waiting for the lock. So board, calendar and connected-tool requests that read that table stalled for about three minutes. One board request took 116 seconds; one tool request took 190.
- Wait 3 seconds for a lock. Migrations set
lock_timeoutto 3 seconds and, if they can't get the lock, let go and try again. After 8 tries the build fails, and the current deploy stays. - Builds built together take turns. A transaction lock (
pg_advisory_xact_lock) lets one run at a time, and files an earlier build applied are skipped. - A late file runs alone. A new file whose name sorted earlier was merged late, and the rule "rerun from the changed file through everything after it" reran a later file that was already applied, locking the table again. That rerun stalled things for another 60 seconds. Now only the new file runs.
Every wait in one place
10 ms, 150 ms, 500 ms, 1.5 s (5 s at most), 1 minute. Every wait in this post lives as data in one app policy file shared by web and iOS. No numbers are written into screen or adapter code. The web (TypeScript) and iOS (Swift) each read the policy with their own interpreter, and both interpreters are tested against the same scenario files. Values only iOS uses live in the same file, marked with the platforms that use them.
What we learned
- "Visible month first" only matters on the first draw. Once the screen is drawn, splitting requests costs more. So a month already on screen is fetched together with its neighbors.
- Collecting needs two values: quiet after the last call and a maximum wait from the first. Measure waits against real finger speed so they don't sit on an edge.
- If batching doesn't cut anything, look at when requests leave. A batch only collects calls that leave in the same moment. On iOS, the concurrency model was making calls leave late.
- Security invariants beat optimizations. Remembering something that keeps a revoked permission alive isn't worth any speed.
- Make the measuring trustworthy first. We measured a real account with a read-only build. You can only trust a fix as far as you trust the numbers.
Filling the database with 10,000 users covered the server side; this post covered how the app asks the server.