WEEK 03 · 2026-08-12 · WED

FB Live Comments:实时评论 HLD、SSE 与可恢复历史

把 live comments 拆成 durable comment log + realtime delivery;不要把 WebSocket 当作数据库。

今日固定时间表

08:30 wake 只保留起床;学习从 08:50 开始。三块窗口不互相挤占。

08:30 wake起床、早餐、准备白板;不安排预读或算法。
08:50—09:1008:50—10:55 system design
闭卷 HLD — 先给 API 和实体,明确历史评论与实时评论的分界。
09:10—09:4508:50—10:55 system design
精确原文 — 读 Live Comments requirements/entity/API/HLD 三个功能子路径。
09:45—10:2508:50—10:55 system design
机制化白板 — 画 append comment → log/broker → connection server → SSE client;旁路 history page。
10:25—10:5508:50—10:55 system design
DDIA 决策卡 — 用 log broker 与 offset 解释 Last-Event-ID 和 catch-up。
14:30—16:15NeetCode Tag · Stack
三道题在下方独立算法表执行,避免系统设计表格挤压算法细节。
20:30—21:1520:30—21:15 口述:为什么 SSE 是本题默认解,什么时候才换 WebSocket。

算法模块

连续单一 NeetCode Stack tag;每天 3 题,14:30—16:15 完成。

#ProblemInvariant focus执行
7Largest Rectangle in Histogram单调递增栈和右边界结算。35 分钟限时 + 5 分钟 invariant/bug risk
8Valid Parentheses限时复盘:错误输入和早停。35 分钟限时 + 5 分钟 invariant/bug risk
9Min Stack限时复盘:重复最小值和 pop 同步。35 分钟限时 + 5 分钟 invariant/bug risk

闭卷起手

先暴露自己的当前模型,再用 live headings 修正。

20 分钟闭卷画:postComment、subscribe/live stream、getCommentsSince;写出 lastCommentId 如何跨断线保存。

Hello Interview 精确目录

day 页面必须链接到具体 section anchors;周级 overview 不放小节链接。

项目精确 section anchorDisposition今天怎么用
FB Live CommentsUnderstanding the Problemrequired readingclarify live video comments surface
FB Live CommentsFunctional Requirementsrequired readingpost, receive new comments, see earlier comments
FB Live CommentsNon-Functional Requirementsrequired readingrealtime delivery, massive concurrent viewers, HA
FB Live CommentsThe Set Uprequired readingscope and simplifications
FB Live CommentsPlanning the Approachrequired readingentities/API/HLD/deep dive order
FB Live CommentsDefining the Core Entitiesrequired readingLiveVideo, Comment, ViewerSession, Cursor
FB Live CommentsAPI or System Interfacerequired readingpost comment, stream comments, catch-up page
FB Live CommentsHigh-Level Designrequired readingwrite durable comment, broadcast to connected viewers
FB Live Comments1. Viewers can post comments on a live video feedrequired readingdurable append and moderation boundary
FB Live Comments2. Viewers can see new comments being posted while they are watching the live videorequired readingSSE/WebSocket realtime path
FB Live Comments3. Viewers can see comments made before they joined the live feedrequired readinghistory and cursor page

DDIA 精确决策卡

只读能改变今天设计决定的小节。

项目问题精确 DDIA subsection改变的系统决定
Live Comments 的 comment log 和广播通道是什么关系?Ch12 · 基于日志的消息代理durable comment append 是可回放事实;SSE/WebSocket 是低延迟投递,不承担永久历史。
客户端 reconnect 时从哪里补漏?Ch12 · 消费者偏移量客户端保存 lastCommentId/Last-Event-ID,服务端从 durable log/cache 读取 since cursor 后继续直播。

今日产出与修复规则

课程角色CORE · requirements/API/data model/HLD
必须交付Live Comments HLD:Comment store、stream broker、connection server、catch-up API、lastCommentId 客户端状态。
修复规则如果实时通道丢消息会造成永久丢失,说明你把 delivery channel 当成 source of truth,必须重画 durable log。
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.