← 2026-08-23 📂 All Days 2026-08-25 →

📊 Day 118 — System Design Synthesis

🔥 Expert Level | Synthesis: 存储选型决策框架

🏗️ 系统设计 / System Design

存储选型全景图 — 何时用哪种数据库?

Storage Selection Guide — Picking the Right Database for Every Job


🎯 核心问题 / The Core Question

面试官最爱问:「你会用什么数据库?为什么?」

Interviewers love asking: "What database would you use? Why?"

❌ 错误答案:「用 PostgreSQL,它很可靠。」

❌ Wrong answer: "PostgreSQL, it's reliable."

✅ 正确答案:取决于数据模式、访问模式、一致性要求和规模。

✅ Right answer: Depends on data shape, access pattern, consistency requirements, and scale.


📊 存储类型速查 / Storage Cheatsheet

场景 / Scenario → 推荐存储 / Use This ────────────────────────────────────────────────────────── ACID 事务 / ACID transact. → PostgreSQL / MySQL 灵活 Schema / Flexible schema → MongoDB (document DB) 低延迟热数据 / Hot cache → Redis / Memcached 时序数据 / Time-series → InfluxDB / TimescaleDB 全文搜索 / Full-text search → Elasticsearch / OpenSearch 文件/对象 / Blobs → S3 / GCS 事件流 / Event stream → Kafka / Kinesis 图关系 / Graph queries → Neo4j / Amazon Neptune 全球低延迟 KV → DynamoDB / Cassandra OLAP 分析 / Analytics → BigQuery / Snowflake

🔑 关键决策轴 / Key Decision Axes

1. 一致性 vs 可用性 (CAP 回顾)

  • 强一致性:PostgreSQL, MySQL, etcd, Zookeeper — 用于金融、支付
  • 最终一致性:DynamoDB, Cassandra, Redis Cluster — 用于社交、推荐
  • 口诀:钱要强一致,点赞可最终。

2. 读写比例

  • 读多写少 (>10:1):PostgreSQL + Read Replica + Redis 缓存层
  • 写多读少:Cassandra(LSM-Tree 写路径极快),ClickHouse(列存批写)
  • 均等:单 PostgreSQL + 合理索引往往撑到 10K QPS

3. 数据结构

  • 结构化关系 → SQL(JOIN 是第一公民)
  • 嵌套文档(用户配置、JSON) → MongoDB / DynamoDB
  • 纯 Key-Value 点查 → Redis / DynamoDB
  • 宽列(时序、日志行) → Cassandra / HBase

4. 规模边界(经验值)

< 1TB, < 10K QPS → 单 PostgreSQL 实例 < 10TB, < 100K QPS → PostgreSQL + Read Replica + Redis > 10TB or 全球分布 → DynamoDB Global / Cassandra / Vitess PB 级分析 → BigQuery / Snowflake (OLAP, 不是 OLTP!)

🏗️ 典型生产架构 / Typical Polyglot Stack

用户请求 / User Request │ ├── CDN (S3 + CloudFront) ── 静态资源 / Static assets │ └── API Server ├── Redis ────────────── 缓存、Session、分布式锁 ├── PostgreSQL ──────── 用户/订单/核心业务 (ACID) ├── Elasticsearch ────── 搜索、日志分析 ├── S3 ──────────────── 文件、图片、备份 └── Kafka ──────────── 事件流、服务解耦

为什么这样设计?

Why this design?

  • 每个存储做它最擅长的事。PostgreSQL 不擅长 TB 级搜索,Elasticsearch 不擅长 ACID。
  • Each storage does what it's best at. PostgreSQL is bad at TB-scale search; Elasticsearch is bad at ACID.

⚠️ 常见误区 / Common Mistakes

❌ 过早引入 NoSQL

很多初创公司数据量很小时就用 MongoDB,反而失去了 JOIN 和 ACID,后来痛苦迁回 PostgreSQL。

Many startups adopt MongoDB prematurely, lose JOINs + ACID, then migrate back to Postgres in pain.

❌ 把 Redis 当主数据库

Redis 是缓存/会话存储,数据有丢失风险(AOF+RDB 需要配置,且 Redis 重启有延迟)。

Redis is a cache/session store. Data loss risk unless persistence is carefully configured.

❌ 一库解决所有问题(Mono-DB Fallacy)

认为 PostgreSQL 或 MongoDB 能搞定一切。生产系统几乎都是多存储架构。

Production systems are almost always polyglot. No single DB wins everything.

❌ 混淆 OLTP 和 OLAP

在 PostgreSQL 上跑大量分析查询会锁表、拖慢在线业务。复杂分析要走数仓(BigQuery/Snowflake)。

Running heavy analytics on your OLTP database slows production traffic. Separate your data warehouse.


📚 References

  • https://architecturenotes.co/things-you-should-know-about-databases/
  • https://use-the-index-luke.com/
  • https://www.postgresql.org/docs/current/indexes.html
  • https://cassandra.apache.org/doc/latest/cassandra/architecture/overview.html

🧒 ELI5

不同存储就像厨房工具:冰箱存食材(PostgreSQL),微波炉快速加热(Redis),归档柜存食谱(S3),留言板传消息(Kafka),搜索引擎找食谱(Elasticsearch)。

Different databases are like kitchen tools: fridge for ingredients (Postgres), microwave for quick reheating (Redis), filing cabinet for recipes (S3), message board for communication (Kafka), index for finding recipes (Elasticsearch). Use the right tool for the job.

💻 Day 118 — Algorithms

🔥 Expert Level | Advanced Graphs — Pattern Block Start

💻 算法 / Algorithms — #1584 Min Cost to Connect All Points (Medium)

🧩 新模式 / New Pattern: 高级图算法 — Advanced Graphs

📍 This block: 6 problems

什么时候用 / When to use: 有权图最短路径(Dijkstra)、最小生成树(Prim/Kruskal)、Union-Find 动态连通性

识别信号 / Signals: weighted shortest path, minimum spanning tree, union find, disjoint sets, network connectivity, cost to connect

通用模版 / Template:

# Dijkstra's — Shortest Path
import heapq

def dijkstra(graph, start):
    dist = {node: float('inf') for node in graph}
    dist[start] = 0
    heap = [(0, start)]  # (cost, node)
    while heap:
        d, u = heapq.heappop(heap)
        if d > dist[u]: continue  # stale entry, skip
        for v, w in graph[u]:
            if dist[u] + w < dist[v]:
                dist[v] = dist[u] + w
                heapq.heappush(heap, (dist[v], v))
    return dist

# Prim's MST — For dense graphs (n^2 edges)
def prim_mst(points):
    n = len(points)
    in_mst = [False] * n
    min_cost = [float('inf')] * n
    min_cost[0] = 0
    heap = [(0, 0)]  # (cost, node)
    total = 0
    while heap:
        cost, u = heapq.heappop(heap)
        if in_mst[u]: continue
        in_mst[u] = True
        total += cost
        for v in range(n):
            if not in_mst[v]:
                w = your_edge_weight(u, v)
                if w < min_cost[v]:
                    min_cost[v] = w
                    heapq.heappush(heap, (w, v))
    return total

核心洞察 / Key Insight: Dijkstra = BFS + 优先队列(贪心选最短边)。Prim = Dijkstra 的变体,用于最小生成树。两者都用堆 + 懒删除(stale entry check)。


📍 今日题目 / Today's Problem

🔗 LeetCode #1584 🟡 Medium

📹 NeetCode Video


🌍 真实场景类比 / Real-World Analogy

想象你是城市规划师,要在 n 个村庄之间修路,使所有村庄都能互相到达。修路的费用 = 曼哈顿距离(|x1-x2| + |y1-y2|)。目标:花最少的钱把所有村庄连通。

You're a city planner connecting n villages with roads. Road cost = Manhattan distance. Goal: minimum cost to connect all villages (classic Minimum Spanning Tree).


🧩 映射到模式 / Map to Pattern

这是一道最小生成树 (MST) 问题 — 经典 Prim 算法场景:

  • 所有节点两两之间都有边(完全图,n² 条边)
  • 求连通所有节点的最小总代价

This is MST, not Dijkstra. Key difference:

  • Dijkstra: shortest path from one source to all others
  • Prim/Kruskal: minimum weight to connect ALL nodes

💡 解法 / Solution

import heapq

def minCostConnectPoints(points: list[list[int]]) -> int:
    n = len(points)
    in_mst = [False] * n
    # min_cost[i] = cheapest edge to add node i to MST
    min_cost = [float('inf')] * n
    min_cost[0] = 0
    heap = [(0, 0)]  # (cost, node_index)
    total = 0
    edges_used = 0

    while edges_used < n:
        cost, u = heapq.heappop(heap)

        # Lazy deletion: skip stale entries
        if in_mst[u]:
            continue

        in_mst[u] = True
        total += cost
        edges_used += 1

        # Update neighbors (all unvisited nodes)
        for v in range(n):
            if not in_mst[v]:
                manhattan = (abs(points[u][0] - points[v][0]) +
                             abs(points[u][1] - points[v][1]))
                if manhattan < min_cost[v]:
                    min_cost[v] = manhattan
                    heapq.heappush(heap, (manhattan, v))

    return total

追踪 Trace (3 points: [0,0], [2,2], [3,10]):

Start: heap=[(0,0)], min_cost=[0, inf, inf] Pick (0, node=0): total=0, update neighbors → node1: manhattan=4, node2: manhattan=13 heap=[(4,1),(13,2)] Pick (4, node=1): total=4, update neighbors → node2: manhattan=|3-2|+|10-2|=9 < 13 → update heap=[(9,2),(13,2_stale)] Pick (9, node=2): total=13, done (3 nodes) Answer: 13

复杂度 / Complexity:

  • Time: O(n² log n) — n² edges, each pushed to heap once
  • Space: O(n²) — heap can hold all edges
💡 Alternative: Kruskal's with Union-Find is cleaner for sparse graphs. Prim's wins for dense graphs (complete graph = n² edges).

🔄 举一反三 / Pattern Connections

问题核心变化关键差异
#743 Network Delay Time (下一题)Dijkstra 单源最短路不是 MST,是 shortest path
#787 Cheapest Flights K StopsDijkstra + 约束 (k stops)Bellman-Ford 变体更直接
#778 Swim in Rising Water二分 + BFS 或 Prim 变体最小化最大边权
#332 Reconstruct ItineraryEulerian path (DFS)完全不同,不是 Dijkstra

📚 References

  • https://neetcode.io/problems/min-cost-to-connect-points
  • https://leetcode.com/problems/min-cost-to-connect-all-points/
  • https://cp-algorithms.com/graph/mst_prim.html
  • https://en.wikipedia.org/wiki/Prim%27s_algorithm

🧒 ELI5

把所有点用绳子连起来,每条绳子的费用是两点的曼哈顿距离。你每次选最便宜的绳子,把一个还没连上的点拉进来,直到所有点都连上。这就是 Prim 算法!

Imagine connecting dots with rope. Each rope costs Manhattan distance. Always grab the cheapest rope that pulls a new dot into your connected group. That's Prim's algorithm for MST!

🗣️ Day 118 — Soft Skills Synthesis

🔥 Expert Level | Staff+ 场景综合

🗣️ 软技能 / Soft Skills

Staff 工程师的「影响力杠杆」— 如何在没有汇报关系的情况下推动变革

Staff Engineer's Leverage — Driving Change Without Direct Authority


🎯 场景 / Scenario

你是一名 Staff Engineer,发现公司三个不同业务线的团队分别在重复造轮子——各自开发了内部的 feature flag 系统,代码重复且不一致。你没有任何权力要求他们停下来用你的方案,但你认为统一是正确的决策。你会怎么做?
You're a Staff Engineer who discovers three separate teams have each built their own internal feature flag system—redundant, inconsistent, and all solving the same problem. You have no authority over any of them, but you believe consolidation is the right call. What do you do?

💡 为什么这道题重要 / Why This Matters

这是 Staff+ 工程师最典型的挑战:技术影响力 ≠ 行政权力。面试官想看你能不能在没有职位权威的情况下撬动系统性变化。

This is the defining Staff+ challenge: technical influence ≠ management authority. Interviewers want to see whether you can drive systemic change without positional power.


⭐ STAR Framework

Situation: 三支团队,三套 feature flag 实现,维护成本高,功能参差不齐。

Three teams, three implementations, high maintenance overhead, inconsistent capabilities.

Task: 在没有直接汇报关系的情况下,推动统一,同时不破坏已有团队的自主性。

Drive consolidation without direct reports, without breaking team autonomy.

Action — 四步杠杆模型 / Four-Lever Model:

  1. 先倾听,再提案 (Listen before proposing)

逐一与三个团队做 1:1,了解他们各自的痛点、差异化需求和历史决策。避免第一步就说「你们该用我的方案」。

Do 1:1s with each team first. Understand their pain, unique needs, and history. Never open with "you should use mine."

  1. 数据化问题 (Quantify the problem)

制作一页纸的对比分析:每套系统的功能差距、维护人时、过去 6 个月的 bug 数。让问题自己说话。

Make a one-pager: feature gaps, maintenance hours, 6-month bug counts per system. Let the data advocate for you.

  1. 共建,不是推销 (Co-create, don't sell)

邀请三个团队各出一人,组成「Feature Flag Working Group」。目标是找到大家都能接受的方案,而不是推销你自己的。

Form a "Feature Flag Working Group" with a delegate from each team. Goal: find a solution everyone buys into—not your pre-built solution.

  1. 降低迁移成本 (Lower switching cost)

提供迁移指南、自动化兼容层、可选迁移时间表。让采用新方案比继续维护旧方案更容易。

Provide migration guides, compatibility shims, flexible timelines. Make adopting easier than maintaining.

Result:

3个月内,两个团队自愿迁移,第三个团队在季度末跟进。运维成本下降 40%,feature flag 成为公司级共享平台。

Within 3 months, two teams voluntarily migrated; the third followed by quarter end. 40% reduction in maintenance cost. Feature flags became a company-wide platform.


❌ vs ✅ 对比 / Bad vs Good

❌ 常见失误✅ 正确做法
直接给 VP 发邮件要求强制统一先让团队自己看到问题的成本
在 Slack 公开说「你们的实现很烂」私下 1:1,建立信任再讨论改进
只提问题,不提解决方案带着「我们可以一起做什么」来
要求全量迁移、立即生效渐进迁移,给出充足过渡期

🌟 Senior/Staff 加分点 / Senior/Staff Signals

  • 能说清楚「为什么现在做比以后做成本更低」(技术债的时间价值)
  • 能量化技术债务对业务的影响(不只是工程视角)
  • 能区分「我的技术判断」和「最适合公司的方案」
  • 理解政治阻力(团队 ownership 意识)并有针对性地化解

🔑 Key Takeaways

  1. 影响力来自信任,信任来自倾听。 Influence comes from trust; trust comes from listening first.
  2. 数据比意见更有说服力。 Data beats opinions in technical debates.
  3. 共建比推销更持久。 Co-creation produces more durable outcomes than selling your solution.
  4. 降低他人的切换成本就是降低阻力。 Reducing switching cost = reducing resistance.

📚 References

  • https://staffeng.com/guides/engineering-strategy
  • https://lethain.com/staff-engineer-archetypes/
  • https://increment.com/teams/the-power-of-the-staff-engineer/

🧒 ELI5

你想让同学们用同一款画笔,但你不是老师。你先去问每个人喜欢自己画笔的哪里,然后一起设计一款大家都喜欢的新画笔,最后大家自己决定换不换。结果大家都换了!

You want classmates to use the same paintbrush, but you're not the teacher. You ask what they love about their own brushes, design a new one together that everyone likes, and let them choose. Everyone switches! That's influence without authority.

🤖 Day 118 — AI News

🔥 Expert Level | AI 新闻速递 — August 2026

🤖 AI 本周要闻 / AI News Roundup

August 2026 — 模型大爆发时代的三个关键信号


📰 Story 1: EU AI Act 开始执行 — 通用 AI 模型面临新规

EU AI Act Enforcement Begins — GPAI Models Face New Obligations

来源 / Source: https://www.stephensonharwood.com/insights/neural-network-august-2026/

2026年8月2日,欧盟 AI 法案(EU AI Act)开始对具有「系统性风险」的通用 AI 模型(GPAI)执行义务。欧盟委员会获得权力,可要求提供信息、评估模型、并对不合规的公司处以罚款。

On August 2, 2026, the EU AI Act began enforcing obligations for general-purpose AI (GPAI) models with systemic risk. The European Commission gained powers to request information, evaluate models, and impose fines on non-compliant companies.

为什么重要 / Why it matters:

这是全球第一个对前沿 AI 模型具有法律约束力的监管框架正式落地。OpenAI、Anthropic、Google 等公司在欧洲的部署策略将受到直接影响。工程师需要开始理解 AI 合规工程(AI compliance engineering)这个新领域。

This is the first legally binding AI regulatory framework for frontier models to take effect globally. Engineers now need to understand AI compliance engineering as a real discipline.


📰 Story 2: Alibaba 发布 Qwen3.8-Max — 2.4万亿参数开源模型

Alibaba Releases Qwen3.8-Max — Reportedly 2.4T Parameter Open-Weight Model

来源 / Source: https://augusto.digital/insights/blogs/monthly-llm-news-august-2026/

阿里巴巴发布了 Qwen3.8-Max,据报道是迄今为止最大的开源权重模型,参数量达2.4万亿(混合专家架构 MoE)。同时发布了 Qwen3.8-27B 的更小版本,适合消费级 GPU 运行。

Alibaba released Qwen3.8-Max, reportedly the largest open-weight release ever at 2.4 trillion parameters (MoE architecture), alongside the smaller Qwen3.8-27B for consumer GPU deployment.

为什么重要 / Why it matters:

开源模型正在快速追上闭源前沿模型。对工程师来说,这意味着「在自己的基础设施上运行 frontier-class 模型」正变得可能。MoE 架构(少量参数实际激活)是关键——2.4T 参数中同时激活的只是一个子集,实际计算成本远低于密集模型。

Open-weight models are rapidly catching closed-source frontier models. MoE architecture is key: only a subset of 2.4T params activate per token, making compute cost much lower than a dense model.


📰 Story 3: Claude Code Auto Mode + GPT-5.6 推动「自主 AI 工作流」时代

Claude Code Auto Mode + GPT-5.6 Push Autonomous AI Workflows

来源 / Source: https://local-ai-zone.github.io/blog/ai-updates-august-2026.html

据报道,Anthropic 在8月推出 Claude Opus 5 并启用 Claude Code Auto Mode,主打「无需逐步确认」的自主编码工作流。同期,据报道 OpenAI 发布 GPT-5.6,内置 ChatGPT Work agent,以及收购了演示文稿初创公司 NextSlide。

Anthropic reportedly shipped Claude Opus 5 and enabled Claude Code Auto Mode for autonomous coding workflows. Simultaneously, OpenAI reportedly launched GPT-5.6 with ChatGPT Work agent, and acquired presentation startup NextSlide.

为什么重要 / Why it matters:

AI agent 不再是「帮你写代码片段」,而是「自主执行多步骤工程任务」。对面试来说,这意味着:理解 AI agent 架构(ReAct、工具调用、记忆管理)已经是 senior 工程师的必备知识,不再是加分项。

AI agents are no longer "help you write snippets"—they autonomously execute multi-step engineering tasks. For interviews: understanding agent architecture (ReAct, tool use, memory) is now table stakes for senior engineers, not a bonus.


💡 工程师视角总结 / Engineer's Takeaway

2026年8月 AI 格局变化 / August 2026 Landscape Shift: 监管 → EU AI Act 落地,合规成本上升 开源 → Qwen3.8-Max 追平闭源前沿,推理成本下降 产品 → 自主 agent 工作流成主流,单次调用 API 时代结束

📚 References

  • https://www.stephensonharwood.com/insights/neural-network-august-2026/
  • https://augusto.digital/insights/blogs/monthly-llm-news-august-2026/
  • https://local-ai-zone.github.io/blog/ai-updates-august-2026.html

🧒 ELI5

本周 AI 三件事:政府开始管 AI(欧盟),阿里开源了超大模型(像把核电站的设计图公开),AI 助手开始能自己完成一整个任务而不需要你步步确认。

Three things this week in AI: governments started regulating AI (EU), Alibaba open-sourced a mega-model (like publishing nuclear plant blueprints), and AI assistants can now complete entire tasks autonomously without step-by-step approval.