Online Video Platform Architecture: Core Design and Key Technical Practices
Online video platforms have become a mainstream form of internet content consumption, yet behind every seemingly simple action—logging in, watching HD video, syncing playback across devices, sending danmaku, subscribing to membership, or downloading for offline viewing—sits a complex distributed system. This article systematically walks through the layered architecture, core technical modules, and engineering practices for building a high-concurrency, low-latency, and scalable video platform. It covers core business characteristics, a four-layer architecture, authentication and cross-device playback synchronization, transcoding and HLS streaming, CDN distribution and origin pull, real-time danmaku, membership billing and offline download, as well as stability, observability, and cost optimization—giving developers and architects a complete technical picture.
Introduction
Online video platforms have become a mainstream form of internet content consumption. When a user opens the client, logs in, watches HD video, syncs playback progress across multiple devices, sends danmaku to interact, subscribes to membership benefits, and downloads content for offline viewing—behind each of these seemingly simple actions lies a complex distributed system. With the goal of “building a high-concurrency, low-latency, and scalable online video platform,” this article systematically reviews its architectural layering, core technical modules, and key engineering practices, helping developers and architects build a complete technical understanding.
I. Core Business Characteristics of the Platform
Before designing the architecture, it helps to clarify a few key characteristics that distinguish a video platform from an ordinary web application:
- Massive bandwidth consumption: Video delivery is bandwidth-intensive. A single HD video can have a bitrate of several Mbps, and massive concurrent playback places extreme demands on network egress and storage reads.
- Read-heavy, write-light, with concentrated hotspots: Popular content draws far more plays than the long tail, so cache hit rates and distribution strategy directly determine overall cost and user experience.
- High demands on state and real-time responsiveness: Data such as playback progress, danmaku, and comments requires good readability and low-latency responses.
- Long rich-media processing pipeline: Upload, transcoding, slicing, moderation, and distribution together form a complete media processing pipeline.
These characteristics are exactly why video platforms typically adopt a multi-layer architecture of “access layer—business service layer—media processing layer—storage and distribution layer,” rather than a monolithic application.
II. Overall Layered Architecture Design
A practical video platform architecture is usually divided into four layers, each with its own responsibility and progressively decoupled:
- Access layer: Handles domain resolution, load balancing, TLS termination, and traffic scheduling. It evenly distributes massive concurrent requests across backend clusters and applies rate limiting and circuit breaking to abnormal traffic.
- Business service layer: Hosts business logic for users, content, membership, comments, danmaku, and more. It is typically split into multiple microservices by domain boundary, deployed and scaled independently.
- Media processing layer: Completes compute-heavy tasks such as transcoding, slicing, watermarking, content moderation, and cover extraction. It is an asynchronous processing cluster with high CPU and memory usage, decoupled from the online request path.
- Storage and distribution layer: Composed of object storage, a content delivery network, relational databases, and distributed caches, it handles the persistence and accelerated distribution of original videos, segment files, and structured data.
When implementing this on the cloud, the capabilities above map to common cloud product categories: use object storage to hold original and transcoded media files, a content delivery network to accelerate the distribution of video segments, a message queue to smooth and decouple asynchronous tasks, a container platform to run stateless business services and elastically scaled transcoding clusters, and log services and monitoring and alerting to ensure observability. Taking Baidu AI Cloud as an example, all of these general categories have corresponding product support, but the architectural methodology is vendor-agnostic.
III. User Authentication and Cross-Device Playback Sync
Login and cross-device synchronization are the “glue” of a video platform. The core idea is: maintain playback state per user and read it in real time across any device.
3.1 Authentication and Token Design
After a client logs in, the server issues an access token and a refresh token. The access token has a short lifetime and is used for API authentication, while the refresh token has a long lifetime and is used for silent renewal, reducing the risk of token leakage. The user’s device identifier (deviceId) serves as an additional dimension to distinguish the behavior of the same account across different terminals.
3.2 Playback Progress Reporting API
The client needs to report playback progress at a fixed interval (e.g., every 10–15 seconds), and the server persists it so other devices can read it:
POST /api/v1/playback/progressContent-Type: application/json{"userId": "u_10086","videoId": "v_20001","position": 328.5,"duration": 3600,"deviceId": "device_ios_abc","updatedAt": 1758620550}
The corresponding persistence structure uses “user + video” as the primary key, ensuring that each user keeps only one latest progress record per video, which naturally supports multi-device overwrite writes:
CREATE TABLE playback_progress (user_id VARCHAR(64) NOT NULL,video_id VARCHAR(64) NOT NULL,position DOUBLE NOT NULL, -- playback position (seconds)duration INT NOT NULL,device_id VARCHAR(128) NOT NULL,updated_at BIGINT NOT NULL, -- millisecond timestampPRIMARY KEY (user_id, video_id));
To reduce write pressure on the database, progress reports can first be written to a distributed cache and merged within a time window, then persisted asynchronously. Reads hit the cache first, forming the classic pattern of “write to cache, batch-persist to database, serve reads from cache.”
IV. Video-on-Demand and Streaming Distribution
4.1 Transcoding and Slicing
Original videos vary widely in format, bitrate, and resolution, so they must be transcoded into a unified form and generated at multiple bitrate tiers (e.g., 480P / 720P / 1080P) to support adaptive bitrate playback. The mainstream approach slices video into second-level segments accompanied by an index manifest file. Taking HLS as an example, the manifest structure is as follows:
#EXTM3U#EXT-X-VERSION:3#EXT-X-TARGETDURATION:10#EXT-X-MEDIA-SEQUENCE:0#EXTINF:9.009,segment_000.ts#EXTINF:9.009,segment_001.ts#EXTINF:9.009,segment_002.ts#EXT-X-ENDLIST
The client fetches segments one by one according to the manifest, automatically switching bitrates during network fluctuations, thereby balancing clarity and smooth playback.
4.2 Distribution and Origin Pull
Once segment files are stored in object storage, a content delivery network caches popular content at edge nodes. Key design points include:
- Multi-level caching: Edge nodes plus an intermediate layer to reduce origin pull pressure.
- Long cache with content addressing: Segment names include a content hash to avoid cache breakdown and dirty reads.
- Warm-up strategy: Proactively pre-warm expected hit content before launch to avoid sudden cold starts.
V. Danmaku and Real-Time Interaction System
Danmaku is a high-concurrency interaction scenario that is “write-heavy, read-in-batches.” The core idea is to make writes asynchronous via a message queue and to fetch reads in batches by time window.
The producer delivers danmaku events to a message queue to achieve peak shaving and decoupling:
def publish_danmaku(event):message = {"video_id": event["video_id"],"content": event["content"],"timestamp_ms": event["timestamp_ms"], # timestamp where the danmaku appears"color": event.get("color", "#FFFFFF"),"mode": event.get("mode", "scroll"), # scroll / top / bottom"user_id": event["user_id"],}mq.send(topic="danmaku_topic", body=json.dumps(message))
The consumer aggregates danmaku by video and writes them into a time-series store or cache sharded by video_id. When the client fetches, it only needs to request danmaku within a small time window around the current playback position, rather than loading everything, which controls the data volume per request. Meanwhile, danmaku content must pass through a text moderation pipeline to filter out violating content before it is allowed to display.
VI. Membership Subscription and Offline Download
6.1 Membership and Entitlement System
A membership system is essentially “an entitlement switch plus a billing order.” It is recommended to abstract entitlement verification into an independent service, so business services query a user’s current entitlement status (e.g., whether they can watch HD, whether they can skip a certain type of restriction) through an API, avoiding duplicated implementations across modules. On the billing side, follow the state machine of “order—payment—entitlement activation,” where any failed step must have an idempotent compensation mechanism.
6.2 Offline Download
Client-side offline download must work reliably on weak networks:
- Resumable downloads with segments: record which segments have been downloaded and continue from the interruption point after reconnecting.
- Integrity checks (e.g., per-segment checksums) ensure files are not corrupted.
- Downloaded content must be bound to account entitlements and stored encrypted locally on the device to prevent unauthorized distribution.
VII. Stability, Observability, and Cost Optimization
High availability is the bottom line for a video platform and must be ensured across multiple dimensions:
- Elastic scaling: Automatically scale up and down based on CPU, bandwidth, or queue-backlog metrics via a container platform to handle traffic peaks.
- Full-link monitoring: Establish monitoring and alerting for key metrics such as playback success rate, time to first frame, rebuffering rate, and transcoding queue latency.
- Logging and tracing: Use unified log services and a tracing system to quickly locate cross-service failures.
- Cost optimization: Reduce wasted bandwidth through adaptive bitrate, improve hit rates by caching popular content, and lower storage costs through hot/cold data tiering.
VIII. Summary
A mature online video platform is the result of many technical modules working together: authentication, playback sync, media processing, streaming distribution, real-time interaction, membership billing, and offline download. The core principles of its architecture can be summarized as: traffic governance at the access layer, domain-based decoupling at the service layer, asynchronous compute-intensive processing at the media layer, and multi-level caching at the storage and distribution layer. In practice, developers should first ensure the stability and cost controllability of the core playback path, then gradually enhance capabilities such as danmaku, membership, and offline viewing. On the cloud, they can leverage common categories—object storage, content delivery network, message queue, container platform, log services, and monitoring and alerting—to build a resilient, observable, and continuously evolving technical foundation.
