· SWE Editorial · System Design  · 6 min read

Design YouTube: Architecture and Data Flow

A component-level breakdown of a YouTube-style video platform: upload service, transcoding workers, metadata database, view counters, and CDN, plus how data flows between them.

A component-level breakdown of a YouTube-style video platform: upload service, transcoding workers, metadata database, view counters, and CDN, plus how data flows between them.

After sketching the high-level shape of a YouTube-style system, interviewers often push into the architecture: what services exist, what data stores back them, and how a request actually flows through the system end to end. This article walks through each component in detail.

Component Inventory

A production video platform decomposes into roughly five service layers:

  1. Upload service — handles ingestion of raw video from creators.
  2. Transcoding workers — convert raw video into playback-ready formats.
  3. Metadata database — stores titles, descriptions, channel info, and relationships.
  4. View counter / analytics pipeline — tracks engagement at massive write volume.
  5. CDN — delivers video bytes to viewers globally.

Let’s trace a video’s journey through each.

Upload Service

The upload service is intentionally thin. Its job is coordination, not data handling:

  • Authenticates the creator and validates upload permissions/quota.
  • Issues a pre-signed URL (or resumable upload session) pointing directly at blob storage.
  • Writes an initial metadata row: video_id, owner_id, status: uploading, created_at.
  • Once the client confirms the upload finished, the service updates status: processing and emits an event onto a message queue for the transcoding pipeline to pick up.

Designing it this way means the upload service never becomes a bottleneck for large binary transfers — it only ever handles small JSON payloads and coordination logic. This is the same pattern used by most large-scale file-upload systems, not unique to video.

Transcoding Workers

The transcoding pipeline is a fleet of stateless worker processes consuming from a queue (Kafka or SQS-style). For each incoming job:

  • The worker pulls the raw file from blob storage.
  • Splits it into chunks (for long videos) to parallelize processing across multiple workers.
  • Runs each chunk through the transcoding process to produce multiple resolution/bitrate variants.
  • Reassembles chunked output into properly segmented files (for HLS/DASH adaptive streaming) and writes them back to blob storage, in a separate “processed” bucket/prefix from the raw originals.
  • Emits a completion event, which the metadata service consumes to flip status: ready and populate available resolution options.

Worker fleets scale horizontally and independently from the upload service — a surge in uploads (e.g., after a platform feature launch) doesn’t require scaling the API layer, just adding transcoding capacity, which is a good example of decoupled scaling to raise in an interview.

Metadata Database

Video metadata (title, description, tags, channel, upload date, available resolutions, thumbnail URLs) lives in a structured database — traditionally a relational store, though many large platforms shard it or move to a distributed SQL/NoSQL hybrid at extreme scale.

Design considerations:

  • Read-heavy, write-light. Metadata is written once (at upload, then rarely updated) and read constantly (every video page view). This makes it a great candidate for aggressive caching — a read-through cache (Redis or similar) in front of the metadata DB absorbs the vast majority of traffic.
  • Denormalization for read speed. Channel name, subscriber count, and other frequently-joined data are often denormalized directly onto the video record to avoid expensive joins on the hot read path.
  • Separate from comments. Comments are high-volume, high-write, and have different consistency requirements (eventual consistency is fine) — they typically live in their own dedicated store, not the core video metadata table.

View Counter and Analytics Pipeline

This is the component that trips up candidates who don’t have direct experience with high-write-volume systems. Naively incrementing a view_count column in the metadata database on every single view would create massive write contention on hot rows (a viral video might get thousands of views per second).

The production pattern:

  • View events are fired to a message queue (not written synchronously to the DB).
  • A stream processing job (Flink, Spark Streaming, or a simpler batching consumer) aggregates counts in memory over short windows (e.g., every few seconds) and issues batched increment writes to the database, or writes directly to a fast counter store (Redis) that gets periodically flushed to the durable database.
  • The displayed view count on the video page is read from this fast counter store, not recalculated live — slight eventual consistency (a few seconds of lag) is an acceptable tradeoff for avoiding write contention.

This same pattern — buffer writes, batch aggregate, flush periodically — reappears constantly in system design interviews (like counters, view counts, trending scores) and is worth having as a reusable mental template.

CDN and the Read Path

When a viewer requests a video:

  1. Client hits the API layer, which reads (cached) metadata and returns the manifest URL and video ID.
  2. Client’s player requests the adaptive streaming manifest from the CDN.
  3. CDN serves cached video segments from the nearest edge node if available (cache hit) or fetches from origin blob storage on a miss, caching the result for subsequent viewers in that region.
  4. Player selects resolution dynamically per segment based on measured bandwidth.

Popular videos achieve extremely high cache-hit rates because so many viewers request the same segments; the long tail of rarely-watched content has lower hit rates and relies more on origin fetches, which is an acceptable tradeoff since that content also has lower absolute request volume.

End-to-End Data Flow Diagram (Described)

Upload service issues a pre-signed URL → client uploads raw video to blob storage → completion event → transcoding worker pool picks up job → parallel chunked transcoding → processed segments written to blob storage → completion event updates metadata DB, flips status to ready → CDN pulls/caches segments on first viewer request → subsequent viewers served from edge cache → view events stream asynchronously to the counter pipeline → aggregated counts periodically flushed back to metadata DB (or a fast counter store read directly by the API layer).

Comparison Table: Data Store Choices Per Component

Data TypeStore TypeConsistency NeedWhy
Raw/processed video bytesBlob storage (S3-equivalent)Strong (once written)Massive size, immutable after processing, cheap at scale
Video metadata (title, tags)Relational or distributed SQLStrongStructured, relatively low write volume, needs joins
View countsFast counter store (Redis) + periodic DB flushEventualExtremely high write volume; strong consistency unnecessary
CommentsDocument/NoSQL storeEventualHigh write volume, flexible schema, no complex joins needed
Video segments (playback)CDN edge cacheEventual (cache-based)Read-heavy, latency-critical, geographically distributed

Common Follow-Up Questions

  • “What happens if the transcoding worker crashes mid-job?” — Answer: the queue redelivers the message after a visibility timeout; workers should be idempotent (checking if partial output already exists) to avoid wasted duplicate work.
  • “How do you avoid serving a half-processed video?” — Answer: status field gates visibility; the API layer never returns a manifest URL until status: ready.
  • “How would you add live streaming to this?” — Answer: fundamentally different path (see our scaling bottlenecks article), since there’s no upload-then-transcode step; video must be ingested and distributed in near real time.

Wrapping Up

The architecture of a YouTube-style platform is really a story about decoupling: upload from transcoding, transcoding from serving, metadata reads from metadata writes, and view-count writes from the durable database. Each boundary exists to let one part of the system scale independently of the others, which is the core insight interviewers are testing for.

For more worked examples of this decoupling pattern applied across different systems, see The 0-to-1 SWE Interview Playbook (Amazon: https://www.amazon.com/dp/B0H256Z1MF?tag=sirjohnnymai-20), which walks through component-level architecture design as a repeatable interview skill.

Back to Blog

Related Posts

View All Posts »