WEEK 04 · 2026-08-18 · TUE

WhatsApp:多设备、连接失败、Redis 丢投递、乱序与 last seen

完整覆盖 WhatsApp deep dives:billions connections、partition by chat/user、multi-client、WebSocket failure、Redis delivery failure、out-of-order、last seen。

今日固定时间表

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

08:30 wake起床、早餐、准备白板;不安排预读或算法。
08:50—09:1508:50—10:55 system design
Bad/Good/Great 拆解 — Bad: socket 转发即真相;Good: durable log + pub/sub;Great: per-device cursor + fencing + idempotent replay。
09:15—09:5008:50—10:55 system design
精确原文 — 读 WhatsApp potential deep dives、H4 partition subheading、levels 和 references。
09:50—10:2508:50—10:55 system design
故障时序 — 连接断开、Redis 丢消息、重复 ACK、乱序到达、last seen 时钟偏差。
10:25—10:5508:50—10:55 system design
恢复和指标 — 补 reconnect gap、delivery lag、duplicate rate、zombie owner rejection、presence freshness。
14:30—16:15NeetCode Tag · Sliding Window
三道题在下方独立算法表执行。
20:30—21:1520:30—21:15 Staff 追问:multi-device、connection owner pause、out-of-order messages、last seen freshness。

算法模块

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

#Problem / modePatternInvariantBug riskTimeSpace
4Minimum Difference Between Highest and Lowest of K Scores
NEW · 30m solve + 5m evidence
排序后固定长度窗口排序后最优 k 元组必为连续窗口。窗口端点相差 k-1;k=1。O(n log n)O(n) sort-dependent
5Subarrays of Size K and Average >= Threshold
NEW · 30m solve + 5m evidence
固定长度 rolling sum每次判定前窗口恰有 k 项。浮点平均误差;改比 sum >= k*threshold。O(n)O(1)
6Grumpy Bookstore Owner
NEW · 30m solve + 5m evidence
固定增益窗口baseline satisfaction 与窗口额外收益不重算。把本来满意客户重复计入增益。O(n)O(1)

闭卷起手

15 分钟闭卷回答:WebSocket gateway、Redis/pubsub、durable message store 谁拥有事实?

Hello Interview 精确目录

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

项目精确 canonical sectionDisposition今天怎么用
WhatsAppPotential Deep Divesdeep divemove from HLD to scale/failure
WhatsApp1) How can we handle billions of simultaneous users?deep diveconnection ownership and partitioning
WhatsAppShould we partition by chat or by user?deep diveH4 partitioning decision under connection scale
WhatsApp2) What do we do to handle multiple clients for a given user?deep diveper-device state and receipts
WhatsApp3) What happens if the WebSocket connection fails?deep divedisconnect, reconnect, gap pull
WhatsApp4) What happens if Redis fails to deliver a message?deep divepub/sub is delivery hint, durable log is truth
WhatsApp5) How do we handle out-of-order messages?deep diveconversation sequence and client buffering
WhatsApp6) How can we handle a "last seen" functionality?deep divesoft presence and clock caveats
WhatsAppWhat is Expected at Each Level?level expectationcalibrate interview depth
WhatsAppMid-levellevel expectationhappy path
WhatsAppSeniorlevel expectationscale, ordering, failure
WhatsAppStaff+level expectationoperational semantics and edge cases
WhatsAppReferencesreference metadatarecorded but not scheduled as passive reading

DDIA 精确决策卡

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

项目问题精确 DDIA subsection改变的系统决定
last seen/presence 为什么不能作为强事实?Ch9 · 不可靠的时钟presence 是软状态,使用 TTL 和服务端观测时间;不把客户端时钟当作真实在线/离线裁决。
connection owner 暂停后又回来,如何防止僵尸连接继续写状态?Ch9 · 隔离僵尸进程和延迟请求connection/session owner 带 fencing token;旧 owner 的延迟写入被拒绝。

本日项目 artifacts

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

今日产出、修复与英语 recall

课程角色CORE · all deep dives + Bad/Good/Great
必须交付WhatsApp deep-dive matrix:connection scale/multi-device/disconnect/Redis/out-of-order/last-seen,各含 Bad-Good-Great、failure/recovery/metrics。
修复规则如果答案只说“加 Kafka/Redis”,补 message sequence、device cursor、fencing token 和用户可见语义。
English recall
English recall: “The socket is a delivery channel; the durable message log is the source of truth.”
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.