WEEK 04 · 2026-08-17 · MON

WhatsApp:消息事实、connection ownership 与离线投递 HLD

把 WhatsApp 讲成 durable message log + device delivery state + soft presence,而不是 WebSocket 转发器。

今日固定时间表

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

08:30 wake起床、早餐、准备白板;不安排预读或算法。
08:50—09:1008:50—10:55 system design
闭卷收敛 — FR/NFR/out-of-scope;先定义 per-conversation ordering,不承诺全局总序。
09:10—09:4508:50—10:55 system design
精确原文 — 读 WhatsApp 到 HLD 四个功能路径。
09:45—10:2508:50—10:55 system design
白板主路径 — client_message_id → conversation sequencer → durable message → fanout/mailbox → device receipt。
10:25—10:5508:50—10:55 system design
DDIA 决策卡 — 把 logical timestamp/happens-before 绑定到消息顺序、离线重连和重复投递。
14:30—16:15NeetCode Tag · Sliding Window
三道题在下方独立算法表执行。
20:30—21:1520:30—21:15 WhatsApp 英语 recall + 中文 Q&A:ordering guarantee、offline delivery、multi-device receipts。

算法模块

连续单一 NeetCode Sliding Window tag;每天 3 个 NEW slot,每题 30 分钟作答 + 5 分钟证据,正好 105 分钟。每天 timed review = 0,满足不超过 1。

#Problem / modePatternInvariantBug riskTimeSpace
1Contains Duplicate II
NEW · 30m solve + 5m evidence
固定最大跨度窗口 + setset 只保存与当前 index 距离不超过 k 的值。先查后删会漏掉边界 k;k=0。O(n)O(k)
2Best Time to Buy and Sell Stock
NEW · 30m solve + 5m evidence
单调左状态右指针处只需要左侧最低价格。先更新 min 再算利润;递减数组。O(n)O(1)
3Minimum Recolors to Get K Consecutive Black Blocks
NEW · 30m solve + 5m evidence
固定长度计数窗口窗口始终恰含 k 个 block,并维护 white 数。第 k 个元素加入时 off-by-one;k=n。O(n)O(1)

闭卷起手

20 分钟闭卷画 sendMessage、syncMessages、ackReceipt、setPresence;写清 sent/delivered/read 分别代表什么。

Hello Interview 精确目录

day 页面使用 canonical data-toc-id/H4 anchors;周级 overview 不放小节链接。

项目精确 canonical sectionDisposition今天怎么用
WhatsAppUnderstanding the Problemrequired readingscope: 1:1/group messaging, delivery and presence
WhatsAppFunctional Requirementsrequired readinggroups, messages, offline delivery, media
WhatsAppNon-Functional Requirementsrequired readingscale, durability, latency, eventual delivery
WhatsAppThe Set Uprequired readingcandidate framing
WhatsAppPlanning the Approachrequired readingrequirements → entities → API → HLD
WhatsAppDefining the Core Entitiesrequired readingUser, Device, Chat, Message, Receipt, Presence
WhatsAppAPI or System Interfacerequired readingsend, sync, receipts, presence
WhatsAppHigh-Level Designrequired readingconnection gateway + durable log + fanout
WhatsApp1) Users should be able to start group chats with multiple participants (limit 100)required readinggroup membership and chat ownership
WhatsApp2) Users should be able to send/receive messages.required readingdurable accept and delivery pipeline
WhatsApp3) Users should be able to receive messages sent while they are not online (up to 30 days).required readingmailbox/sync cursor and retention
WhatsApp4) Users should be able to send/receive media in their messages.required readingmedia pointer; not Week 4 main bottleneck

DDIA 精确决策卡

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

项目问题精确 DDIA subsection改变的系统决定
WhatsApp 发送 ACK 到底代表消息处于哪个顺序点?Ch10 · 逻辑时钟conversation 内 sequence/logical timestamp 由服务端分配;不使用客户端日历时钟决定消息顺序。
离线设备重连时如何判断哪些消息先发生、哪些是重复?Ch6 · “先发生”关系与并发设备保存 last applied cursor;按 conversation sequence 补缺口,messageId/clientMessageId 幂等应用。

本日项目 artifacts

脚本、音频、PDF 与 mock evidence 直接从对应日打开。

今日产出、修复与英语 recall

课程角色CORE · requirements/API/data model/HLD
必须交付WhatsApp HLD:Chat/Message/DeviceDelivery/Receipt/Presence schema、发送 ACK 语义、离线 sync cursor。
修复规则如果 ACK 被说成对方已读,重写 sent/durable/delivered/read 四种状态。
English recall
English recall: “A send ACK means the server durably accepted the message, not that every recipient has read it.”
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.