估计和容量规划 — 计算预期负载、数据量和资源需求 — 是系统设计的重要部分。粗略的 "back-of-the-envelope" 计算指导设计决策(要扩展多少、需要哪些资源)并且在设计面试中很常见。
为什么这很重要
Estimating scale informs DESIGN decisions:
→ how many servers? how much storage? what database? do you need sharding/caching?
→ understanding the SCALE (small vs massive) shapes the whole design
→ rough numbers guide whether/how to scale (don't over- or under-engineer)
应该估计什么(back-of-the-envelope)
✓ TRAFFIC → users, requests/sec (QPS); read vs write ratio (e.g. 100:1 reads:writes)
→ peak vs average (design for peak); daily active users → requests
✓ STORAGE → data size per item × volume × growth over time → total storage (and growth rate)
✓ BANDWIDTH → data transferred per second (request size × QPS)
✓ MEMORY → cache size needed (e.g. cache the hot 20% of data)
→ rough estimates (order of magnitude) → good enough to inform design
