Cross-Device Playback Progress and Interaction State Synchronization Architecture

    This article describes a general architecture for synchronizing playback progress, interaction states, and message updates across multiple devices. It examines out-of-order writes, conflict merging, idempotency, read-model projection, inbox/outbox messaging, session governance, and observability, and summarizes design rules for eventual consistency and a stable cross-device experience.

    Cross-Device Playback Progress and Interaction State Synchronization Architecture

    In video, audio, course, and content-community applications, a continuous experience across multiple devices has become a baseline capability: users can continue content on a tablet or web page after watching part of it on a phone; favorites, comments, bullet comments, likes, and message states under the same account should be as consistent as possible; and first-time registration, login renewal, device switching, and session security also need stable support. On the surface, these are separate feature points. Behind them, however, is a set of technical problems involving account systems, state consistency, event synchronization, conflict merging, idempotent deduplication, message aggregation, and observability.

    This article does not focus on any specific platform or product. Instead, it abstracts “multi-device synchronization of playback records, interaction states, and message updates” into a general technical solution and discusses how to build a low-latency, scalable, and operable cross-device state synchronization architecture.

    1. Problem Breakdown: Why Multi-Device Synchronization Is Hard

    The core contradiction in multi-device state synchronization is “multiple write sources + multiple read endpoints + weak network + eventual consistency.” Typical challenges include:

    1. Out-of-order writes: A user plays to 10 minutes on device A, while device B, due to offline caching, only syncs to 8 minutes. The time events arrive at the server may not match the time they actually occurred.
    2. Conflict merging: When the same account operates on favorites or playback progress on two devices at the same time, it is necessary to define whether timestamps, version numbers, or business priorities take precedence.
    3. Idempotency and retries: Clients may repeatedly report the same event when the network fluctuates, and the server must ensure that duplicate requests do not cause state jumps.
    4. Read-heavy and write-heavy workloads: Playback records are read frequently, interaction states are written frequently, and message notifications also require aggregation and deduplication. A single storage system is unlikely to satisfy all of these needs at once.
    5. Multi-device session security: Login states need to be managed at the device dimension, with support for active logout, anomaly detection, and token renewal.
    6. Insufficient observability: Without tracing, metrics, and logs, it is difficult to locate “why a certain device did not sync to the latest state.”

    Therefore, architecture design should not focus only on a single API. It should be organized around “event-based synchronization + state storage + read-model projection + idempotency governance.”

    2. Overall Architecture: Event-Driven Design with Read-Model Separation

    A layered approach is recommended:

    • Access layer: Handles authentication, rate limiting, parameter validation, and device identifier parsing.
    • Command layer: Receives write operations such as playback progress, comments, bullet comments, favorites, likes, and message-read events, and generates events with version numbers.
    • Event channel: Decouples writes from downstream consumption through a message queue, supporting peak shaving, retries, and multiple consumers.
    • State storage: Relational databases store strongly consistent data such as accounts, content, and permissions; distributed caches store high-frequency read states; object storage stores large text or attachments; logging services and monitoring and alerting provide observability.
    • Read-model layer: Builds query-oriented projections for scenarios such as “continue playback,” “my favorites,” “message center,” and “feed list.”
    • Push layer: Pushes change notifications to other devices through long connections or polling, and clients then pull the latest state on demand.

    For deployment and operations, teams can combine general-purpose capabilities such as message queues, logging services, and monitoring and alerting (for example, from Baidu AI Cloud) to build elasticity and observability. The specific choice should be evaluated against team constraints, and the architecture should not be bound to a single product capability.

    3. Playback Progress Sync: Versions, Timestamps, and Merge Strategy

    A playback record usually includes the user, content, episode or chapter, playback position, total duration, update time, device identifier, and version number. The synchronization strategy can be divided into three steps:

    1. Client-side local recording: When offline, write locally first and mark the record as pending synchronization.
    2. Idempotent server reception: Use userId + mediaId + episodeId + deviceId + eventId as the idempotency key, and return the existing result directly for duplicate events.
    3. Merge rules: Do not simply let “later arrivals overwrite earlier arrivals.” It is recommended to use “business timestamp + monotonic version number + progress sanity check.” For example, if the same content advances to 10 minutes on one device and 8 minutes on another, and the business timestamps are close, the larger progress can be chosen. If one device’s progress clearly moves backward without a “restart playback” event, the old value should be retained.

    The following illustrative pseudocode expresses only the logic, not a concrete API:

    1. function syncPlaybackProgress(cmd):
    2. key = hash(cmd.userId, cmd.mediaId, cmd.episodeId, cmd.deviceId, cmd.eventId)
    3. if idempotentStore.exists(key):
    4. return idempotentStore.get(key)
    5. current = stateStore.get(cmd.userId, cmd.mediaId, cmd.episodeId)
    6. if current == null:
    7. next = buildState(cmd)
    8. else if cmd.businessTime < current.businessTime and cmd.position <= current.position:
    9. next = current
    10. else if cmd.position > current.position:
    11. next = merge(cmd, current)
    12. else:
    13. next = mergeByVersion(cmd, current)
    14. stateStore.saveWithVersion(next, expectedVersion=current.version)
    15. eventBus.publish("playback.changed", next)
    16. idempotentStore.put(key, next)
    17. return next

    The key points are: version numbers are used for concurrency control, business timestamps are used for out-of-order judgment, event IDs are used for idempotency, and progress sanity checks are used to prevent abnormal jumps.

    4. Interaction States: Separate Handling for Comments, Bullet Comments, Favorites, and Likes

    Interaction states have different consistency requirements. Comments and bullet comments usually allow eventual consistency but require moderation, folding, pagination, and sorting. Favorites and likes require fast feedback while preventing duplicate counting. A “write events + read projections” approach is recommended:

    • The write side records raw events to ensure traceability;
    • The read side builds projection tables by content dimension or user dimension;
    • Count-based states use “event deduplication + incremental aggregation” instead of direct overwrite;
    • List-based states use cursor pagination to avoid deep pagination;
    • High-frequency interactions have rate limiting and risk-control rules, but the rules should be configurable.

    For example, favorite state can maintain two read models: user_favorite and content_favorite_count. The former serves “whether I have favorited this,” and the latter serves “total favorites.” Both are updated by the same event and are allowed to be eventually consistent for a short period.

    5. Messages and Feeds: Inbox, Outbox, Aggregation, and Deduplication

    Common problems in message centers include “duplicate notifications, disordered sequence, and inaccurate unread counts.” An outbox and inbox model can be used:

    • Outbox records business events such as replies to comments, content updates, and system notifications;
    • Inbox writes message indexes by user dimension and supports read, delete, and aggregation;
    • Use a unique message key for deduplication, such as userId + bizType + bizId + actorId;
    • Unread counts use an independent count projection, with compensation jobs for periodic calibration;
    • Feed lists are projected by timeline, combined with caching and pagination strategies.

    The push layer is only responsible for “indicating that something has changed” and does not carry full state transmission. After clients receive the indication, they pull on demand. This reduces pressure on the push channel and avoids reliability issues caused by large message bodies.

    6. Account Sessions and Multi-Device Login: Device-Level Governance

    The prerequisite for a multi-device experience is secure and reliable account sessions. It is recommended to include user, device, session, and expiration information in tokens, and for the server to maintain a device session table that supports active logout, abnormal login detection, and token rotation. The first-time registration flow should be idempotent to avoid duplicate submissions creating multiple accounts. Login-state renewal should be rate-limited, and sensitive operations should require secondary verification.

    7. Observability and Disaster Recovery: Making Sync Issues Traceable

    At least three types of observability capabilities should be built: metrics (sync latency, failure rate, duplicate rate, unread deviation), logs (event ID, user ID, device ID, version number), and tracing (from reporting to read-model update). Alerts and compensation tasks should be set for critical synchronization paths, and state storage and read models should be compared periodically. After deviations are found, they should be automatically repaired or escalated for manual intervention.

    8. Conclusion

    Multi-device playback progress and interaction state synchronization is not a single-endpoint problem. It is a consistency engineering problem built around events, state, and read models. Through event-based writes, version control, idempotent deduplication, conflict merging, the inbox model, and observability, a stable experience can be achieved under weak networks and multiple devices. Architecture implementation should be driven by business priorities: playback progress pursues continuity, interaction states pursue eventual consistency, message notifications pursue deduplication and explainability, and account sessions pursue security and controllability.