第 7 周 - 第 1 天 - 2026-09-07 MON - CORE - YouTube HLD

YouTube CORE: upload, publication state, and streaming HLD

08:50-10:55 system design14:30-16:15 Trees x320:30-21:15 recall

今日目标

把 YouTube 讲成 upload session -> original object -> processing DAG -> published manifest -> CDN delivery,而不是一个大文件下载服务。

08:50-09:00Set target
一句话写下:视频什么时候才算 publish,可以被 watch API/CDN 返回?
09:00-10:05Blank-page then original reading
先闭卷画 upload/watch HLD,再读 YouTube requirements, API, HLD, upload/watch sections and Bad/Good/Great progressions.
10:05-10:45Decision note
写 publication state machine: Created, Uploading, Uploaded, Processing, ReadyToPublish, Published, Failed.
10:45-10:55Spoken close
2 分钟英文口述 upload path and watch path, including manifest and CDN.
14:30-16:15NeetCode Trees
Exactly three contiguous Trees slots. Each slot is 30m solve + 5m pattern/invariant/bug/complexity evidence.
20:30-21:15Recall / Q&A / repair
20:30-21:15 朗读 YouTube 中文讲义 01-03;录音中必须说出 upload ACK、publish atomically、CDN stale policy。

Exact source links

Use original Hello Interview titles and current canonical anchors. Inline Bad/Good/Great headings without standalone live anchors link to their parent canonical section.

Original title / direct linkDispositionUse
Understand the Problemrequired readingscope YouTube as upload plus streaming, not recommendations/search/comments
Functional Requirementsrequired readingupload videos, watch streams
Non-Functional Requirementsrequired readingavailability, huge blobs, low-latency playback, 1M uploads/day, resumable upload
The Set Uprequired readingcandidate framing
Planning the Approachrequired readingrequirements to entities to API to HLD to deep dives
Defining the Core Entitiesrequired readingUser, Video, VideoMetadata, upload session, rendition
The APIrequired readingPOST presigned URL, metadata, stream manifest
High-Level Designrequired readingmetadata DB, object store, processor, CDN
Background: Video Streamingrequired readingcodec, container, bitrate, manifest files
1) Users can upload videosrequired readingpresigned multipart upload, blob storage, raw versus renditions versus segments
2) Users can watch videosrequired readingdownload file versus segments versus adaptive bitrate
Bad Solution: Store the raw videoinline progressionfails device compatibility and post-processing
Good Solution: Store different video formatsinline progressionsupports device formats but misses segment streaming
Great Solution: Store different video formats as segmentsinline progressionsupports manifest-driven adaptive streaming
Bad Solution: Download the video fileinline progressionlarge file blocks startup and loses progress on failure
Good Solution: Download segments incrementallyinline progressionstarts quickly but still ignores changing network
Great Solution: Adaptive bitrate streaminginline progressionclient switches renditions by bandwidth using manifests

DDIA decision cards

Only exact Ch11/Ch12/Ch13 sections that change today's design are assigned.

DDIA Ch11

工作流调度

Question: YouTube transcode DAG 怎么重启不重做错误的阶段?

把 transcode/split/manifest 建模为有依赖的 job graph;每步输出到对象存储并带 content address/version。

DDIA Ch11

对外提供派生数据

Question: 派生 Top K 和 CDN manifest 何时能对外服务?

把可服务数据作为派生输出发布;读路径只读稳定版本。

算法模块

Contiguous live NeetCode Trees order. No reviews. Three slots per day.

#Problem / modePatternInvariantBug riskTimeSpace
1Binary Tree Inorder Traversal
NEW - 30m solve + 5m evidence
递归/栈中序左子树、root、右子树的访问顺序不变。迭代时 curr 和 stack 退出条件漏一个。O(n)O(h)
2Binary Tree Preorder Traversal
NEW - 30m solve + 5m evidence
递归/栈前序root 在子树之前被记录。迭代栈右子树先入栈顺序反了。O(n)O(h)
3Binary Tree Postorder Traversal
NEW - 30m solve + 5m evidence
递归/双栈后序children 在 root 之前输出。单栈 lastVisited 更新时机错误。O(n)O(h)

今日验收

OutputYouTube HLD board, publication state machine, Bad/Good/Great comparison, one failure window.
Hard failPassive reading without a spoken answer; missing invariant/failure/recovery/metric; any day outside Week 7 touched.
RepairPick the weakest answer and redo it for 8 minutes with one new failure window.
Local study materials
Detailed lecture notes, audio, recall scripts, PDFs, Staff Q&A, and mock packs are archived locally and are intentionally not published on this site.