skip to content

In a real-estate listing portal's web uploader sending 60 photos and a 3 GB video over a phone's weak uplink, how many uploads should run at once, and why?

level: seniorimportance: should knowfreq 38%

answer

  1. parallel requests split a thin pipe
  2. one overall cap, not one per file
  3. a lane for the long file
  4. per-host connections, shared by tabs
  5. lower the cap when timeouts climb

basics

~20 s

Run a small overall cap, about two requests on a weak phone uplink and three or four on office broadband, with the video in one lane and photos in the rest. More parallel requests split a thin uplink without adding bandwidth.

solid answer

~50 s

Parallel uploads hide per-request latency (asking for the URL, the request setup, the wait for the response), which matters for many small photos on a fast link. They do not add uplink bandwidth: on a thin phone uplink, ten requests each run at a tenth of the speed, every file finishes later, and a drop loses ten partial requests instead of one. So the page sets one overall cap, about two in flight on a weak uplink and three or four on office broadband, and lowers it when timeouts climb. Within it the video gets one lane, one append at a time under an offset-based protocol, so the uplink never idles, while photos take the other lane in listing order and finish early for the agent to review. The browser's own limit, about six connections per host over HTTP/1.1, is not a design: over HTTP/2 requests share one connection and that ceiling disappears.

code

pseudocode · 16 lines
pseudocode
maxInFlight = weakUplink ? 2 : 4        // overall cap, set by the page, not by the browser
videoLanes  = 1                          // offset-based protocol: one append at a time

on file added, request finished, request failed, backoff elapsed:
  while inFlight < maxInFlight:
    next = pickNext()
    if next is none: break
    start(next)                          // fetch a URL just in time, then send

pickNext():
  if video has bytes left and videoInFlight < videoLanes and video is not paused:
    return next video append
  return first queued photo in listing order whose backoff has elapsed

on repeated timeouts:  maxInFlight = max(1, maxInFlight - 1)
on steady successes:   maxInFlight = min(ceiling, maxInFlight + 1)

go deeper

for a junior

Recall that parallel uploads share one uplink, so they hide waiting time but do not add bandwidth.

for a middle

Explain the browser's per-host connection limit over HTTP/1.1, why HTTP/2 removes it, and why the page still needs its own overall cap.

for a senior

Show the scheduler: a small overall cap sized to the link, one lane for the video under an offset protocol, photos in listing order, retries inside the cap, and a cap that shrinks after timeouts.

for a principal

Weigh a fixed cap against an adaptive one: adaptation fits the link but is harder to test and explain. Decide which signal drives it and keep the same policy in every upload surface the portal has.

## What parallel uploads buy, and what they cost An agent uploads 60 photos (about 1 MB each after resizing) and a 3 GB walkthrough video for a listing, sometimes from an office laptop and sometimes from a phone browser in the property on a weak mobile uplink. The tempting design starts all 61 uploads at once. Parallelism helps with one thing and hurts with several: - **It helps** by hiding per-request latency: asking the API for a URL, setting up the request, waiting for storage's response. For many small files on a fast link, that idle time is a large share of the total. - **It does not add bandwidth.** A weak uplink carries the same bytes per second whether one request or twenty share it. Twenty requests each run at a twentieth of the speed, so every photo finishes later and the agent sees nothing done for minutes. - **It raises the cost of a drop.** When the connection falls, every in-flight request loses its partial progress at once. - **It crowds out everything else** on the phone: the page's own API calls, the agent's messages, the map they are checking. - **It ages URLs.** Pre-signed URLs fetched for requests that then wait behind others can expire before their bytes move. ## The browser's limit is not your cap Over HTTP/1.1, browsers open only about six connections per host, and that limit is shared by every tab of the browser that talks to the same host. Over HTTP/2, the browser and server negotiate how many streams share one connection, commonly a hundred, so that ceiling effectively disappears. A page that relied on the browser to throttle it on HTTP/1.1 suddenly runs dozens of uploads at once when storage moves to HTTP/2. The page's own cap is the only one it controls. Because storage is a different host from the portal's API, uploads do not queue the API's requests on HTTP/1.1, but they still share the same radio. ## One overall cap, with a cap per file inside it | Scope | Rule | Why | |---|---|---| | Overall, weak uplink | about 2 requests in flight | enough to keep the link busy between requests, no more | | Overall, office broadband | about 3 to 4 | more latency to hide, bandwidth to spare | | Per photo | 1 request, whole file | small files gain nothing from being split | | Per video, offset-based protocol | 1 append at a time | each append continues from the previous offset | | Per video, a protocol that accepts pieces out of order | could take 2 | only where the server's protocol allows it | The IETF working group's resumable-uploads draft does not support sending one upload as several parallel requests, so under it the video is strictly one append at a time. These numbers are starting points to measure, not constants. ## Ordering: what goes first 1. **Start the video's lane at once.** The video is most of the bytes; keeping one request on it means the uplink is never idle while photo requests wait for URLs and responses. 2. **Photos in listing order,** cover photo first, in the remaining lane or lanes. Small files finishing early let the agent review, reorder and fix rejected photos while the video continues. 3. **Retries rejoin the queue** after their backoff, inside the same cap, never on top of it. 4. **Let the agent choose.** On a very weak link, offer to pause the video and finish it later on office Wi-Fi from the same device, since the server keeps its partial upload. ## Adapting to the link - Start at the cap for the link the page expects, then lower it after repeated timeouts and raise it slowly after a run of fast completions. - Treat the browser's `offline` event as a hint to pause the scheduler, not proof; resume when requests start succeeding again. - When the page is hidden on a phone, expect in-flight requests to stall if the tab is frozen; on return, query the server's offsets rather than trusting in-flight state. A candidate who says "as many as possible" has confused latency with bandwidth; one who says "one at a time" leaves a fast link idle between small files. The answer is a small explicit cap, sized to the link, with the long file given its own lane.

  • Why not upload all 60 photos at once so they finish sooner?
    The same bytes go through the same uplink either way, so the batch does not finish sooner; each photo just finishes later, a drop loses more partial work, and URLs fetched early age while their requests wait. On HTTP/1.1 the browser would queue most of them anyway; on HTTP/2 it would not, which is why the page sets its own cap.
  • On an office laptop with fast broadband, does the same cap hold?
    Raise it. With bandwidth to spare, per-request latency dominates for small photos, so three or four in flight keeps the link busy. Keep the cap explicit rather than leaving it to the browser, because over HTTP/2 the browser's per-host limit no longer applies, and keep the video in its single lane.

A weak uplink is a single-lane road: sending more cars at once does not add lanes, it only makes every car arrive later and puts more of them in the ditch when the road closes.

  • More parallel uploads always finish the batch sooner
  • The browser's per-host connection limit is cap enough, even over HTTP/2
  • Give each file its own unlimited stream of parallel requests
  • Send the 3 GB video as parallel requests under any upload protocol
  • Retries can bypass the concurrency cap because they are urgent