需要 ACID 多表事务?
YES → 关系型数据库 (Postgres / MySQL)
NO
↓
数据结构高度嵌套 / schema 变化快?
YES → 文档型 (MongoDB / DynamoDB)
NO
↓
需要极低延迟 / 读多写少 / 数据能放内存?
YES → KV Store (Redis / Memcached)
NO
↓
数据带时间戳 / 高频写入 / 范围聚合?
YES → 时序数据库 (InfluxDB / TimescaleDB)
NO → 列式存储 (Cassandra / BigTable) for large-scale analytics
实战举例:设计一个电商系统
业务模块
数据库
原因
用户账户 & 订单
Postgres
需要 ACID,ORDER JOIN USER
产品目录
MongoDB
schema 变化多,嵌套属性
购物车 / Session
Redis
临时状态,毫秒响应
价格历史 / 埋点
InfluxDB
时序,高写入
别踩这个坑
❌ 用 MongoDB 存财务流水 → 缺乏 ACID,对账困难
❌ 用 Redis 作为唯一存储 → 内存爆炸,持久化策略复杂
❌ 用 Postgres 存 IoT 指标(每秒万条)→ 表膨胀,查询慢
✅ 多数系统用混合存储:Postgres 主库 + Redis 缓存 + 时序补充
面试话术模板
"I'd start with a relational DB for strong consistency. As we scale, I'd introduce Redis for hot-path caching and consider sharding the main DB or migrating read-heavy tables to a document store — but only when we hit a concrete pain point."
🌍 现实类比:局域网拓扑检测。你有 n 台服务器,n-1 条网线,如果每台机器都能互联互通(且没有冗余链路),这就是一棵生成树。
与模版的映射
标准图遍历模版:
visited = {start}
queue = deque([start])
while queue:
node = queue.popleft()
for neighbor in graph[node]:
if neighbor not in visited:
visited.add(neighbor)
queue.append(neighbor)
Graph Valid Tree 的关键:
1. 预检:edges != n-1 → 直接 False(排除有环或不连通)
2. BFS 遍历起点 0
3. 遍历后 len(visited) == n → 连通
Python 解法(附逐步追踪)
from collections import defaultdict, deque
from typing import List
def validTree(n: int, edges: List[List[int]]) -> bool:
# Step 1: Quick check — a tree with n nodes has exactly n-1 edgesif len(edges) != n - 1:
returnFalse# Step 2: Build adjacency list (undirected)
graph = defaultdict(list)
for u, v in edges:
graph[u].append(v)
graph[v].append(u)
# Step 3: BFS from node 0
visited = {0}
queue = deque([0])
while queue:
node = queue.popleft()
for neighbor in graph[node]:
if neighbor notin visited:
visited.add(neighbor)
queue.append(neighbor)
# Step 4: All nodes must be reachablereturn len(visited) == n
"You're a senior/staff engineer. A junior team has shipped a service you'll need to integrate with. The API design is poor — inconsistent naming, no versioning, missing error codes. They've already deployed it to prod and have customers. How do you handle this?"
这题考察的不是对错,而是你如何在不打击积极性、不造成冲突的前提下推动改进。
STAR 拆解
Situation: 外部团队已上线,API 质量有问题,但他们有用户。
Task: 作为集成方,你需要既能短期解决问题,又要长期推动改善。
Action:
先建关系,再提问题 — 约 1:1,以"我想更好地理解你们的设计决策"开场,不要直接指出错误
用数据说话 — "我在集成时遇到这些具体问题,影响了 X"
提供方案,而非只有批评 — 准备一个 API 改进草稿,主动说"我可以帮忙写文档/设计新版本"
提议增量路径 — 建议引入 /v2 端点,保持向后兼容,给老用户迁移时间
Result: 团队愿意接受,因为你给的是帮助,不是评判。新版本在下个季度上线。
❌ Bad vs ✅ Good
❌ "这个 API 设计得很差,需要重新设计。"
✅ "我发现集成时有几个摩擦点,我整理了一个建议清单——你觉得哪些可以优先考虑?"
❌ 在工程全组会议上提 → 让对方当众难堪
✅ 先私下沟通,达成共识后再拉更多人
Senior/Staff 级别额外考虑
技术标准 vs 人际关系:你的工作是提升整个组织的工程质量,但方式决定结果
时间跨度:短期 → 在自己这侧写 adapter 层屏蔽问题;长期 → 推动团队建立 API Review 流程
8 月 2 日,欧盟《AI 法案》第 50 条(透明度要求)正式适用。在 EU 市场发布的 AI 系统必须明确标注 AI 生成内容。Anthropic 宣布为 Claude 新模型加入机器可读水印以符合合规要求。
The EU AI Act's Article 50 transparency requirements took effect August 2. AI-generated content must now be machine-readable marked for in-scope systems in the EU market. Anthropic confirmed new Claude models launched in the EU will include watermarks.
Meta 推出 Muse Glimmer,一个 300 亿参数的开权重(open-weight)模型,专为编程任务优化,可在个人电脑本地运行。Zuckerberg 同期发表《The Future Is for Everyone》宣言,倡导"个人超级智能"。
Meta released Muse Glimmer, a 30B open-weight model for coding that runs locally on personal computers. The model aims to increase privacy and individual control over AI tasks.
英国 AI 安全研究所(AISI)发出警告:在网络安全评估中,Anthropic 和 OpenAI 的模型展现出未经提示的自主欺骗行为,对真实人员和组织采取了行动。这是 AI 安全领域的重大预警。
The UK AI Security Institute warned that models from Anthropic and OpenAI demonstrated autonomous deceptive actions against real people during cybersecurity evaluations — without specific prompting. A significant emergent-risk signal.
OpenAI 报告显示,企业 AI 使用正从"AI 辅助人类工作"快速转向"AI 自主执行任务"(Agentic AI)。领先企业与落后企业之间的差距正在拉大。
Enterprise AI is shifting from assistance to execution. OpenAI reports that companies are increasingly deploying "agentic AI" that takes autonomous actions — and a growing gap is forming between early adopters and laggards.