Multi-Device Playback Progress Sync: From Data Model to Consistency
"Continue watching" across a phone, a living-room TV, and a tablet looks trivial on the surface, but at scale it forces three hard questions: where to store progress, how to write it correctly when requests arrive out of order, and how to read it fast while keeping every device consistent. This article walks through a practical design. It starts with a unified progress model that covers long videos, episodic series, and text/image content through a single structure. It then details the write path, combining client-side throttling with server-side idempotent, monotonic updates, and the read path, built on layered caching and clear multi-device conflict-resolution rules. It also covers guest-to-account merging, content-version changes, capacity and sharding, observability, and privacy compliance, and closes with a launch checklist. By the end, you will understand how to keep playback position accurate, writes affordable, merges correct, and reads fast at millions-of-users scale.
1. Problem Definition: Why “Continue Watching” Is Hard to Get Right
A user watches an episode of a short drama on their phone during a commute, fast-forwards through a scene, then pauses and rewinds. At home they open the TV and keep watching. Later, when they switch to a tablet, the content should land exactly where they left off, not just at the start of the episode. This seemingly simple “pick up where I left off” feature raises at least three engineering questions:
- Where to write: Should a progress record be keyed by user, by content, or by device? Can different content formats (video, episodic series, text/image or comics) share one model?
- How to write it correctly: When requests arrive out of order on a weak network, when a user is active on multiple devices at once, and when client clocks are unreliable, how do you guarantee that the surviving record is the correct one?
- How to read it fast: Opening a home page or a detail page may require reading many progress records at once. How do you keep latency low while staying consistent across devices?
The difficulty comes from three angles:
- Progress is multi-dimensional: watch position, completion status, last-update time, and content version are all needed. Storing a single “position” field quickly becomes limiting.
- Writes are high-frequency: a single viewing session of a long video generates many heartbeat reports, and the write volume becomes substantial once you multiply by a massive user base.
- Reports are asynchronous: network latency and retries cause out-of-order arrivals, so “the request that arrives later is not necessarily the newer state.”
The core of progress sync can be summed up in four phrases: unified model, disciplined writes, idempotent merging, and locality of reads. The rest of this article expands on each.
2. A Unified Progress Model: One Structure for Many Content Formats
2.1 Abstracting “Content Positioning”
Different content types have inherently different units of progress:
| Content type | Progress unit | Typical read behavior |
|---|---|---|
| Single long video | Playback milliseconds | Convert to a percentage of total duration and seek to the corresponding time point |
| Episodic short drama / series | Episode number + playback ms within the episode | Show “watched up to episode X”; on resume, seek within that episode |
| Text/image / comics | Chapter + page index | Show a reading-progress percentage; on resume, jump to the corresponding page |
Rather than building a separate table for each type, it is more sensible to abstract three shared concepts:
- Position value (
position_value): an integer that is monotonically comparable within that content type, such as playback milliseconds, page index, or a running sequence number. - Completion ratio (
progress_ratio): a decimal between 0 and 1 derived from the position value and the total content length, used for cross-format display. - Status: in progress or completed.
2.2 Why You Cannot Store Only a Percentage
A percentage is convenient to display, but it is not suitable as the single source of truth:
- Precision loss: 1% of a long video can be several seconds or even tens of seconds, so resuming from a percentage causes a noticeable regression in experience; for a short clip, 1% may be less than a single frame.
- Invalidated by content changes: once content is re-edited or replaced, an old percentage points to an entirely different location.
- Cannot judge progress direction: you cannot tell which report corresponds to a further-along watch position.
The recommendation is therefore “position value as primary, ratio as secondary,” and each record should carry a content version number.
2.3 Example Data Model
Using the user–content pair as the primary key guarantees that a given user has exactly one progress record for a given piece of content:
CREATE TABLE content_progress (user_id BIGINT NOT NULL COMMENT 'User ID; guest mode uses a temporary identifier',content_id VARCHAR(64) NOT NULL COMMENT 'Unique content identifier',content_type TINYINT NOT NULL COMMENT 'Content type: 1-video, 2-episodic series, 3-text/image',position_value INT NOT NULL COMMENT 'Position value within the content, e.g. playback ms or page index',progress_ratio DECIMAL(5, 4) NOT NULL COMMENT 'Completion ratio, 0~1',status TINYINT NOT NULL DEFAULT 1 COMMENT '1-in progress, 2-completed',content_version INT NOT NULL DEFAULT 0 COMMENT 'Content version the report is based on',device_id VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'Device identifier of the most recent report',updated_at BIGINT NOT NULL COMMENT 'Server-side write timestamp (ms)',client_time BIGINT NOT NULL COMMENT 'Client-side report timestamp (ms)',PRIMARY KEY (user_id, content_id),KEY idx_user_updated (user_id, updated_at));
Design notes:
- Primary key
(user_id, content_id): naturally supports range scans for “a user’s recently watched items” and shards cleanly by user, which makes later horizontal scaling easier. - Store only the final state: each report does not need to be appended as a log, otherwise the data volume grows linearly with the number of heartbeats.
- Keep
content_version: after content changes, this lets you decide whether the old progress can still be reused.
If you need to audit “watch-behavior traces” (for example, completion-rate analytics), write the key events to a data warehouse through an asynchronous message pipeline, rather than piling up logs in the progress table.
3. Write Path: Client Throttling + Server Idempotency
Progress data is inherently asynchronous and eventually consistent: the client does not have to wait for server acknowledgment before playing, and the server does not have to block a user from switching devices. The design should split this path into four stages: client collection → throttled reporting → idempotent write → read-model refresh.
3.1 Client: Throttled Reporting with a Local Fallback
If every playback heartbeat triggers a request, a single 30-minute session can generate hundreds of writes. The common approach is to throttle on both a time and a progress threshold:
- A fixed minimum interval must elapse since the last report (e.g., 15 seconds);
- The position must have advanced by at least a certain ratio since the last report (e.g., 5%);
- Report immediately when playback ends or when progress rewinds by more than a set amount;
- Force a report on pause, when the app goes to the background, when the page unloads, or when content is switched.
Example code:
class ProgressTracker {static final long THROTTLE_INTERVAL_MS = 15_000; // Minimum report intervalstatic final int PROGRESS_STEP = 5; // Progress-change threshold (percentage points)static final int COMPLETION_PERCENT = 97; // Ratio considered as completedfinal ProgressSink sink; // Report channelfinal ProgressStore store; // Local persistenceString contentId;int contentType;long total; // Total duration (ms) or total page countint lastSentPercent = -1;long lastSentAt = 0;void onTick(long position, long now) {boolean isLast = isLastPosition(position, total);if (isLast) {position = total; // Normalize to the endpoint to avoid getting stuck at 99%}int percent = (int) (position * 100 / Math.max(total, 1));if (isLast || percent >= COMPLETION_PERCENT) {percent = 100;}store.saveLocal(contentId, position, percent, now); // Persist locally first to guarantee the resume point is never lostboolean intervalReady = now - lastSentAt >= THROTTLE_INTERVAL_MS;boolean progressReady = Math.abs(percent - lastSentPercent) >= PROGRESS_STEP;if (isLast || (intervalReady && progressReady)) {// Enqueue to a pending queue first, then submit asynchronously; network failure won't affect the local recordstore.enqueue(new ProgressReport(contentId, contentType, position, percent, now));lastSentAt = now;lastSentPercent = percent;}}void flush() { // Call on pause, on entering background, or when switching contentstore.flushPending();}}
The client also needs two more strategies:
- Read local first: on launch or when entering a detail page, prefer reading local progress; render the first screen using the local value, then fetch server data asynchronously and decide whether to jump based on the merge rules.
- Local as fallback: when the network is unavailable, reporting tasks go into a local pending queue and retry with exponential backoff after the network recovers (e.g., 1s, 2s, 4s, capped at around 30s). This avoids both “watched for half an hour offline and lost all progress” and a request storm the moment a server-side failure recovers.
3.2 Server: Idempotent Writes and Monotonic Overwrite
The core problem on the server side is that multiple reports may arrive out of order, and the final state must not “regress” because of arrival order.
Step 1 — Generate an idempotency key. Each time the client decides to report, it generates a globally unique request ID (e.g., request_id) and sends it with the request. The server deduplicates on (user_id, content_id, request_id) to prevent client retries from being processed twice.
Step 2 — Use a unified clock baseline. A client’s system time may be manually altered by the user, or skewed by timezone settings, so when deciding what is newer, use the server’s receive time. Client time is only a reference; when the offset exceeds a threshold (e.g., 5 minutes), fall back to server time directly.
Step 3 — Monotonic overwrite. When the database natively supports atomic upsert, a single statement can perform “insert or conditional update,” avoiding the race that comes with “read, then write”:
-- Overwrite progress only when no record exists, or the new report is not older than the existing oneINSERT INTO content_progress(user_id, content_id, content_type, position_value, progress_ratio,status, content_version, device_id, updated_at, client_time)VALUES(:user_id, :content_id, :content_type, :position, :ratio,:status, :content_version, :device_id, :now, :client_time)ON DUPLICATE KEY UPDATEposition_value = IF(VALUES(client_time) >= client_time,VALUES(position_value), position_value),progress_ratio = IF(VALUES(client_time) >= client_time,VALUES(progress_ratio), progress_ratio),status = IF(VALUES(client_time) >= client_time,VALUES(status), status),content_version = IF(VALUES(client_time) >= client_time,VALUES(content_version), content_version),device_id = IF(VALUES(client_time) >= client_time,VALUES(device_id), device_id),updated_at = IF(VALUES(client_time) >= client_time,VALUES(updated_at), updated_at),client_time = IF(VALUES(client_time) >= client_time,VALUES(client_time), client_time);
If the database does not support atomic upsert, you can use a “read-compare-write” approach. The key is that the conditional update itself must execute atomically: when the condition is not met, the write is simply a no-op, rather than checking first and then overwriting unconditionally:
-- Current progress already read as :currentPosUPDATE content_progressSET position_value = :newPos,progress_ratio = :newRatio,status = :newStatus,device_id = :deviceId,updated_at = :now,client_time = :clientTimeWHERE user_id = :userIdAND content_id = :contentIdAND position_value = :currentPosAND client_time <= :clientTime;
The tradeoff here is: allow the position to stay equal or advance, but reject any regression. When a user manually drags the progress bar back to rewatch, they expect the rewatch position to be preserved, so these reports should not be discarded outright. You can introduce a “rewind window” rule: allow the overwrite only when the new report time is clearly later than the existing record and the position rewinds by more than a threshold (e.g., 10%).
3.3 Manual Seeking vs. Natural Playback
Two sources of progress must be distinguished:
- Natural playback: the user advances passively, so reports can be batched under the throttling policy.
- User-initiated seeking or page-flipping: this reflects genuine viewing intent and should be reported immediately, and it should record only the single valid end position, not every “waypoint” along the range.
Otherwise, when a user drags from 30% straight to 90% and then back to 20%, the intermediate range produces a flood of bogus progress records that waste writes and pollute downstream recommendation logic.
For completion detection, the recommendation is to introduce the notion of “effective watching”: mark content as completed when the progress reaches the end and effective play time reaches a certain ratio (e.g., 90%) of the total duration. Merely dragging to the end does not count as completion. This prevents accidental taps from batch-marking episodes as “watched.”
4. Read Path: Latency, Consistency, and Conflict Resolution
4.1 The Read Model
The “Continue Watching” strip on the home page and “Last watched” on the detail page are both essentially queries for the most recent N progress records, so an index like idx_user_updated is indispensable. Reads generally span three layers:
- Local cache: millisecond response, guaranteeing a resume point even on cold start.
- Distributed cache: caches a user’s recent watch list, invalidated or refreshed on write.
- Persistent storage: the source of truth when the cache misses, fronted by multi-level caching.
It is also worth separating reads from writes: writes go to the primary, reads go to read-only replicas. But be aware that primary-replica replication has a short lag, so a user switching devices may read stale progress. For entries with high consistency requirements (such as an explicit click on “Continue Watching”), you can set an extremely short dual-read verification window, or synchronously refresh the cache after a successful write.
4.2 Multi-Device Conflict Resolution
When a phone and a TV are both active at the same time, their reports will arrive alternately. Resolve by the following priority:
- Time first: the most recent valid operation wins, i.e., “where the user most recently stopped.”
- Status first: if either device has completed, the content is considered completed.
- Equal-weight conflict: if timestamps are identical (e.g., within the same second), take the larger progress, so the result stays reproducible.
- Conflict marking: for high-frequency alternating reports, additionally record the “most recently active device,” so you can show a hint like “last watched on device X.”
4.3 Merging Guest and Logged-In States
Users often try the product while logged out and only bind an identity after signing in. The recommended merge rules are:
- The account’s primary progress wins: after login, prefer the progress already stored under the account.
- Guest progress as fallback: if the account has no record, import the guest’s most recent progress.
- Preserve guest history: keep the remaining guest records under the guest identifier for later content-operations analysis, but they no longer participate in the user’s resume flow.
The merge operation must also be idempotent, to prevent duplicate imports caused by repeated logins or client retries.
4.4 Content-Version Changes
If content is re-edited, or an entire title is replaced, the old progress may have become meaningless. Recommended handling:
- Record the content version the report was based on;
- When the current version differs from the recorded version, show a prompt such as “Content has been updated. Start over?” and let the user decide;
- For simple page reordering, do an approximate mapping based on “chapter + relative position within the page.”
5. Engineering Safeguards: Capacity, Observability, and Privacy
5.1 Capacity and Sharding
The progress table is a classic “large table, small rows” structure, and its size is driven by the total amount of content rather than by the popularity of any single item. For scaling:
- Shard by a hash of
user_id, so a user’s reads and writes land on the same shard, avoiding cross-shard transactions; - Migrate cold data (e.g., not updated for over a year) to object-storage archival;
- After hot/cold separation, the online store keeps only the progress of active users.
5.2 Observability
At minimum, watch these metrics:
- Report success rate and report P99 latency;
- Rewind-rejection rate (the proportion rejected by the monotonic-overwrite rule); a sudden spike usually indicates a client clock anomaly or replayed requests;
- Cache hit rate for progress reads;
- The distribution of “position drift” after a device switch (e.g., the difference between the actual position after switching and the server-recorded position).
Pair these with structured logging and distributed tracing to stitch together the full path of a single progress write.
5.3 Privacy and Compliance
Watch records are user-behavior data, so handle them following the principle of data minimization: collect only the fields strictly necessary for the feature; clearly state the purpose in the privacy policy; give users an entry point to view and delete their data; and set a reasonable retention period.
6. Leveraging General Cloud-Platform Capabilities
None of the above requires building every piece of infrastructure from scratch. You can rely on the general-purpose capabilities offered by cloud platforms to carry each layer:
- Use a container platform to deploy the stateless access layer and business services, scaling elastically with load;
- Use a message queue to absorb asynchronous events, smoothing out traffic peaks and driving progress roll-ups;
- Use object storage to archive historical progress data and relieve pressure on the online store;
- Use logging services and monitoring/alerting to cover the critical path, so reporting anomalies are caught quickly.
For example, general-purpose products from Baidu AI Cloud, such as containers, message queues, object storage, and logging and monitoring/alerting, can serve as the foundation for a progress-sync service, letting teams focus their energy on the experience and the strategy themselves.
7. Launch Checklist
- Model: Are the position value and completion ratio separated? Is the content version recorded?
- Writes: Is there throttling? Is there a local pending queue? Are writes idempotent? Is progress regression prevented?
- Reads: Is there local caching and multi-level caching? Can reads be affected by replication lag?
- Conflicts: Is there a clear merge priority? Can guest and logged-in states be merged smoothly?
- Operations: Is there a complete dashboard of core metrics with anomaly alerts?
- Compliance: Is there a view-and-delete entry point? Is the data-retention policy clear?
8. Conclusion
The value of multi-device progress sync lies not in how complex the technology itself is, but in making users not feel its presence: no searching when they switch devices, no thinking when they open the app, and content that opens straight to the position they left. The key to achieving this is to describe progress with a unified model, control cost with disciplined writes, guarantee correctness with idempotent merging, and defend latency with layered reads. Get these four things solid, back them with thorough monitoring and compliance mechanisms, and you can deliver a stable, trustworthy cross-device experience at a scale of tens of millions of users.
