Build it. The database schema, API, code and platform limits for photo backup and file sync are on a separate page: Build it: photo backup and file sync on Android and iOS (18 min read).
How to read this. This page follows a 45-minute round (the length I assume), in order. The schema, REST calls, code and platform tables are in the build guide. The follow-up questions are my reconstruction of challenges that public prep material reports, not transcripts of real rounds.
TL;DR. My answer: an upload is a saved job that can resume, not one request. The server says which blocks (pieces of a file) it lacks, and the phone sends only those. Progress is saved locally, so a killed app loses at most one block. I show "backed up" only after the server confirms the file. On iOS: a background URLSession carries each block as a file upload, and the system decides when it runs. I save my progress in SwiftData or Core Data and recover at the next launch.
Patterns in this round.
- Outbox (an upload is a saved job that can resume)
- Checkpoint (the Memento pattern) (saved progress means a killed app loses at most one block)
More in design patterns in mobile rounds.
Free: one follow-up round a week. A short interview question with a weak and a strong answer, by email. You also get the cheat sheet.
1. Scope and constraints (minutes 0 to 4)
In short: Keep scope to one-way camera-roll backup, and name what the phone does to an upload.
A prompt I would expect: "Design photo backup for our app. Photos and videos from the camera roll should be safe in the cloud." I ask four questions and give a default:
- How much is the phone? The app and its API contract, not the storage servers.
- Which direction? Camera roll to cloud only.
- Which sizes? Photos of 3 to 10 MB, videos up to several GB (my assumption). Wi-Fi and charging by default.
- How many devices? One phone.
| In scope | Out of scope | Parked until you ask |
|---|---|---|
| Camera-roll photos and videos | Sharing and permissions | Any file type, edited later |
| New items go up on their own | Search and face grouping | A second phone writing the same files |
| A state per item: detected, hashing, uploading, backed up, failed | Editing | End-to-end encryption |
| Restore |
The phone can hurt an upload in four ways:
| What the phone does | Requirement at risk | Deep dive |
|---|---|---|
| Kills the app process | An upload loses at most a small piece | Client structure (3), upload (4.1) |
| Stops background work | The backup finishes with the screen off | Running the transfer (4.2) |
| Drops the radio mid-transfer | No lost, doubled or corrupt files | Data and contracts (2), upload (4.1) |
| Runs on battery and a data plan | No cellular or low-battery upload by default | Running the transfer (4.2) |
Your decision. The scope question I expect: "Edits on two phones, and encrypted too." Which do you keep?
First idea, and why it fails. Say yes to both. Two writers need versions and conflict handling from the first commit. Encryption changes what the server can compare. The protocol then changes.
What I would say. Neither yet. I design for one writer.
Say this. "Camera-roll backup, one way, is in. Edits on two phones and end-to-end encryption each change the upload protocol, so I am parking them. Tell me if you want one earlier."
The follow-up question I expect:
"Which comes first?"
Two phones first, encryption last. Each has a cost:
- Two phones: the commit needs a base version (the version the edit started from).
- Encryption: it costs cross-account dedupe (storing identical files once).
45-minute plan
| Minutes | Step | Show by the end | Cut if behind |
|---|---|---|---|
| 0 to 4 | Scope and constraints | Scope list, four phone behaviors | Fewer questions |
| 4 to 14 | Data and contracts | Local database as truth, missing list, numbers | Two numbers |
| 14 to 22 | Client structure | Layers, who owns the upload | One line per layer |
| 22 to 40 | Make the hard part work | Upload drawn, who runs it on each OS | Detection in one sentence |
| 40 to 45 | Break it, ship it, roll it back | Failures, the flag, what I watch | Two failures and the flag |
2. Data and contracts (minutes 4 to 14)
In short: A local database holds the job, and the server owns what is stored.
Your decision. Who knows what is already stored? Pick one: a counter per file in the app, the server alone, or a local database that the app writes and the server corrects.
First idea, and why it fails. Keep an offset (a byte count) per file and add to it as blocks go out. Sometimes the server stores a block but the response is lost. Sometimes the app dies between the send and the save. Then they disagree, and you leave a gap or send a block twice.
What I would say. The local database holds the job: items, blocks and a session (the server's record of one upload in progress). The server owns the truth about what is stored, and the phone asks it. I reject a single byte offset.
The follow-up question I expect:
"The user adds a video that is already in the cloud. Do you send it again?"
No. The tables and REST sketch are in the build guide.
- The phone sends the hashes (short fingerprints) of its blocks.
- The server answers with the blocks it lacks (the missing list).
The contract has four calls:
- Open: size and block hashes in; a session and the missing list out. Asking again returns the current list.
- Put block: one block and its hash. The server refuses a wrong hash.
- Commit: the block list and base version in; the new version out. The same list again returns the same version.
- Changes: a cursor (a saved position) in; cloud changes and the next cursor out.
Arithmetic only where it changes a choice. These numbers are assumptions, not measurements:
| Assumption | Arithmetic | What it settles |
|---|---|---|
| 3,000 photos of 4 MB, uplink 20 Mbit/s | 12,000 MB is 96,000 Mbit, so 4,800 s, about 80 minutes. At 5 Mbit/s it is about 5.3 hours | The first backup takes many runs over several charging periods, newest first |
| A 4 GiB video in 4 MiB blocks | 4,096 / 4 is 1,024 blocks. One lost block is 4 MiB, about 0.1 percent of the file | Per-block state in the database is cheap; a failure never costs the whole file |
| The same 12 GB at 5 Mbit/s in a foreground worker | About 5.3 hours of network time, against the documented 6 hours per 24 for a dataSync foreground service in an app targeting Android 15 or later | Too close once scheduling gaps count, so every run saves its progress and expects a restart |
3. Client structure (minutes 14 to 22)
In short: The app plans the work in a database. The OS scheduler carries it out.
Your decision. Who owns the upload? The ViewModel (it holds the state of one screen), a foreground service kept open for the whole backlog, or the OS scheduler working from the app's database?
First idea, and why it fails. The ViewModel starts the upload, or a foreground service runs the whole backlog. Three things fail:
- A ViewModel is cleared when its owner is destroyed (ViewModel overview). An upload held in memory dies with the process.
- Android answers process death with saved state (saved state).
- A
dataSyncforeground service in an app targeting Android 15 or later is documented to get 6 hours in any 24. Then it has a few seconds to stop (timeouts).
What I would say. The app plans the work and the OS carries it out. Items, blocks and sessions are database rows. Constrained WorkManager jobs run the uploader. WorkManager is Android's background-work library, and its queued work is documented to persist across restarts (persistent work). I reject the other two.
The follow-up question I expect:
"Where does the progress bar get its number?"
From the local database.
- The number is confirmed blocks divided by total blocks.
- Updates run a few times a second at most.
More links
- Sync repository to Transfer scheduler: schedules
- Uploader to Local database: state
- Uploader to Metadata API: commit
In Android's terms, Compose (the UI toolkit) and the ViewModel are the UI layer. SyncRepository is the data layer. The database, change detector and two APIs are its data sources (data layer; Android documentation content from the Android Open Source Project, Apache License 2.0). Three rules:
- The UI observes the database and never touches the network.
- The worker calls the uploader, which lives in the data layer. A Composable or ViewModel never runs it.
- Blocks never change, and each is named by its hash. Metadata says which blocks make which version.
4. Make the hard part work (minutes 22 to 40)
In short: The server lists the blocks it lacks. The phone sends only those, and the OS runs the transfer.
4.1 The upload (minutes 22 to 33)
Your decision. A 4 GB video (example size) waits to upload on a weak connection. Do you send it as one request, as blocks the phone counts, or as the blocks the server says it still needs?
First idea, and why it fails. One request per file from a coroutine. Three things fail:
- The connection drops at 90 percent (example), and the next try starts at zero.
- The app dies, and the progress was only in memory.
- A lost response leaves the app unsure whether the last block arrived.
What I would say.
Say this. "I read the file as a stream and hash each block. I never hold the file in memory. I send the hashes, and the server replies with the blocks it lacks. I upload only those, one PUT for each. I mark a block uploaded only when the server confirms it. A commit with the full block list makes the version visible."
Drive's resumable upload and core tus (an open resumable-upload protocol) both send one continuous stream and resume by offset. I reject blocks counted by the phone, because they cannot skip blocks the server already has. The code is in the build guide.
The follow-up question I expect:
"The user edits the photo after you hashed it."
I hash each block again just before I send it. If the hash differs, the code throws an error, the item goes back to hashing, and nothing is committed.
- A lost commit response is safe. The commit is idempotent: doing it twice has the same result as doing it once.
- Sessions expire: Google's resumable session URIs last one week (Drive uploads).
- On a
404I open a new session. Blocks the server already stored cost nothing. - After a relaunch I reuse the saved session and the same block list, never a new one, so a second commit returns the same version. A new session starts only after a
404. - Blocks may arrive in any order. The commit lists the block hashes in file order, so the order on the wire does not matter.
4.2 Running the transfer (minutes 33 to 40)
Your decision. The user is not looking at the app. What keeps the bytes moving: a service you keep open, a scheduled job with constraints, or the system's own transfer feature?
First idea, and why it fails. Keep a foreground service or coroutine running until the backlog is done. Three things stop it:
- The system ends the service at its limit.
- A constraint can stop the worker mid-run.
- On iOS the system suspends the app.
What I would say.
Say this. "I choose by who started the upload. Automatic backup uses constrained WorkManager jobs, not a service I keep open: unmetered network (usually Wi-Fi), charging, battery not low. A transfer the user starts uses a user-initiated data transfer job (Android 14 and up). Every run saves its progress, so a stop costs one block. On iOS the system owns the transfer and gives no finish time."
The follow-up question I expect:
"How does the app know what is new without scanning the whole library?"
I do not scan. I save a position and ask only for changes after it.
- Android: I save the
MediaStoregeneration number.MediaStoreis Android's shared media database, and the number rises when media changes. I ask for items changed since it. - iOS: I save a persistent change token (a saved position in the change history). At launch I fetch the changes since it.
The follow-up after that: "The user logs out, or switches account, with a backup half done."
- Every item, block and session row stores the account it was made for.
- The uploader checks the current account before each block. It never sends one account's photos to another account.
- On logout I stop the work. I would then ask the user: keep the queue for that account, or delete it.
4.3 Where iOS changes the design
The design is the same, with weaker guarantees. Swift code is in the build guide.
- The system owns the transfer. A background
URLSession(Apple's networking API) continues while the app is suspended. I cannot count on running code between blocks. So I write each block to a temporary file and create several upload tasks. - Force-quit. A force-quit cancels background transfers, and nothing restarts the app. I read my saved state at the next launch and create the tasks again.
- Finding new photos. I save a persistent change token and fetch the changes since it on launch. The change observer only reports while the app runs.
- Photos in iCloud. With iCloud Photos and "Optimize iPhone Storage", the original may not be on the phone. I ask
PHAssetResourceManagerto export it, with network access allowed. This can be slow, so it runs before the upload, not inside it. - Limited access. The user can share only some photos. I back up only those, and the screen says so.
- Newer iOS. iOS 26.1 adds a Photos upload extension for library assets. I know it exists. I would build on a background URLSession first, and check the extension's requirements before relying on it.
5. Break it, ship it, roll it back (minutes 40 to 45)
In short: List how it fails, say what the user sees, and keep a server flag as the kill switch.
| Failure | User sees | Data holds | Recovery |
|---|---|---|---|
| App process dies mid-write | The item still shows uploading, then continues | Item and block states | The worker asks for the missing list again |
| Lost acknowledgement | No change | A block the server may have kept | Ask again; a stored block is not in the list |
| Interrupted large transfer | "Waiting for network" | Per-block states | Resume from the missing list |
| Credential expires mid-operation | Paused, with a reason | Blocks still missing | Refresh the token once, then resume |
| Quota full | "Storage full", paused | Items still waiting | No retry loop; resume when the user frees space |
| Background kill or throttle | A late backup | Block states in the database | The next run catches up |
| Photo deleted, or photo access removed, before upload | "Can't read this photo" on that item | Item row with a failed reason | Mark only that item failed. No retry loop. The other items go on |
| App reinstalled or data cleared | Backup shows catching up | The server still has the stored blocks. The local database is gone | Hash again and send the hashes. The missing list is short, so little is sent again |
| Old app version meets new server contract | Nothing | Old block size | The server accepts both shapes |
Rows not linked to a source are my design choices. Sources are in Further reading.
Release reality:
- A Play staged rollout (a release to a growing share of users) can be halted, but phones with the update keep it (staged rollouts).
- Old clients stay in use, so the server accepts both protocols until old traffic is small.
- A new block size ships behind a server flag, with the old path kept in the app. In my design that flag is the kill switch, the only rollback that reaches installed apps.
- In my view, a flag cannot turn off a local database migration. It needs a format that is safe to downgrade, or it ships forward-only with the flag off by default.
Say this. "I cannot recall a bad build, so the rollback is the flag plus a fixed build. I would watch completion rate, bytes sent again, duplicate files and battery complaints. Left out: sharing, search, encryption."
6. Follow-ups that change a constraint
In short: Each follow-up changes one constraint. A strong answer names what breaks and the fix.
These are practice prompts, not claims about interviewers.
- A 4 GB video (example size) over a connection that drops every few minutes. Strong: only missing blocks go up, state is per block, each run saves progress, and the user sees a reason, not a stuck bar. Weak: "retry the upload."
- Any file type, edited later. Strong: a file is a list of blocks per version, and an edit commits against the version it started from. Fixed blocks shift when bytes are inserted, so name content-defined chunking (cutting blocks by content, not position) as the cost. Weak: "upload the file again."
- Two phones edit the same file offline. Strong: the commit carries
baseVersion. A newer server version returns409, and I keep both as a conflicted copy. Weak: "last write wins." - End-to-end encryption. Strong: encrypt before upload and name what breaks: cross-account dedupe, thumbnails, server search, key recovery. Weak: "encrypt the file first."
- After release, duplicate-file reports rise for some users. Strong: switch the flag to the old path, pause the staged release, ship a fix. Weak: "roll back the release."
- The backend wants a new block size. Strong: old versions stay in use, so the server speaks both shapes. Dedupe across sizes is lost, and I say so. The flag moves users in steps. Weak: assuming everyone updates.
7. What changes by level
In short: Levels differ in who raises the problem, and whether a rollout plan comes with it.
These levels are my own reading, drawn from vendor and prep material (courses and books). They are not any company's rubric.
- Mid-level: a WorkManager upload with retry. I want to hear: "The upload is a job that retries and runs only on Wi-Fi."
- Senior: a missing list owned by the server, block hashing, constant memory, and what each OS will not run in the background. I want to hear: "The server owns what is stored, so a lost acknowledgement costs one block."
- Staff: conflicts across devices, dedupe against encryption, metrics, and a block-size rollout that old clients survive (staff guide). I want to hear: "I would ship the new block size behind a server flag and keep the old path until old clients disappear."
Common weak answers. Ten minutes on storage when the question was the phone. Only the happy path. A ViewModel coroutine doing the upload. Showing "backed up" before the server confirmed. No kill switch. Reading the whole file into memory.
Staff answer: the decision and the rollout
Decision: share the protocol first. Write one spec for sessions, missing blocks, commit and conflicts, with tests that both uploaders must pass. Share code through Kotlin Multiplatform only if duplicated bug fixes are measured to cost more.
Alternative: one shared engine from day one.
Revisit trigger: the same sync bug fixed twice in a quarter, or a second app needing behavior the contract cannot express. See the native vs cross-platform guide.
Rollout: the flag from section 5, then a staged release. Guardrail: no rise in data-loss, duplicate-file or battery complaints.
What I read and what is my view: I read the Android background cap, the session lifetime and the Apple force-quit behavior in the official docs. The ownership model, protocol rule, metrics, assumed numbers and level signals are my opinion.
Test yourself
In short: Seven questions from this case. Answer each one out loud first, then open the answer.
1. Who knows what is already stored, and why not a byte offset in the app?
The local database holds the job, and the server owns the truth about what is stored. A byte offset breaks when the server stores a block but the response is lost, or the app dies between the send and the save. They disagree, and you leave a gap or send a block twice.
2. The user adds a video that is already in the cloud. Do you send it again?
No. The phone sends the hashes of its blocks, and the server answers with the blocks it lacks. If it lacks none, nothing is sent.
3. Who owns the upload, and why not a foreground service?
The app plans the work in a database and the OS scheduler carries it out, with constrained WorkManager jobs. A ViewModel dies with the process. A dataSync foreground service on Android 15 or later gets 6 hours in any 24 and then must stop.
4. The user edits the photo after you hashed it. What happens?
Each block is hashed again just before it is sent. If the hash differs, the code throws an error, the item goes back to hashing, and nothing is committed.
5. A commit response is lost. Is it safe to send the commit again?
Yes. The commit takes the block list and a base version, and the same list again returns the same version. It is idempotent.
6. How does the app know what is new without scanning the whole library?
It saves a position and asks only for changes after it. On Android that is the MediaStore generation number.
7. On iOS, the user force-quits the app during a backup. What happens to the uploads?
A force-quit cancels the background transfers, and nothing restarts the app. At the next launch I read my saved state and create the upload tasks again.
Further reading (official docs)
- Build it: photo backup and file sync on Android and iOS: schema, REST, code and platform limits for this case
- Data layer: repositories, data sources and work lifetimes (Android)
- Offline-first apps: write strategies and sync (Android)
- Task scheduling and WorkManager (Android)
- Foreground service timeouts, including dataSync (Android)
- Staged rollouts (Google Play Console help)
- Manage uploads and resumable uploads (Google Drive API)
- Resumable upload protocol (tus)
- URLSessionConfiguration background(withIdentifier:) (Apple)
- PHAssetResourceUploadJob (Apple)
Words on this page (15)
- Acknowledgement
- A short reply that says the server got a message. If this reply is lost, the app does not know, so it sends the message again.
- Coroutine
- A light background task in Kotlin. It can pause and continue later without blocking a thread.
- Cursor
- A saved place in a list. The server gives it to the app, and the app sends it back to get the next part.
- Dedupe
- To keep only one copy of the same item. For example, a message that arrives twice is stored once.
- Foreground service
- An Android service that shows a notification while it works. The system is less likely to stop it.
- Hash
- A short code made from the bytes of a file. Apps compare the codes to see if two files are the same.
- Idempotent
- Doing it twice has the same result as doing it once. This makes a retry safe.
- Kill switch
- A remote flag that turns a feature off at once. It is the one rollback that reaches apps that are already installed.
- Process death
- The system ends the process of your app to free memory. Anything that is only in memory is lost.
- Repository
- The class that reads and writes data for the rest of the app. It hides whether the data comes from the network or the database.
- Resumable upload
- An upload that can continue after a break. It does not start again from the first byte.
- Rollback
- Going back to the old behavior after a problem. A build on a user's phone cannot be taken back, so teams use a kill switch.
- Staged rollout
- A release to a growing share of users, not to everyone at once. It limits the harm of a bad release.
- ViewModel
- A class that holds the state of one screen. It survives a screen rotation.
- WorkManager
- Android's tool for background work that must run later. The work survives when the app closes or the phone restarts.
What I checked and what I did not
- I read the Android pages for data layer, WorkManager, foreground-service timeouts (including dataSync) and staged rollouts. They support the 6 hours in any 24 for dataSync on Android 15 and later.
- I read the Google Drive resumable upload page and the tus protocol. Drive sessions last one week.
- I read the Apple pages for background URLSession and for the Photos upload job. Apple says a force-quit cancels background transfers.
- The block-per-PUT session and the missing list are my own design. Drive and tus resume by byte offset. I tested the design against no real server.
- The numbers are my own assumptions (3,000 photos, 4 MB each, 20 Mbit/s, 4 MiB blocks). I rechecked the sums.
- I did not re-read the Android 14 photo access page or the Apple page on BGProcessingTask for this version.
- I did not verify the Photos upload extension requirements on iOS 26.1.
- No iOS engineer has reviewed the iOS parts yet.
- The follow-up questions and level descriptions are my reading of public prep material. They are not real transcripts or a company rubric.
Questions or corrections?
Add them to the discussion thread for this case on GitHub. To post, you need a free GitHub account. What you write there is public and follows GitHub's terms. Good answers are added to this page.
Keep reading
Get the free one-page cheat sheet
One page: the five steps, a 45-minute time plan and two checklists. Print it or keep it on your phone.
We email you the cheat sheet after you confirm your address. You can also open it now from the Start here page. You also get a short email each week with a follow-up round, and a note when a new case is published. Unsubscribe any time. Privacy.