High-Concurrency Video Platform Architecture: Login and Content Delivery Practices

    This article presents a practical architecture for high-concurrency content platforms, covering five core dimensions: identity authentication, user state synchronization, real-time interaction, content delivery, and observability. It explains how to issue and verify credentials at scale, keep playback progress consistent across devices with idempotent writes, handle danmaku and comments in separate layers, distribute media through edge caching and adaptive bitrate, and stabilize the system with metrics, logs, tracing, and tiered rate limiting. Includes sample code and a deployment checklist.

    The source material comes from a client entry page of a video content platform, containing typical elements such as login prompts, cross-device playback history sync, danmaku and comment interactions, content category navigation, and client downloads. This article strips away the specific product attributes and abstracts them into a general architecture problem for high-concurrency content platforms. It covers five dimensions—identity authentication, state synchronization, real-time interaction, content delivery, and observability—and provides actionable technical designs with illustrative code.

    From Page Elements to Technical Problems

    A public-facing content platform entry page usually serves three purposes: it acts as an identity entry point that prompts users to log in or register; it explains capabilities, informing users that logging in unlocks HD playback, cross-device progress sync, and interactive comments; and it provides content navigation, exposing different content categories to users.

    Mapping these elements to the backend yields several clear technical problems:

    • Authentication and authorization: how to securely issue and verify credentials under high concurrency;
    • User state synchronization: how to keep playback progress, favorites, and history consistent across devices;
    • Real-time interaction: how to make danmaku and comments low-latency, sortable, and reviewable;
    • Content delivery: how to deliver massive amounts of static and streaming content to the edge at low cost and low latency;
    • Observability and governance: how to locate problems, control capacity, and ensure stability.

    Each is discussed below.

    Authentication: Designing the Login Path for High Concurrency

    Login is the first gate of a content platform and the entry point for traffic spikes. There are three key design points.

    First, separate credentials from state. The server should not store session state. Instead, it should issue signed tokens that carry the user identifier, expiration time, and audience information, with the server only verifying the signature. Any instance can then verify tokens independently, which naturally supports horizontal scaling.

    1. token = base64(payload) + "." + base64(signature)
    2. payload = { sub: user ID, exp: expiration time, aud: client type, scope: permission set }

    Second, use short-lived tokens plus refresh tokens. Access tokens should have a short lifetime to reduce exposure risk. Refresh tokens live longer but can only be used to obtain new access tokens, and should support rotation and revocation.

    Third, protect the login endpoint. Login is a typical write hotspot and needs rate limiting, CAPTCHA or human verification, and backoff after repeated failures to prevent credential stuffing and brute-force attempts. Password-type credentials must be stored as salted hashes; plaintext or reversible encryption is prohibited.

    Cross-Device Playback Sync: Consistency and Idempotency

    Cross-device playback history sync is essentially a user-scoped state synchronization problem. The core tension is that writes are frequent and highly concurrent, while reads require low latency.

    The recommended approach is “merge writes + cache reads”:

    • The client records progress locally first, then reports it at throttled intervals (for example, every few seconds or at key points);
    • The server performs idempotent writes keyed by user and content, using a version number or update timestamp to resolve out-of-order overwrites;
    • The read path fetches the latest progress from cache, falling back to the persistent layer on a cache miss.

    Illustrative idempotent write logic:

    1. def update_progress(user_id, item_id, position, client_ts):
    2. key = f"progress:{user_id}:{item_id}"
    3. current = cache.get(key)
    4. if current and current.client_ts >= client_ts:
    5. return current # discard stale reports to keep writes idempotent
    6. record = {"position": position, "client_ts": client_ts}
    7. cache.set(key, record, ttl=7 * 24 * 3600)
    8. queue.send("progress_topic", record) # persist asynchronously to absorb spikes
    9. return record

    A message queue is used here to remove high-frequency writes from the synchronous path. The persistent layer consumes in batches and writes in bulk, which reduces write pressure and makes it easier to run viewing analytics later.

    Real-Time Interaction: Layered Handling of Danmaku and Comments

    Danmaku and comments have different requirements and should be designed in separate layers.

    Danmaku emphasizes real-time delivery and low latency, and can tolerate brief loss. Comments emphasize reliability, sortability, and reviewability.

    • Danmaku: clients send in batches. After rate limiting and content safety filtering, the server broadcasts to subscribers in the same content room over a long-lived connection or push channel. A ring buffer keeps the most recent messages in the room, so new arrivals only need to fetch the latest window.
    • Comments: go through a standard write API. After persistence, a sort key is generated at the global or per-thread level (time, popularity), and the read path returns paginated results. Popularity ranking should be computed asynchronously to avoid heavy computation on the request path.

    Content safety should be applied upfront: text first passes keyword and rule-based filtering, high-risk content enters a manual or model-based review queue, and only approved content becomes publicly visible.

    1. Danmaku path: client -> access layer (rate limit / filter) -> room broadcast -> subscribers
    2. Comment path: client -> write API -> persistent layer -> async ranking / review -> read API

    Content Delivery and Playback Quality

    The delivery goal for a content platform is “nearby, low-latency, low-cost.” Common practices include:

    • Upload static assets and streaming segments to object storage, with CDN edge nodes caching them;
    • Use segmented streaming with adaptive bitrate, letting the client switch quality based on network conditions;
    • Pre-warm popular content to the edge and fetch cold content from origin on demand, balancing cost and hit rate;
    • Sign playback URLs with an expiration to prevent hotlinking and unauthorized access.

    Category navigation (such as membership, comics, sports events, or launch events) is essentially a content catalog and search problem. A combination of “catalog tree + inverted index + cache” works well, with cache refreshes triggered by events when the catalog changes.

    Observability and Capacity Governance

    High-concurrency systems must be observable. At a minimum, cover four types of signals:

    • Metrics: request volume, error rate, latency percentiles, queue backlog, cache hit rate;
    • Logs: structured logs carrying a request identifier for end-to-end correlation;
    • Tracing: call relationships across the access layer, business layer, and storage layer;
    • Alerts: thresholds based on percentile latency and error budgets, rather than averages alone.

    For capacity governance, apply tiered rate limiting (per user, per API, global), circuit breaking and degradation (degrade interaction to read-only when unavailable), and elastic scaling (the container platform scales based on metrics). Load testing should cover three typical scenarios: login spikes, the moment a stream starts, and hotspot events.

    Implementation Checklist

    1. Authentication: short-lived tokens with refresh token rotation; rate limiting and human verification on the login endpoint;
    2. Sync: throttled client reporting, idempotent server writes, message queue for spike absorption;
    3. Interaction: danmaku over a broadcast channel with rate and content filtering; comments over reliable writes with async ranking;
    4. Delivery: object storage + edge caching + adaptive bitrate + signed URLs;
    5. Observability: metrics, logs, tracing, and alerts as a unified set, with thresholds based on percentile latency;
    6. Governance: tiered rate limiting, circuit breaking and degradation, metric-based elastic scaling, and regular load testing.

    All of the above are common industry practices; specific parameters must be determined through load testing based on business scale. Building on general-purpose capabilities such as object storage, message queues, container platforms, log services, and monitoring and alerting from Baidu AI Cloud can significantly shorten infrastructure setup time, letting teams focus on business and experience innovation.