DDIA Ch11
工作流调度
Question: YouTube transcode DAG 怎么重启不重做错误的阶段?
把 transcode/split/manifest 建模为有依赖的 job graph;每步输出到对象存储并带 content address/version。
把 YouTube 讲成 upload session -> original object -> processing DAG -> published manifest -> CDN delivery,而不是一个大文件下载服务。
| 08:50-09:00 | Set target 一句话写下:视频什么时候才算 publish,可以被 watch API/CDN 返回? |
|---|---|
| 09:00-10:05 | Blank-page then original reading 先闭卷画 upload/watch HLD,再读 YouTube requirements, API, HLD, upload/watch sections and Bad/Good/Great progressions. |
| 10:05-10:45 | Decision note 写 publication state machine: Created, Uploading, Uploaded, Processing, ReadyToPublish, Published, Failed. |
| 10:45-10:55 | Spoken close 2 分钟英文口述 upload path and watch path, including manifest and CDN. |
| 14:30-16:15 | NeetCode Trees Exactly three contiguous Trees slots. Each slot is 30m solve + 5m pattern/invariant/bug/complexity evidence. |
| 20:30-21:15 | Recall / Q&A / repair 20:30-21:15 朗读 YouTube 中文讲义 01-03;录音中必须说出 upload ACK、publish atomically、CDN stale policy。 |
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 link | Disposition | Use |
|---|---|---|
| Understand the Problem | required reading | scope YouTube as upload plus streaming, not recommendations/search/comments |
| Functional Requirements | required reading | upload videos, watch streams |
| Non-Functional Requirements | required reading | availability, huge blobs, low-latency playback, 1M uploads/day, resumable upload |
| The Set Up | required reading | candidate framing |
| Planning the Approach | required reading | requirements to entities to API to HLD to deep dives |
| Defining the Core Entities | required reading | User, Video, VideoMetadata, upload session, rendition |
| The API | required reading | POST presigned URL, metadata, stream manifest |
| High-Level Design | required reading | metadata DB, object store, processor, CDN |
| Background: Video Streaming | required reading | codec, container, bitrate, manifest files |
| 1) Users can upload videos | required reading | presigned multipart upload, blob storage, raw versus renditions versus segments |
| 2) Users can watch videos | required reading | download file versus segments versus adaptive bitrate |
| Bad Solution: Store the raw video | inline progression | fails device compatibility and post-processing |
| Good Solution: Store different video formats | inline progression | supports device formats but misses segment streaming |
| Great Solution: Store different video formats as segments | inline progression | supports manifest-driven adaptive streaming |
| Bad Solution: Download the video file | inline progression | large file blocks startup and loses progress on failure |
| Good Solution: Download segments incrementally | inline progression | starts quickly but still ignores changing network |
| Great Solution: Adaptive bitrate streaming | inline progression | client switches renditions by bandwidth using manifests |
Only exact Ch11/Ch12/Ch13 sections that change today's design are assigned.
Contiguous live NeetCode Trees order. No reviews. Three slots per day.
| # | Problem / mode | Pattern | Invariant | Bug risk | Time | Space |
|---|---|---|---|---|---|---|
| 1 | Binary Tree Inorder Traversal NEW - 30m solve + 5m evidence | 递归/栈中序 | 左子树、root、右子树的访问顺序不变。 | 迭代时 curr 和 stack 退出条件漏一个。 | O(n) | O(h) |
| 2 | Binary Tree Preorder Traversal NEW - 30m solve + 5m evidence | 递归/栈前序 | root 在子树之前被记录。 | 迭代栈右子树先入栈顺序反了。 | O(n) | O(h) |
| 3 | Binary Tree Postorder Traversal NEW - 30m solve + 5m evidence | 递归/双栈后序 | children 在 root 之前输出。 | 单栈 lastVisited 更新时机错误。 | O(n) | O(h) |
| Output | YouTube HLD board, publication state machine, Bad/Good/Great comparison, one failure window. |
|---|---|
| Hard fail | Passive reading without a spoken answer; missing invariant/failure/recovery/metric; any day outside Week 7 touched. |
| Repair | Pick the weakest answer and redo it for 8 minutes with one new failure window. |