skip to content

How should a wedding-photography app order, parallelise and retry 600 queued photos and a 2 GB clip on a weak venue signal?

level: seniorimportance: should knowfreq 40%

answer

  1. what should the couple see first?
  2. a few streams share one thin uplink
  3. path failure or request failure?
  4. a refused file is never retried
  5. hand the OS a batch

basics

~20 s

Favourites and small photos go first, the 2 GB clip last, with only a few uploads in flight on a thin link. Lost connections and server errors resume from the server's offset after backoff; refused files are never retried.

solid answer

~50 s

Order by value to the couple: the photos the photographer flagged first, then the remaining photos, and long clips last — by default on Wi-Fi — so the gallery fills while the big file waits; total time barely changes, but usefulness arrives hours sooner. Keep concurrency low, say two photos and one large file in flight (an assumption to tune from measured throughput): on a thin uplink more streams split the same bandwidth and leave more half-sent work when the signal drops. Hand the OS's transfer service a batch rather than one file per wake-up. Retry by failure class: a lost connection, a timeout or a `5xx` means back off with jitter, ask the server for its offset and resume; `429` or `503` honours `Retry-After`; an expired URL gets one refresh; a refused file — too large, wrong type — fails at once and is shown to the photographer.

go deeper

for a junior

Recall two rules: send what the user values most first, and never keep retrying a failure the server says is final.

for a middle

Explain the ordering, why a few concurrent uploads beat many on a thin uplink, and which failures resume from the server's offset after backoff.

for a senior

Walk the failure table — lost link, 5xx, 429 with Retry-After, expired URL, offset conflict, upload gone, refused file — and show retries that do not drain the battery.

for a principal

Own the policy for large media: whether long clips wait for Wi-Fi and charging by default, what users may override, and how concurrency adapts to measured throughput.

## Order: what the couple sees first A photographer leaves the reception with **600 photos** (say 10 MB each, an assumption) and a **2 GB** ceremony clip queued, on an uplink of about **2 Mbit/s** (also an assumption). At that rate the photos alone are 6,000 MB, or 48,000 Mbit, about 6.7 hours; the clip adds another 2.2 hours. The queue will not finish at the venue, so the real question is what arrives first. 1. **Flagged favourites** — the 50 shots the photographer starred for the couple: 500 MB, about 33 minutes. 2. **The rest of the photos**, in shooting order so the gallery fills as a story. 3. **Large clips last**, by default only on Wi-Fi and while charging, with a visible override. On a fixed link the total time is about the same in any order; sending the clip first does not make the queue finish sooner. What order changes is **when the gallery becomes useful**: favourites first puts the best photos in front of the couple within the hour, while clip first leaves them an empty gallery for more than two hours. ## How many at once - **Bandwidth is shared.** On a thin uplink, ten parallel uploads each get about a tenth of it; none finishes sooner, and the first photo appears later. - **Partial work is exposure.** When the signal drops, every in-flight upload is interrupted together; more streams mean more half-sent files to resume. - **Servers push back.** A burst of connections can earn `429 Too Many Requests`. - **A separate lane for the big file.** One slot for a large clip and two for photos keeps photos flowing while a clip trickles — a starting point to tune from measured throughput, not a rule. When work is handed to the OS's background-transfer service, hand over a **batch in priority order**. On one platform the documentation (written for background downloads) describes a delay that grows each time the system wakes the app and the app then starts a new transfer; it recommends one session with many tasks started together over a chain of one-at-a-time hand-overs. ## Retry by failure class The common mistake is one retry rule for everything. A failure is either the **path** (the network, a busy server) or the **request** (this credential, this offset, this file). Only the first is cured by waiting. | What happened | What it means | What the client does | |---|---|---| | connection lost, timeout, no response | the path failed | wait for connectivity, back off with jitter, ask the server for its offset, resume | | `5xx` | the server failed | back off, ask for the offset, resume | | `503` or `429` with `Retry-After` | the server asked for a pause | wait at least that long; lower concurrency after a `429` | | `403` on an expired pre-signed URL | the credential expired | get a fresh URL once; if that is refused too, fail the entry | | `409 Conflict` on append | the client sent the wrong offset | ask for the offset again | | `404` or `410` for the upload | the server discarded the partial upload | start a new upload from zero | | `413`, `415` or another refusal of the file | the server will not take this file | fail at once, store the reason, show it | The IETF draft for resumable uploads says the same in general form: after a server error or a lost connection the client may retrieve the offset and resume; after a client error it should not retry unless the response's meaning allows it. A `409` offset conflict and a `403` on an expired credential are exactly such errors: each says what to change before trying again. ## Retrying without draining the phone - **Do not retry into no network.** A loop firing every few seconds while the venue has no signal wakes the radio for nothing. Wait for the OS to report connectivity, or let an OS-owned transfer wait for a network. - **Back off with jitter and a cap**, so many phones regaining signal after an outage do not all retry in the same second. - **Keep retrying path failures** for as long as the file exists and the user has not cancelled; a 2 GB clip may need dozens of resumes over a weekend. Request failures other than an expired URL, a wrong offset or a discarded upload get no retries at all. - **Cellular rules belong to the user.** A setting such as *originals on Wi-Fi only* decides which lane may run on a metered network. How long background work may run, and when the OS defers it, is the background-work subject; this design only has to survive those limits. ## What the photographer sees Each file shows one honest state: *waiting for Wi-Fi*, *uploading 63 %* from the server's offset, *retrying in 2 min*, or *failed — file type not accepted* with a button to remove or replace it. A refused file never loops silently, and a path failure never shows up as an error the photographer has to fix.

  • Why not upload all 600 photos in parallel to finish sooner?
    On a thin uplink the streams share one pipe, so each runs proportionally slower and the total time barely moves, while the first finished photo arrives later. Every drop now interrupts dozens of half-sent files, and the server may answer the burst with `429`. A small fixed number of streams, tuned from measured throughput, does better.
  • How does the queue avoid draining the battery while the venue has no signal at all?
    It stops retrying on a timer. It waits for the OS to report connectivity, or leaves the work with an OS-owned transfer that waits for a network, then backs off with jitter and a cap. Each blind attempt wakes the radio for nothing; one attempt after the network returns costs far less.
  • The server answers a photo's upload with `413 Content Too Large`; what should the queue do?
    Mark that entry failed with the reason and stop. Resending the same file produces the same refusal and burns data. Show it to the photographer with an action — remove it, or send a smaller version — while the rest of the queue keeps moving.

  • Uploading every file in parallel finishes sooner on a weak connection.
  • Starting the 2 GB clip first makes the whole queue finish sooner.
  • A file the server refused will go through if retried often enough.
  • Retrying every few seconds is harmless while the phone has no signal.
  • Every upload failure can be handled by the same backoff-and-retry rule.