A budgeting phone app requests a 15-minute balance refresh, but field logs show a few runs a day; why, and how should the design cope?
answer
- an interval is a floor
- every constraint must hold
- deep idle batches into windows
- usage sets the ration
- refresh on open, alert from the server
basics
~20 sA periodic interval is a minimum gap, not a timetable; runs also wait for constraints, deep-idle windows, battery-saving modes and usage priority. Design for a few runs a day: refresh on open, show data age, alert from the server.
solid answer
~50 sPeriodic background work only sets the shortest gap between runs. On one platform 15 minutes is the smallest interval allowed at all; on the other there is no interval, only an earliest start for the next run, which the system treats as "not sooner". Each run then also waits for its constraints, so a charging requirement can delay or skip a whole interval. An unplugged phone lying still drops into a deep idle state where jobs wait for maintenance windows that come less and less often, and on one platform an app the user opens rarely gets fewer runs. So a few runs a day is the system working as designed. I would request an honest interval of a few hours, refresh in the foreground on open, label balances with their age, and send the "close to your budget" alert from the server as a push.
go deeper
Remember that a periodic interval is the shortest gap between runs, never a timetable, and that the OS can delay or skip a run.
Explain the causes that stack: the floor or earliest start, constraints, deep-idle maintenance windows, usage-based priority and battery-saving modes, each attributed to the platform that documents it.
Redesign around the drift: an honest interval, a foreground refresh path, visible data age, server-sent urgent alerts and field measurement of real gaps per platform and device maker.
Set a team rule that no feature promises a cadence from device scheduling, and decide which freshness guarantees the server must own instead.
## The symptom The personal-budgeting app shipped a periodic refresh "every 15 minutes" so balances and the spending summary would always be fresh. Field logs show three to six runs a day, sometimes none overnight, and almost none for some users. Nothing is broken. The request and the OS simply mean different things by "every 15 minutes". ## Why periodic work drifts **Periodic work** is a deferrable job the OS may repeat. Several independent mechanisms stretch the gap between runs, and they stack: | Cause | What it does to a 15-minute request | |---|---| | The interval is a floor | On one platform the repeat interval is "the minimum time between repetitions" and 15 minutes is the smallest allowed; the exact time depends on constraints and system optimisation | | No interval at all | On the other platform each run submits the next with an **earliest start**; the system promises only that it will not begin sooner | | Constraints | A run waits until *every* constraint holds; with a charging constraint a run can be delayed or skipped for that interval | | **Deep idle** | An unplugged, stationary phone with the screen off defers jobs and network access to brief **maintenance windows**, which come less often the longer it lies still | | **Usage priority** | On one platform the OS sorts apps into tiers by how recently and how often the user opens them, and the tier sets how often jobs run on battery | | Battery-saving modes | A user's battery-saving mode or a low battery holds deferred work back further | | Device makers | One platform lets each manufacturer set its own criteria for tiering apps the user rarely uses | The other platform's documentation says the system decides when to launch the task and promises no time, so a design cannot assume either platform is the generous one. ## How the design should cope 1. **Ask for what the data needs, not what the team wishes.** Bank transactions post a few times a day; a refresh every few hours with a network constraint is honest and cheap, while 15 minutes requests a cadence no OS will deliver. 2. **Make the foreground the freshness path.** When the user opens the app, refresh at once; the periodic run only shortens that wait. 3. **Show the data's age.** Every balance carries its last-updated time, so a missed run is visible rather than wrong. 4. **Move time-critical messages off the device schedule.** The "you're near this month's budget" nudge is computed by the server and sent as a push; a device schedule that may not fire for hours cannot carry it. 5. **Measure the real cadence.** Log each run's start, the gap since the previous run and the outcome, and look at the distribution per platform and per device maker rather than the requested interval. ## What not to do - **Shorten the interval further.** On one platform nothing shorter than 15 minutes can be requested at all, and at any interval the same mechanisms still decide. - **Fake activity to earn a better tier.** One platform's documentation warns that the tiering algorithm can change and that each manufacturer may write its own; notifications sent only to keep an app "active" get dismissed, and the system then offers the user a way to block them. - **Keep the app alive in the background with a socket or an ongoing task.** That spends the user's battery to cheat the scheduler and is a different design with its own costs. ## Worked check Suppose, as the scenario's own assumption, a user opens the app twice a day and charges overnight. Two foreground refreshes plus a run or two during charging give fresh data at every open — exactly what the user experiences — even though the periodic job ran four times instead of ninety-six. The design was right to need only that. A user who opens the app once a week and rarely charges overnight is the opposite case: almost every open finds day-old data, so the foreground refresh and the visible data age carry the whole experience. ## What interviewers grade That the candidate names more than one cause, keeps each platform's specifics attributed to that platform, and moves freshness onto the foreground and urgency onto the server instead of fighting the OS.
- Would requesting a 15-minute interval with no constraints make runs more frequent?Only a little. Dropping constraints removes one reason to wait, but deep idle, usage priority and battery-saving modes still decide, and the floor remains. It also lets runs happen on cellular and on a low battery, spending the user's data and energy for freshness nobody sees until they open the app anyway.
- The team wants the 'near your budget' nudge the same afternoon a big purchase posts; where should that logic live?On the server, which sees the posted transaction first and can send a push straight away. The device schedule might run hours later, so it can at most refresh the numbers behind the alert, never be the reason it arrives.
A periodic job is a passenger on the waiting list for every flight: they will never board before their listed departure, they board only when a seat is free, and frequent flyers get seats first — some days they fly late, some days not at all.
- A periodic job set to 15 minutes runs every 15 minutes.
- If runs are rare, shortening the interval will make them frequent.
- Missed periodic runs are queued and replayed together later.
- Both platforms schedule periodic work the same way, so one test device proves the cadence.
- Sending extra notifications keeps the app in a better background tier.