High-Concurrency Video Platform Architecture: Login, State Sync, and Content Delivery

    This article presents a reference architecture for high-traffic video platforms, covering stateless login and authentication, eventually consistent playback progress sync across devices, separate pipelines for danmaku and comments, multi-tier content distribution, observability, and security. It is written from a vendor-neutral perspective, using generic cloud capability categories such as object storage, message queues, container platforms, logging, and monitoring.

    High-Concurrency Video Platform Architecture: Login, State Sync, and Content Delivery

    1. Background and Problem Definition

    Content platforms show a clear tidal traffic pattern: evenings, live events, and product launches create short, sharp peaks. At the same time, login, playback progress sync, and interactive comments are tightly coupled. If the architecture only optimizes isolated features, peak periods bring login queues, lost progress, and delayed comments. This article abstracts a reference architecture from a general technical perspective, covering identity authentication, state synchronization, real-time interaction, and content delivery.

    Note that this article does not target any specific vendor product. Cloud capabilities are described as generic categories, such as object storage, message queues, container platforms, logging services, and monitoring and alerting.

    2. Login and Authentication: From Single-Node Sessions to Stateless Tokens

    2.1 Why Traditional Sessions Do Not Scale Horizontally

    Early systems often kept sessions in the memory of a single machine. Once the service scales to multiple instances, a user request landing on a different instance loses the login state. There are two common fixes: store sessions in a distributed cache, or use stateless tokens that encode identity claims in the token itself and are verified server-side with a public key.

    2.2 Implementation Details of the Token Approach

    A stateless token (such as the industry-standard JWT structure) consists of a header, a payload, and a signature. Key concerns when rolling it out:

    • Layered expiry: short-lived access tokens and long-lived refresh tokens reduce exposure if a token leaks;
    • Key rotation: signing keys should support multiple versions coexisting, so rotation does not log everyone out at once;
    • Logout semantics: stateless tokens are naturally hard to invalidate immediately, so a revocation list or an incrementing version number can be introduced.

    Illustrative code (pseudocode, expressing the flow only):

    1. Login:
    2. verify(account, password_hash)
    3. access = sign({uid, scope, exp: now+15min})
    4. refresh = sign({uid, exp: now+30d})
    5. Return access, refresh
    6. Request verification:
    7. payload = verify(access)
    8. if payload.uid in revocation_list: reject

    2.3 Peak Management for Login

    Login often depends on external services such as SMS or CAPTCHA verification, making it the most fragile step under peak load. A message queue can absorb the spike asynchronously, moving non-real-time work such as verification, risk-control sampling, and log persistence off the critical path. Login endpoints should also be rate-limited by tier, prioritizing playback requests from already logged-in users.

    3. Multi-Device Sync: Eventual Consistency for Playback Progress

    Syncing playback records across devices is a typical high-write, low-latency-tolerance scenario. A user watches halfway on a phone, switches to a tablet, and expects the progress error to stay within seconds.

    3.1 Data Model

    Progress records should be written per (user, content, device) dimension, with a separate aggregated “latest progress” view. Writes use an append-only event stream, and the aggregated view is updated through incremental computation, which naturally supports replay and correction.

    3.2 Consistency Strategy

    • The client persists locally first, then reports asynchronously, so network jitter does not interrupt viewing;
    • The server resolves conflicts using timestamps and version numbers, keeping the newer progress;
    • Readers tolerate brief staleness; eventual consistency is enough for the experience.

    3.3 Hot and Cold Tiering

    Historical progress is cold data and can move to object storage with low-frequency access; recently active progress stays in cache or high-performance storage. Tiering controls cost while keeping the hot path low-latency.

    4. Real-Time Interaction: Peak Shaving and Ordering for Danmaku and Comments

    Danmaku is high-volume, short, and tolerant of slight reordering; comments require strong consistency and traceability. The two should use different pipelines.

    4.1 Danmaku Pipeline

    Clients batch messages by time window. The server buffers them in a message queue, consumes them in parallel by partition, and broadcasts through a long-lived connection push channel. The partition key can be the content identifier, keeping danmaku for the same content relatively ordered.

    4.2 Comment Pipeline

    Comment writes pass through content safety review and rate limiting; only after a successful write do counter updates and notifications trigger. Counter updates create hotspots, which can be eased with bucketed counters plus periodic aggregation.

    1. Danmaku: client batch -> access layer -> message queue (partitioned by content) -> consume -> push
    2. Comment: client -> review -> persist -> bucketed counter -> periodic aggregation

    5. Content Delivery: Storage, Cache, and Origin Fetch

    The core of distributing video and image-text content is “close to the user, few origin fetches.”

    • The origin uses object storage for original files, addressed by content identifier;
    • Edge cache nodes serve hot content and fetch from origin on a miss;
    • Hotspot detection relies on real-time statistics from access logs, with proactive pre-warming for sudden spikes;
    • Transcoded outputs are stored by quality level, and clients adaptively select based on network conditions.

    For origin fetch strategy, request coalescing (single-flight) is recommended so that a single hot object expiring in cache does not overwhelm the origin.

    6. Observability and Stability

    Without measurement there is no optimization. Build three lines together: logging, metrics collection, and monitoring and alerting.

    1. Logging: structured records of login success rate, progress report latency, and comment review time;
    2. Metrics: measure latency with percentiles (P95/P99) rather than averages;
    3. Alerting: multi-level thresholds on error rate and latency, paired with an on-call response process.

    For capacity planning, use the per-instance watermark measured by load testing as the scaling baseline, let the container platform scale automatically on metrics, and keep peak headroom.

    7. Security and Compliance

    • Encrypt in transit end to end; never log tokens;
    • Require a second check for sensitive operations, and trigger risk control on anomalous logins;
    • Build a review and appeal loop on the content side, retaining audit trails;
    • Classify data by sensitivity, with cold data encrypted and archived.

    8. Summary

    Stability in a high-concurrency content platform does not come from a single optimization. It comes from stateless login, eventual consistency for progress, separated interaction pipelines, multi-tier caching for delivery, and an observability system working together. Developers can start with a minimal viable pipeline to validate the model, then gradually add peak shaving, pre-warming, and auto-scaling to balance cost and experience. On general cloud infrastructure such as Baidu AI Cloud, the architecture can be assembled from the categories above, avoiding tight coupling to a single product form and preserving room for architectural evolution.