skip to content

In a budgeting phone app, which work should run as urgent and which deferred: a just-saved cash expense, the category-model refresh, the database backup?

level: middleimportance: should knowfreq 48%

answer

  1. who is waiting for it
  2. urgent work spends a ration
  3. bulk work waits for cheap conditions
  4. a short extension, not a long run
  5. never ride the nightly batch

basics

~20 s

Only the cash expense is urgent: the user just did it and it is tiny, so it leaves at the first connection. The model refresh and backup are deferrable bulk work that waits for cheap conditions, sparing the small urgent-time ration.

solid answer

~50 s

I sort by who is waiting. The cash expense is something the user just did: it is saved locally first, sent at once while the app is on screen, and if the user leaves straight away it uses the platform's short urgent path — on one platform run-now work that starts immediately if the app's quota allows, on the other a request for a little extra time as the app leaves the screen. With no signal it waits for any network, never for the overnight batch. The category-model refresh and the backup nobody watches: they are deferrable work that requires charging and idle, or an unmetered network, and can slip a day. Running them as urgent would spend a per-app ration of urgent time, sized by how much the user uses the app, that the next expense needs.

go deeper

for a junior

Recall that work the user just did is treated differently from maintenance nobody is watching, and that urgent background time is limited.

for a middle

Explain how each job is classified, which conditions each deferrable job declares, and what a per-app urgent quota means when it runs out.

for a senior

Show the user's write is never lost when the urgent path is unavailable, and keep bulk work off it so the ration stays for the sends that need it.

for a principal

Own a rule that limits which teams may use the urgent path, since every feature spends the same per-app ration and the user's battery.

## Two kinds of background work A phone OS offers an app two different bargains for work done off screen. - **Urgent, short work** — something the user just started and expects to finish: sending a message, saving a file, recording a payment. It should start now and finish within seconds to a few minutes. - **Deferrable bulk work** — maintenance nobody is watching: retraining a model, compacting or backing up a database, prefetching. It can wait hours for conditions that make it cheap. The platforms expose the urgent path differently. On one platform the app can mark a one-off job as urgent run-now work: it starts immediately if the system's load allows, is meant for short user-initiated tasks such as sending a message, and is less held back by power-saving restrictions — but it draws on a **per-app quota of execution time** that depends on how much the user uses the app. On the other platform the app asks, before or as it leaves the screen, for a **limited extra stretch of time** to finish critical work such as sending a message, with an expiration handler that must cancel or defer the work when time runs out. Deferrable work on that platform includes a task type for heavy processing that the system schedules for periods of low activity such as overnight while charging. ## Sorting the personal-budgeting app's three jobs | Job | Who is waiting | Path | Conditions | |---|---|---|---| | Cash expense typed in a lift | the user, right now | urgent, and the foreground first | any network; nothing else | | Category-model refresh | nobody | deferrable bulk | charging and device idle | | Database backup | nobody, until a phone is lost | deferrable bulk | unmetered network and charging | The cash expense is small, user-initiated and wrong if it is late: a partner sharing the budget should see it soon. The model refresh is CPU-heavy and invisible; running it on battery while the user scrolls is exactly what the OS's idle and charging conditions exist to prevent. The backup moves the whole local database over the network, so an unmetered link and a charger make it cheap; one missed night costs nothing. ## The life of the cash expense 1. The expense is written to the local database together with its queued send, so it can never be lost (the ordering and keys of that queue belong to the question on the offline outbox). 2. While the app is on screen, the send is attempted at once and again when connectivity returns. 3. If the user leaves the app immediately and there is signal, the app takes the platform's urgent path — run-now work on one platform, a short extension on the other — so the send finishes within the moments the OS grants. 4. If there is no signal, the send becomes a one-off job that needs only a connected network, and the next app open retries it too. At no point does the expense wait for the overnight batch. ## Why not make everything urgent - **The ration is small and shared.** On one platform the documented guideline gives urgent work from about 30 minutes per rolling day for an app in active use down to 5 minutes for the most restricted, explicitly approximate and not guaranteed; urgent quotas are stricter than those for ordinary jobs. A backup spending minutes of it every night can leave the next expense with nothing. - **Out of quota means degraded, not faster.** That platform lets an app choose what happens when the quota is gone: run the job as ordinary deferred work, or drop it. Either way the backup has gained nothing and the expense may have lost its fast start. - **Urgent is not long.** An extension or a run-now job is sized for seconds to minutes. Bulk work squeezed into it gets stopped partway. - **It spends the user's battery and data at the worst time.** Bulk work run as urgent runs as soon as the app leaves the screen — on battery, perhaps on cellular. ## A useful rule Ask two questions of every job: *does a person notice if this is an hour late?* and *is it small?* Only a yes to both earns the urgent path. Everything else declares its cheap conditions and accepts that it may slip a day — with its staleness visible if a person ever looks.

  • The urgent-time quota is spent when the user saves another cash expense and leaves; what should happen?
    The send still must not be lost. The app keeps it queued on disk and lets the job fall back to ordinary deferred work with a network constraint, which is one platform's built-in out-of-quota choice, and the next app open retries it. Dropping the job is only acceptable for work that can be recomputed, never for a user's write.
  • Could the backup ever deserve the urgent path?
    Yes, when the user asks for it, say before handing in a phone. Then a person is waiting, so the app runs it on screen with visible progress; it is still too large for a short urgent run, so a long transfer goes to the OS's transfer service rather than squeezing into an urgent job.

  • Marking every background job urgent makes the whole app feel faster.
  • Urgent background work is free of any quota or limit.
  • A just-saved expense can wait for the nightly sync batch.
  • Urgent work can run as long as the job needs.
  • A model retrain should start the moment the app leaves the screen.