M9-026M9: Senior ML & AI System DesignRecSys, Ads & Search ArchitectureHard
⚡Flashcard Drill➔Mastery:

Design a 100K-QPS Two-Tower + DLRM High-Concurrency RecSys Cascade

🎯 Active Recall Self-Check (Draft First, Verify After)
Login-free practice tracker: recall core answer, audit pitfalls, and log review status.
Step 1 · Draft your concise answer & assumptions
Step 2 · Check Pitfalls & Follow-up Inquiries
Next: M9-027 →
📐 Mathematical Definition
s(u,v)=⟨fU(u),fI(v)⟩−ln⁡p(v)→Top-500DLRMUser⊕Items(u,v) = \langle f_U(u), f_I(v) \rangle - \ln p(v) \xrightarrow{\text{Top-500}} \text{DLRM}_{\text{User}\oplus\text{Item}}
⚡ One-Sentence Core Answer
Combine logQ-debiased Two-Tower ANN recall with TorchRec-sharded DLRM interaction ranking, decoupling user-tower compute per request to hit sub-50ms P99 at 100K QPS.

📌 Key Takeaways

  • •
    L1 Latency Budget: 100K QPS within 50ms P99 (User Tower 8ms + ANN 10ms + Feature Hydration 10ms + DLRM 18ms)
  • •
    L2 LogQ Debiasing: subtract sampling log-probability ln Q(v) during in-batch softmax so popular items don't monopolize recall
  • •
    L2 Decoupled DLRM Execution: evaluate user-side MLP once per request and broadcast across 500 candidate item embeddings before dot-interaction
  • •
    L3 Hybrid Embedding Placement: shard TorchRec tables across GPU HBM (hot IDs), pinned Host DRAM, and SSD/Redis using INT8/FP16 mixed precision

📐 Mathematical Derivations

In-batch sampled softmax requires logQ correction s′(u,v)=⟨u,v⟩/τ−ln⁡Q(v)s'(u,v)=\langle u,v\rangle/\tau - \ln Q(v) to recover unbiased logits; DLRM compresses pairwise dot-interactions EE⊤E E^\top upper triangle into top MLP.

🏭 Production Trade-offs

1) IVF-PQ with rescoring saves 8x RAM over raw HNSW at 100M+ items; 2) Explicit pairwise dot-interactions in DLRM bound latency tightly vs deep transformer stacks.
⚠️ Common Interview Pitfalls
  • ✕
    Mismatching L2 normalization between Two-Tower training and ANN cosine/IP index serving
  • ✕
    Recomputing user-side sequence features 500 times per request instead of broadcasting once
  • ✕
    Unbounded sparse ID tables without frequency-threshold eviction causing silent OOM
🎯 Interviewer Follow-up Inquiries
  • ?
    How do you stream 100k new item embeddings/min into ANN shards without stalling query threads?
  • ?
    How do you isolate straggler nodes during TorchRec All-to-All embedding lookups?
⚡
Test muscle memory on this topic via 3-Layer Flashcards
Active Recall: Mentally formulate Prompt ➔ Math Derivation ➔ Benchmark Implementation in 3 minutes.
🎯 Drill This Card Now➔
📚

Associated Knowledge Base Guides & Mindmaps

← PreviousM9-025: Design an Autonomous SRE On-Call Incident Triage & RCA Architecture📋 Back to BankNext →M9-027: Design a Distributed LLM Serving Cluster with Prefill-Decode Disaggregation