<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>dbaplus社群</title>
    <link>https://wechat2rss.xlab.app/feed/3b9cc8887fccb80d3f083cd6eb8c344628d101b6.xml</link>
    <description>围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。&#xA;(wechat feed made by @ttttmr https://wechat2rss.xlab.app)</description>
    <managingEditor> (dbaplus社群)</managingEditor>
    <pubDate>Tue, 10 Nov 2026 07:15:57 +0800</pubDate>
    <lastBuildDate>Tue, 10 Nov 2026 07:15:57 +0800</lastBuildDate>
    <image>
      <url>https://wx.qlogo.cn/mmhead/ufVMVgCvafJ9E548RXicwc4cOtTJjEfu0lgrC6U6iaUTxtvICXpoW0s3zSaLcEgEBDiaU1DLiaibZgso/0</url>
      <title>dbaplus社群</title>
      <link>https://wechat2rss.xlab.app/feed/3b9cc8887fccb80d3f083cd6eb8c344628d101b6.xml</link>
    </image>
    <item>
      <title>企业级MultiAgent的记忆系统：短期上下文与四层记忆架构实现</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzkzMjYzNjkzNw==&amp;mid=2247638413&amp;idx=1&amp;sn=24fdf225cd57fdcaa1f315ed354484e4</link>
      <description>当前方案覆盖Redis/MySQL回退、MemOS语义检索等内容。</description>
      <content:encoded><![CDATA[<p><span>偶啦</span> <span>2026-11-10 07:15</span> <span style="display: inline-block;">广东</span></p>




  <p>以下文章来源于：得物技术</p>
  <strong>得物技术</strong>
  <p>技术知识分享交流平台，与你一同走向技术的云端。</p>



  
  <p><img src="https://wechat2rss.xlab.app/img-proxy/?k=cddab5e5&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FgiamgWvCHDYamh3D0CfRiabKiczCqnOkeu0DxtgspbhichrjiaM5oxaWibQOia7bC9qPvNiaKeXzciakJ7zcibxicbLS76tVsIOR8MCI8wm3ug5DhEtmqs%2F0%3Fwx_fmt%3Djpeg"/></p>
  <p>当前方案覆盖Redis/MySQL回退、MemOS语义检索等内容。</p>
  <p class="mp_profile_iframe_wrp" style="margin-bottom: 0px;" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-service_type="1" data-verify_status="2"></mp-common-profile></p><div data-role="outer" label="edit by 135editor" data-pm-slice="0 0 []"><div data-role="paragraph"><div data-tools="135编辑器" data-id="us-4110356"><div data-role="paragraph" style="margin: 0px;padding: 0px;max-width: 100%;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;box-sizing: border-box !important;overflow-wrap: break-word !important;"><p style="text-align:justify;max-inline-size: 100%;margin: 0px;padding: 0px;outline: 0px;clear: both;min-height: 1em;cursor: text;max-width: 100%;letter-spacing: 0.544px;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="color:#138bd5;font-size:16px;font-family:-apple-system-font, BlinkMacSystemFont, Arial, sans-serif;"><strong><span leaf="">目录</span></strong></span></p><div data-role="paragraph" style="color: #222222;font-size: 17px;max-inline-size: 100%;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;letter-spacing: 0.544px;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;font-family:sans-serif;"><div data-role="paragraph" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;max-width: 100%;visibility: visible;"><div data-role="paragraph" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;max-width: 100%;color: #222222;font-size: 17px;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;text-decoration-thickness: initial;visibility: visible;font-family:sans-serif;"><div data-role="paragraph" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;max-width: 100%;letter-spacing: 0.544px;visibility: visible;font-family:-apple-system, BlinkMacSystemFont, Arial, sans-serif;"><div data-role="paragraph" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;max-width: 100%;visibility: visible;"><div data-role="paragraph" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;max-width: 100%;visibility: visible;"><div data-tools="135编辑器" data-id="5" data-color="rgb(198, 198, 199)" data-custom="rgb(198, 198, 199)" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;border: 0px none;z-index: 0;max-width: 100%;font-size: 16px;widows: 1;visibility: visible;"><div style="max-inline-size: 100%;margin: 2px auto;padding: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;max-width: 100%;font-size: 14px;line-height: 25px;border-width: 2px;border-style: dashed;border-color: #c6c6c7;visibility: visible;"><p style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;clear: both;min-height: 1em;cursor: text;max-width: 100%;vertical-align: inherit;line-height: 1.5em;visibility: visible;"><span style="letter-spacing: 0.544px;caret-color: red;"><span leaf="">一、背景及整体架构概览</span></span></p><p style="line-height:1.75;"><span style="font-size: 14px;font-weight: 400;letter-spacing: 0.544px;font-style: normal;color: #222222;text-decoration: none solid #222222;font-family:-apple-system, BlinkMacSystemFont, Arial, sans-serif;"><span leaf="">二、记忆架构概览</span></span></p><p style="line-height:1.75;"><span style="font-size: 14px;font-weight: 400;letter-spacing: 0.544px;font-style: normal;color: #222222;text-decoration: none solid #222222;font-family:-apple-system, BlinkMacSystemFont, Arial, sans-serif;"><span leaf="">三、短期记忆加载详情</span></span></p><p style="line-height:1.75;"><span style="font-size: 14px;font-weight: 400;letter-spacing: 0.544px;font-style: normal;color: #222222;text-decoration: none solid #222222;font-family:-apple-system, BlinkMacSystemFont, Arial, sans-serif;"><span leaf="">四、短期记忆写入详情</span></span></p><p style="line-height:1.75;"><span style="font-size: 14px;font-weight: 400;letter-spacing: 0.544px;font-style: normal;color: #222222;text-decoration: none solid #222222;font-family:-apple-system, BlinkMacSystemFont, Arial, sans-serif;"><span leaf="">五、长期记忆加载实现详解</span></span></p><p style="line-height:1.75;"><span style="font-size: 14px;font-weight: 400;letter-spacing: 0.544px;font-style: normal;color: #222222;text-decoration: none solid #222222;font-family:-apple-system, BlinkMacSystemFont, Arial, sans-serif;"><span leaf="">六、长期记忆写入实现详解</span></span></p><p style="line-height:1.75;"><span style="font-size: 14px;font-weight: 400;letter-spacing: 0.544px;font-style: normal;color: #222222;text-decoration: none solid #222222;font-family:-apple-system, BlinkMacSystemFont, Arial, sans-serif;"><span leaf="">七、核心设计与运行观测</span></span></p><p style="line-height:1.75;"><span style="font-size: 14px;font-weight: 400;letter-spacing: 0.544px;font-style: normal;color: #222222;text-decoration: none solid #222222;font-family:-apple-system, BlinkMacSystemFont, Arial, sans-serif;"><span leaf="">八、总结与后续工作</span></span></p></div></div></div></div></div></div></div></div></div></div><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">一、背景及整体架构概览</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">在 MultiAgent 平台中，Agent 一次请求可能同时经过模型、MCP/A2A 工具、RAG、Workflow 和 Sandbox，还要在多轮对话和跨会话协作中记住用户偏好、任务进展与协作约定。因此记忆模块不是独立外挂，而是 Agent 执行链路的一部分。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">在本项目中，记忆不是把全部历史简单拼到 Prompt，而是分别承接会话上下文、跨会话信息和上下文关联：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">会话延续：</span>短期历史无法支持指代消解和任务延续。</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">跨会话复用：</span>跨会话无法复用用户偏好和稳定事实。</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">上下文关联：</span>新增消息无法与已有上下文建立关联。</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">选型 MemOS：</span>在 1540 个问题、10 个测试用户的评测中，综合得分 74.33%，单跳与多跳表现均达标（评测仅作选型参考，不代表生产 SLA）。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">整体架构：</span>后端基于 Spring Boot 3 和 Java 17，Agent 编排采用 AgentScope。新建 Agent 默认将 longMemoryProvider 设为 MEMOS，但 openLongMemory 默认关闭；开启后，请求开始时短期会话历史和长期记忆并行加载，会话结束后由 onSessionEndAsync 异步完成筛选、去重和长期沉淀。短期记忆以 MySQL 为持久化底座、Redis 为热点缓存，长期记忆以 MemOS 为主路径，同时保留 MySQL/Mem0 路由作为兼容路径。</span></span></p><p><span leaf=""><img class="rich_pages wxw-img" data-aistatus="1" data-backh="346" data-backw="578" data-ratio="0.5982575024201355" style="-webkit-tap-highlight-color:rgba(0, 0, 0, 0);margin:0px;padding:0px;outline:0px;color:rgba(0, 0, 0, 0.9);font-family:&#34;PingFang SC NEW&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size:16px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:0.544px;orphans:2;text-align:start;text-indent:0px;text-transform:none;widows:2;word-spacing:0px;-webkit-text-stroke-width:0px;white-space:normal;background-color:rgb(255, 255, 255);text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;user-select:auto;width:100%;" data-w="1033" src="https://wechat2rss.xlab.app/img-proxy/?k=6fb91211&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FFMFU1P6sHHuZQibicpC9M4kUozu5icbpM6MRMHHvkQczXI44mSjvNBRgniaicZiazql6nNqfGcsibomczuUefKe6eR9icbicAWxoUYZH0oXRW6tzXPS8%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg%26tp%3Dwxpic%26wxfrom%3D5%26wx_lazy%3D1%23imgIndex%3D1"/></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">本文只展开记忆模块的实现：</span>包括四层记忆模型、短期历史的读取与写入、MemOS 的按 scope 检索，以及会话结束后的异步沉淀。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">二、记忆架构概览</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img class="rich_pages wxw-img" data-aistatus="1" data-backh="383" data-backw="578" data-ratio="0.6620370370370371" style="-webkit-tap-highlight-color:rgba(0, 0, 0, 0);margin:0px;padding:0px;outline:0px;color:rgba(0, 0, 0, 0.9);font-family:&#34;PingFang SC NEW&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size:16px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:0.544px;orphans:2;text-align:start;text-indent:0px;text-transform:none;widows:2;word-spacing:0px;-webkit-text-stroke-width:0px;white-space:normal;background-color:rgb(255, 255, 255);text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;user-select:auto;width:100%;" data-w="1080" src="https://wechat2rss.xlab.app/img-proxy/?k=93c1099f&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FFMFU1P6sHHsOOe8KcMeHmAjy8iagQm2psBhx1iaWOibUsia3Af59aCBpOaLia1kkyXjU2ia6bmTa5K9fo1iaIUribc6ywoZ4gp1CbsJTdx2HWVH79KA%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg%26tp%3Dwxpic%26wxfrom%3D5%26wx_lazy%3D1%23imgIndex%3D2"/></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img class="rich_pages wxw-img" data-aistatus="1" data-backh="166" data-backw="578" data-ratio="0.28703703703703703" style="-webkit-tap-highlight-color:rgba(0, 0, 0, 0);margin:0px;padding:0px;outline:0px;color:rgba(0, 0, 0, 0.9);font-family:&#34;PingFang SC NEW&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size:16px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:0.544px;orphans:2;text-align:start;text-indent:0px;text-transform:none;widows:2;word-spacing:0px;-webkit-text-stroke-width:0px;white-space:normal;background-color:rgb(255, 255, 255);text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;user-select:auto;width:100%;" data-w="1080" src="https://wechat2rss.xlab.app/img-proxy/?k=31c4d5e9&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FFMFU1P6sHHsw7RKzgrohFuSOibiajHLMvF9lWpgzJpheQyOcdWscJic9aCFIuGN2te8t6Qp1fs5Y6L4EM1YBrOFCxumsUxCWKAFOicfR6IeSebA%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg%26tp%3Dwxpic%26wxfrom%3D5%26wx_lazy%3D1%23imgIndex%3D3"/></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">Agent 四层记忆模型</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">四层分别对应不同的生命周期：Working Memory 只服务当前一步推理；Session Memory 保存会话内的消息历史；User Memory 记录跨 Agent 共享的偏好和稳定事实，对应 MemOS 的 user_profile；Agent Memory 保存某个 Agent 的任务经验和协作约定，对应 agent_{agentId}。会话结束后，新增消息经过判断和去重，再从 Session 层沉淀到 User 或 Agent 层。</span></span></p><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img" data-aistatus="1" data-imgfileid="100153996" data-ratio="0.8044806517311609" data-s="300,640" type="block" data-type="png" data-w="982" src="https://wechat2rss.xlab.app/img-proxy/?k=37c73bb6&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYaEfhWuvpXWPseIpSicbagLu1xxDzFhicvtfQ61uTvfJ2icg6Pn4Bb18aw63OLicrUiabBtYkSic0ot9c0abSuvh13uibjtQQ4ry1ia89w%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Agent 四层记忆模型：Working、Session、User 与 Agent Memory 的读取、作用域和异步沉淀链路。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">1、记忆类型</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img class="rich_pages wxw-img" data-aistatus="1" data-backh="696" data-backw="578" data-ratio="1.2043956043956043" style="-webkit-tap-highlight-color:rgba(0, 0, 0, 0);margin:0px;padding:0px;outline:0px;color:rgba(0, 0, 0, 0.9);font-family:&#34;PingFang SC NEW&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size:16px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:0.544px;orphans:2;text-align:start;text-indent:0px;text-transform:none;widows:2;word-spacing:0px;-webkit-text-stroke-width:0px;white-space:normal;background-color:rgb(255, 255, 255);text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;user-select:auto;width:100%;" data-w="910" src="https://wechat2rss.xlab.app/img-proxy/?k=01599a4c&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FFMFU1P6sHHuibvJqrXVRZ2Az7cCfW9ZibmC0le4zmrial17pnl6f0M1YTeu1E3pAJpJSNh1kZaqREx3MvgR7ammWsbISVHJXiaZCn1ApFib7VlBk%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg%26tp%3Dwxpic%26wxfrom%3D5%26wx_lazy%3D1%23imgIndex%3D5"/></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">四层模型与 MemOS 类型是两套分类维度：</span>四层模型描述信息的生命周期和作用域；MemOS 的 text_mem、pref_mem、skill_mem、tool_mem 描述记忆内容形态，不能直接与四层一一对应。</span></span></p><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.15092592592592594" data-s="300,640" data-type="png" data-w="1080" style="width:100%;" type="block" data-backw="578" data-backh="87" data-imgfileid="100153999" src="https://wechat2rss.xlab.app/img-proxy/?k=cc363bfd&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYYybicic161lq59D3bicosaIU3icc29AVNa6Mea0QWVGickicpo3WgADOGUibuxvQ8PcC5PLib0NxCfvhUiaauic1I3lJYLE8RlVlOZ2a2L4%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">当前路由行为：</span>longMemoryProvider 未配置、Agent 不存在或读取配置异常时，MemoryRpcServiceImpl 选择 MySQL；明确配置为 MEMOS 或 Mem0 时才进入对应 Provider。MemOS 查询异常由 Provider 自身记录日志并返回空结果，当前不会自动切换到 MySQL。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">2、记忆加载流程</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.7194444444444444" data-w="1080" style="-webkit-tap-highlight-color:rgba(0, 0, 0, 0);margin:0px;padding:0px;outline:0px;color:rgba(0, 0, 0, 0.9);font-family:&#34;PingFang SC NEW&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size:16px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:0.544px;orphans:2;text-align:start;text-indent:0px;text-transform:none;widows:2;word-spacing:0px;-webkit-text-stroke-width:0px;white-space:normal;background-color:rgb(255, 255, 255);text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;user-select:auto;width:100%;" data-backw="578" data-backh="416" src="https://wechat2rss.xlab.app/img-proxy/?k=ec3ff2c7&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FFMFU1P6sHHtd0656PjpkAnWN3gZCTlicJw845W7XNP5DtmaGcsicaqoicicXbr3Qs8U2dbp4DWQkicLFhJlnoYib7rQoeSmWKiaylJdbgh23QvBibR8%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg%26tp%3Dwxpic%26wxfrom%3D5%26wx_lazy%3D1%23imgIndex%3D7"/></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">一次请求的记忆路径</span>可以概括为：AgentExecutor<a class="wx_topic_link" data-recommend="" data-topic="1" style="color: #576B95 !important;" topic-id="mtkyt23o-hijmvv">#execute</a> 解析上下文参数后，在 memoryLoadExecutor 中并行启动短期记忆和长期记忆 Future。短期链路读取 ConversationMemory；长期链路调用 queryMemory，由 MemoryRpcServiceImpl 按 Agent 配置选择 MEMOS、Mem0 或 MySQL。</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">长期记忆检索返回后，平台按 user_profile 与 agent 分组，过滤敏感或低相关内容，并限制每个 scope 的条数。</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">随后以固定 tokens 为默认预算，优先满足用户画像，再把剩余预算分配给 Agent 专属记忆。</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">最终结果写入 AgentContext，与短期消息一起参与后续模型调用；会话结束后再异步触发长期记忆沉淀和上下文摘要。 </span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">实现边界：</span>平台的 ConversationMemory 负责会话历史读取和窗口裁剪；AgentScope Harness 的 state store 负责会话状态持久化，有 Sandbox 时使用共享工作区文件存储，没有 Sandbox 时回退到内存存储。当前 ModelInvoker 主链路构造 Harness 消息时，以本轮 userMsg 为入口，因此不能简单理解为 Redis/MySQL 历史会被无条件直接拼进每一次 AgentScope Prompt。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">3、短期记忆 vs 长期记忆</span></strong></span></p></div></div></div><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.3731481481481482" data-s="300,640" data-type="png" data-w="1080" style="width:100%;" type="block" data-backw="578" data-backh="216" data-imgfileid="100154002" src="https://wechat2rss.xlab.app/img-proxy/?k=5adac161&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYZic5XFBibPr01oYdU1QrBQ7ONoIBcve9KTbVkp8zXxa0mHuhxk20o0Cib3HT2JXx5UnoPZictGwlQ0lF51obCVkQ9O38qyDq0MWaQ%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">4、关键组件及方法</span></strong></span></p></div></div></div><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.2972222222222222" data-s="300,640" data-type="png" data-w="1080" type="block" data-imgfileid="100154004" src="https://wechat2rss.xlab.app/img-proxy/?k=c28f7241&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYZqzGMhhbZVHXXGhVOyaottgf3nMk5VTer8Vw8mV0ZHJ3R0iasz3ymcoQZV5gDQKm4MiaCUtpOW67KX3BQI2pjic1Qus0k39HibibMU%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">三、短期记忆加载详情</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">短期记忆（Session Memory）保存当前会话中按时间排列的对话历史，是指代消解和多轮推理的直接上下文。实现重点是读取时延、Redis/MySQL 回退以及 Token 窗口控制。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="1.8728121353558926" data-w="857" style="-webkit-tap-highlight-color:rgba(0, 0, 0, 0);margin:0px;padding:0px;outline:0px;color:rgba(0, 0, 0, 0.9);font-family:&#34;PingFang SC NEW&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size:16px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:0.544px;orphans:2;text-align:start;text-indent:0px;text-transform:none;widows:2;word-spacing:0px;-webkit-text-stroke-width:0px;white-space:normal;background-color:rgb(255, 255, 255);text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;user-select:auto;width:100%;" data-backw="578" data-backh="1082" src="https://wechat2rss.xlab.app/img-proxy/?k=036de3f9&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FFMFU1P6sHHsicibmGaN0wCa47iaScMZ4z3lvzHDX4S4AuVmiaibXRibSicY9oIBQ303q3HM9jmUahQyfjBPiatGdFnP9W5vkOMPmmwQ5jrcoog5v7CI%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg%26tp%3Dwxpic%26wxfrom%3D5%26wx_lazy%3D1%23imgIndex%3D10"/></span></span></p><p style="line-height: 1.75;text-align: center;"><span style="font-size: 15px;color: rgb(62, 62, 62);"><span leaf=""><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">加载流程图</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">调用链说明：</span></span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">AgentExecutor 从 AgentContext 获取 AgentConfig → ModelBindConfigDto → contextRounds。</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">AgentExecutor 调用 chatMemory.get(conversationId, contextRounds * 3)。</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">chatMemory 是 ConversationMemory 接口，由 ConversationApplicationServiceImpl 实现。</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">实现类优先从 Redis 读取，失败则从 MySQL 回退。</span></span></p></li></ul><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">1、关键实现</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">完整实现还包括消息类型转换、system 消息拆分及工具调用信息处理。下面只保留“读取 → 交替校验 → Token 窗口判断”的主路径，便于理解短期记忆如何形成模型上下文。</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="java"><code><span leaf=""><span class="code-snippet__comment">// DTO 已转换为 Message，system/tool 消息已拆分</span></span></code><br/><code><span leaf="">trimAlternationFromEnd(chatMsgs);</span></code><br/><code><span leaf=""><span class="code-snippet__type">int</span> <span class="code-snippet__variable">windowSize</span> <span class="code-snippet__operator">=</span> MAX_TOKEN_WINDOW_SIZE - SUMMARY_TOKEN_BUDGET;</span></code><br/><code><span leaf=""><span class="code-snippet__type">int</span> <span class="code-snippet__variable">totalTokens</span> <span class="code-snippet__operator">=</span> <span class="code-snippet__number">0</span>, recentTokens = <span class="code-snippet__number">0</span>;</span></code><br/><code><span leaf=""><span class="code-snippet__type">boolean</span> <span class="code-snippet__variable">overLimit</span> <span class="code-snippet__operator">=</span> <span class="code-snippet__literal">false</span>;</span></code><br/><code><span leaf=""><span class="code-snippet__type">List</span>&lt;Message&gt; <span class="code-snippet__variable">recentWindow</span> <span class="code-snippet__operator">=</span> <span class="code-snippet__keyword">new</span> <span class="code-snippet__title">ArrayList</span>&lt;&gt;();</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">for</span> (<span class="code-snippet__type">int</span> <span class="code-snippet__variable">i</span> <span class="code-snippet__operator">=</span> chatMsgs.size() - <span class="code-snippet__number">1</span>; i &gt;= <span class="code-snippet__number">0</span>; i--) {</span></code><br/><code><span leaf="">    <span class="code-snippet__type">Message</span> <span class="code-snippet__variable">message</span> <span class="code-snippet__operator">=</span> chatMsgs.get(i);</span></code><br/><code><span leaf="">    <span class="code-snippet__type">int</span> <span class="code-snippet__variable">tokens</span> <span class="code-snippet__operator">=</span> TikTokensUtil.tikTokensCount(message.getText());</span></code><br/><code><span leaf="">    totalTokens += tokens;</span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">if</span> (!overLimit &amp;&amp; recentTokens + tokens &lt;= windowSize) {</span></code><br/><code><span leaf="">        recentWindow.add(<span class="code-snippet__number">0</span>, message);</span></code><br/><code><span leaf="">        recentTokens += tokens;</span></code><br/><code><span leaf="">    } <span class="code-snippet__keyword">else</span> {</span></code><br/><code><span leaf="">        overLimit = <span class="code-snippet__literal">true</span>;</span></code><br/><code><span leaf="">    }</span></code><br/><code><span leaf="">}</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">if</span> (totalTokens &lt;= MAX_TOKEN_WINDOW_SIZE) {</span></code><br/><code><span leaf="">    removeLeadingAssistant(chatMsgs);</span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">return</span> mergeSystemAndChat(systemMsgs, chatMsgs);</span></code><br/><code><span leaf="">}</span></code><br/><code><span leaf="">removeLeadingAssistant(recentWindow);</span></code><br/><code><span leaf=""><span class="code-snippet__type">String</span> <span class="code-snippet__variable">summaryMd</span> <span class="code-snippet__operator">=</span> iMemoryRpcService.getConversationSummaryMd(Long.parseLong(cid));</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">if</span> (StringUtils.isNotBlank(summaryMd)) {</span></code><br/><code><span leaf="">    recentWindow.add(<span class="code-snippet__number">0</span>, <span class="code-snippet__keyword">new</span> <span class="code-snippet__title">SystemMessage</span>(summaryMd));</span></code><br/><code><span leaf="">}</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">return</span> recentWindow;</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">Redis 优先读取，类说明：</span>ConversationApplicationServiceImpl<a class="wx_topic_link" data-recommend="" data-topic="1" style="color: #576B95 !important;" topic-id="mtkyt23o-gyqeea">#getMessagesFromCache</a> 先读取 Redis List，命中后把 JSON 转为 ChatMessageDto，并翻转为 oldest-first；未命中或读取异常则查询 MySQL，再按倒序 leftPush 回写，设置 CACHE_TTL_SECONDS，并用 rightPop 按 MAX_CACHED_MESSAGES 淘汰最旧消息。逐条解析和异常日志属于防御性代码，这里不展开。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">2、Redis 存储结构实现细节</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">使用 leftPush 写入，最新消息在 index 0；当前实现使用 range(0, Long.MAX_VALUE) 读取 Redis 列表，再在应用层做窗口裁剪；使用 rightPop 移除最旧消息 需要注意，ConversationMemory<a class="wx_topic_link" data-recommend="" data-topic="1" style="color: #576B95 !important;" topic-id="mtkyt23p-rdk0yy">#get</a>(String, int) 的 lastN 参数当前未参与 Redis 的 range 边界计算；实际读取范围由 Redis 列表内容和后续 Token 窗口共同决定。Redis 只承担热点缓存，MySQL 仍是冷启动回源和持久化兜底。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">3、Token 窗口控制策略</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="2.131" data-w="1000" style="-webkit-tap-highlight-color:rgba(0, 0, 0, 0);margin:0px;padding:0px;outline:0px;color:rgba(0, 0, 0, 0.9);font-family:&#34;PingFang SC NEW&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size:16px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:0.544px;orphans:2;text-align:start;text-indent:0px;text-transform:none;widows:2;word-spacing:0px;-webkit-text-stroke-width:0px;white-space:normal;background-color:rgb(255, 255, 255);text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;user-select:auto;width:100%;" data-backw="578" data-backh="1232" src="https://wechat2rss.xlab.app/img-proxy/?k=44f1cca4&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FFMFU1P6sHHuYd4GUQoHY8QZJaoSA5uxhdh85hPs7Q7pdAsvKnrODribYA3chrZETicocMSCYjibm8xT5UuMlk5QhKXI5Dk1picwAdzueGhbeFwQ%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg%26tp%3Dwxpic%26wxfrom%3D5%26wx_lazy%3D1%23imgIndex%3D11"/></span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">四、短期记忆写入详情</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.5694444444444444" data-w="1080" style="-webkit-tap-highlight-color:rgba(0, 0, 0, 0);margin:0px;padding:0px;outline:0px;color:rgba(0, 0, 0, 0.9);font-family:&#34;PingFang SC NEW&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size:16px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:0.544px;orphans:2;text-align:start;text-indent:0px;text-transform:none;widows:2;word-spacing:0px;-webkit-text-stroke-width:0px;white-space:normal;background-color:rgb(255, 255, 255);text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;user-select:auto;width:100%;" data-backw="578" data-backh="329" src="https://wechat2rss.xlab.app/img-proxy/?k=ee6c2a84&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FFMFU1P6sHHsXsCcVgico5GfzUyMasvo5JtDsian6bhbHS2jtmIYKTW83c1AjMLHVBg57qm0af7kQpuvjoIhRibultl0d7OgiamkQf9fuuZERvdQ%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg%26tp%3Dwxpic%26wxfrom%3D5%26wx_lazy%3D1%23imgIndex%3D12"/></span></span></p><p style="line-height: 1.75;text-align: center;"><span style="font-size: 15px;color: rgb(62, 62, 62);"><span leaf=""><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">写入时序图</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">双写的意义——MySQL ：</span>持久化兜底防止数据丢失。Redis： 高性能读取支撑实时对话。<span textstyle="" style="font-weight: bold;">回退机制：</span> Redis 失败时仍可从 MySQL 回退读取。</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="java"><code><span leaf="">messages.forEach(message -&gt; {</span></code><br/><code><span leaf="">    <span class="code-snippet__type">String</span> <span class="code-snippet__variable">conversationId0</span> <span class="code-snippet__operator">=</span> conversationId;</span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">if</span> (conversationId0.startsWith(<span class="code-snippet__string">&#34;agent:&#34;</span>)) {</span></code><br/><code><span leaf="">        <span class="code-snippet__comment">// 子 Agent 的非 ChatMessage 不写入主会话，避免虚拟会话污染主链路。</span></span></code><br/><code><span leaf="">        <span class="code-snippet__keyword">if</span> (message <span class="code-snippet__keyword">instanceof</span> ChatMessageDto) {</span></code><br/><code><span leaf="">            conversationId0 = conversationId.replace(<span class="code-snippet__string">&#34;agent:&#34;</span>, <span class="code-snippet__string">&#34;&#34;</span>);</span></code><br/><code><span leaf="">        } <span class="code-snippet__keyword">else</span> {</span></code><br/><code><span leaf="">            <span class="code-snippet__keyword">return</span>;</span></code><br/><code><span leaf="">        }</span></code><br/><code><span leaf="">    }</span></code><br/><code><span leaf="">    <span class="code-snippet__type">ChatMessageDto</span> <span class="code-snippet__variable">chatMessage</span> <span class="code-snippet__operator">=</span> ...; <span class="code-snippet__comment">// 类型转换、清洗文本并补齐租户字段</span></span></code><br/><code><span leaf="">    <span class="code-snippet__type">ConversationMessage</span> <span class="code-snippet__variable">conversationMessage</span> <span class="code-snippet__operator">=</span> ...;</span></code><br/><code><span leaf="">    <span class="code-snippet__comment">// 先落 MySQL，Redis 只作为可失效的热点缓存。</span></span></code><br/><code><span leaf="">    <span class="code-snippet__type">Long</span> <span class="code-snippet__variable">messageId</span> <span class="code-snippet__operator">=</span> TenantFunctions.callWithTenantId(chatMessage.getTenantId(),</span></code><br/><code><span leaf="">        () -&gt; conversationDomainService.addConversationMessage(conversationMessage));</span></code><br/><code><span leaf="">    chatMessage.setIndex(messageId);</span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">try</span> {</span></code><br/><code><span leaf="">        <span class="code-snippet__type">String</span> <span class="code-snippet__variable">key</span> <span class="code-snippet__operator">=</span> generateConversationKey(conversationId0);</span></code><br/><code><span leaf="">        redisUtil.leftPush(key, JSON.toJSONString(chatMessage));</span></code><br/><code><span leaf="">        redisUtil.expire(key, CACHE_TTL_SECONDS);</span></code><br/><code><span leaf="">        <span class="code-snippet__type">long</span> <span class="code-snippet__variable">size</span> <span class="code-snippet__operator">=</span> redisUtil.size(key);</span></code><br/><code><span leaf="">        <span class="code-snippet__comment">// 最新消息在表头，超出 200 条时从尾部淘汰最旧消息。</span></span></code><br/><code><span leaf="">        <span class="code-snippet__keyword">if</span> (size &gt; MAX_CACHED_MESSAGES) {</span></code><br/><code><span leaf="">            redisUtil.rightPop(key);</span></code><br/><code><span leaf="">        }</span></code><br/><code><span leaf="">    } <span class="code-snippet__keyword">catch</span> (Exception e) {</span></code><br/><code><span leaf="">        <span class="code-snippet__comment">// 缓存失败不回滚已完成的 MySQL 写入，读取时会回源数据库。</span></span></code><br/><code><span leaf="">        log.warn(<span class="code-snippet__string">&#34;Failed to cache message to Redis, conversationId={}&#34;</span>, conversationId0, e);</span></code><br/><code><span leaf="">    }</span></code><br/><code><span leaf="">});</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">短期消息写入后，onSessionEndAsync 还会检查会话摘要：当未被摘要覆盖的消息达到 20 条才触发摘要生成，摘要注入预算约 2000 tokens，并在 Redis 缓存 1 小时。这样做把高频对话写入与低频摘要合并拆开，避免每轮都调用摘要模型。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">五、长期记忆加载实现详解</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.6953703703703704" data-w="1080" style="-webkit-tap-highlight-color:rgba(0, 0, 0, 0);margin:0px;padding:0px;outline:0px;color:rgba(0, 0, 0, 0.9);font-family:&#34;PingFang SC NEW&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size:16px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:0.544px;orphans:2;text-align:start;text-indent:0px;text-transform:none;widows:2;word-spacing:0px;-webkit-text-stroke-width:0px;white-space:normal;background-color:rgb(255, 255, 255);text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;user-select:auto;width:100%;" data-backw="578" data-backh="402" src="https://wechat2rss.xlab.app/img-proxy/?k=c51753dd&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FFMFU1P6sHHsExWJsNfXLPytmuv9hm6a1y22IRkp0qwTT5H37PEpcCb9CP0S7S97hVYtnvPNxjSnFRqUiabbMpl1QOrj5vvfM8UOibauLuw3Y8%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg%26tp%3Dwxpic%26wxfrom%3D5%26wx_lazy%3D1%23imgIndex%3D13"/></span></span></p><p style="line-height: 1.75;text-align: center;"><span style="font-size: 15px;color: rgb(62, 62, 62);"><span leaf=""><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">加载时序图</span></span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">1、并行加载设计</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">在 Agent 执行入口 AgentExecutor<a class="wx_topic_link" data-recommend="" data-topic="1" style="color: #576B95 !important;" topic-id="mtkyt23p-4vugzp">#execute</a> 中，我们采用 CompletableFuture 实现短期记忆和长期记忆的并行加载：</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="typescript"><code><span leaf="">final int finalContextRounds = contextRounds;</span></code><br/><code><span leaf=""><span class="code-snippet__title">CompletableFuture</span>&lt;<span class="code-snippet__title">List</span>&lt;<span class="code-snippet__title">Message</span>&gt;&gt; contextMessagesFuture = <span class="code-snippet__title">CompletableFuture</span>.<span class="code-snippet__title">supplyAsync</span>(() -&gt; {</span></code><br/><code><span leaf="">    <span class="code-snippet__comment">// contextRounds=0 是合法配置，直接跳过短期历史读取。</span></span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">if</span> (finalContextRounds &lt;= <span class="code-snippet__number">0</span>) {</span></code><br/><code><span leaf="">        <span class="code-snippet__keyword">return</span> <span class="code-snippet__keyword">new</span> <span class="code-snippet__title">ArrayList</span>&lt;<span class="code-snippet__title">Message</span>&gt;();</span></code><br/><code><span leaf="">    }</span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">return</span> <span class="code-snippet__keyword">new</span> <span class="code-snippet__title">ArrayList</span>&lt;&gt;(</span></code><br/><code><span leaf="">        chatMemory.<span class="code-snippet__title">get</span>(agentContext.<span class="code-snippet__title">getConversationId</span>(), finalContextRounds * <span class="code-snippet__number">3</span>));</span></code><br/><code><span leaf="">}, memoryLoadExecutor);</span></code><br/><code><span leaf=""><span class="code-snippet__title">CompletableFuture</span>&lt;<span class="code-snippet__title">Map</span>&lt;<span class="code-snippet__title">String</span>, <span class="code-snippet__title">String</span>&gt;&gt; longMemoryFuture = <span class="code-snippet__title">CompletableFuture</span>.<span class="code-snippet__title">supplyAsync</span>(() -&gt; {</span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">if</span> (agentContext.<span class="code-snippet__title">getAgentConfig</span>().<span class="code-snippet__title">getOpenLongMemory</span>() != <span class="code-snippet__title">AgentConfig</span>.<span class="code-snippet__property">OpenStatus</span>.<span class="code-snippet__property">Open</span>) {</span></code><br/><code><span leaf="">        <span class="code-snippet__keyword">return</span> <span class="code-snippet__title">Collections</span>.<span class="code-snippet__title">emptyMap</span>();</span></code><br/><code><span leaf="">    }</span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">try</span> {</span></code><br/><code><span leaf="">        <span class="code-snippet__title">AgentComponentConfigDto</span> modelComponentConfig =</span></code><br/><code><span leaf="">            agentContext.<span class="code-snippet__title">getAgentConfig</span>().<span class="code-snippet__title">getModelComponentConfig</span>();</span></code><br/><code><span leaf="">        <span class="code-snippet__comment">// queryMemory 需要绑定模型的 targetId，未绑定时不发起长期检索。</span></span></code><br/><code><span leaf="">        <span class="code-snippet__keyword">if</span> (modelComponentConfig == <span class="code-snippet__literal">null</span> || modelComponentConfig.<span class="code-snippet__title">getTargetId</span>() == <span class="code-snippet__literal">null</span>) {</span></code><br/><code><span leaf="">            <span class="code-snippet__keyword">return</span> <span class="code-snippet__title">Collections</span>.<span class="code-snippet__title">emptyMap</span>();</span></code><br/><code></code><br/><code><span leaf="">        }</span></code><br/><code><span leaf="">        <span class="code-snippet__built_in">boolean</span> justKeywordMatch = <span class="code-snippet__title">resolveJustKeywordMatch</span>(agentContext);</span></code><br/><code><span leaf="">        <span class="code-snippet__comment">// originalMessage 是主查询词；此处 context 为空，短期历史不会反向增强本次 query。</span></span></code><br/><code><span leaf="">        <span class="code-snippet__keyword">return</span> conversationApplicationService.<span class="code-snippet__title">queryMemory</span>(</span></code><br/><code><span leaf="">            agentContext.<span class="code-snippet__title">getUser</span>().<span class="code-snippet__title">getTenantId</span>(), agentContext.<span class="code-snippet__title">getUser</span>().<span class="code-snippet__title">getId</span>(),</span></code><br/><code><span leaf="">            agentContext.<span class="code-snippet__title">getAgentConfig</span>().<span class="code-snippet__title">getId</span>(), modelComponentConfig.<span class="code-snippet__title">getTargetId</span>(),</span></code><br/><code><span leaf="">            agentContext.<span class="code-snippet__title">getOriginalMessage</span>(), <span class="code-snippet__string">&#34;&#34;</span>, justKeywordMatch,</span></code><br/><code><span leaf="">            agentContext.<span class="code-snippet__title">isFilterSensitive</span>());</span></code><br/><code><span leaf="">    } <span class="code-snippet__keyword">catch</span> (<span class="code-snippet__title">Exception</span> e) {</span></code><br/><code><span leaf="">        <span class="code-snippet__comment">// 长期记忆是增强能力，查询失败时让主对话继续。</span></span></code><br/><code><span leaf="">        log.<span class="code-snippet__title">warn</span>(<span class="code-snippet__string">&#34;查询长期记忆失败&#34;</span>, e);</span></code><br/><code><span leaf="">        <span class="code-snippet__keyword">return</span> <span class="code-snippet__title">Collections</span>.<span class="code-snippet__title">emptyMap</span>();</span></code><br/><code><span leaf="">    }</span></code><br/><code><span leaf="">}, memoryLoadExecutor);</span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf=""><span class="code-snippet__comment">// 这里才是并行结果的汇合点，主流程等待两条记忆链路都完成。</span></span></code><br/><code><span leaf="">agentContext.<span class="code-snippet__title">setContextMessages</span>(contextMessagesFuture.<span class="code-snippet__title">join</span>());</span></code><br/><code><span leaf=""><span class="code-snippet__title">Map</span>&lt;<span class="code-snippet__title">String</span>, <span class="code-snippet__title">String</span>&gt; longMemoryMap = longMemoryFuture.<span class="code-snippet__title">join</span>();</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">设计要点：</span>使用专用线程池 memoryLoadExecutor，避免 ForkJoinPool.commonPool 争抢；长期记忆不阻塞短期记忆，用空 context 先行查询。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">边界与降级：</span>关闭 openLongMemory 时长期 Future 直接返回空 Map；Agent 未绑定模型时跳过长期检索；查询异常也会记录 warning 并返回空结果，主对话继续执行。当前长期查询以 originalMessage 作为主检索词，和短期记忆的读取互不等待，因此并行带来的是执行重叠，不是&#34;短期历史已注入后再增强查询&#34;。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">2、语义检索实现</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">MemOS Search 请求保留以下参数；context 非空时，平台只取前 200 个字符拼到 userMessage 后作为 query。调用链虽然携带 justKeywordSearch，但当前 MemosMemoryApplicationService 未据此切换检索模式，仍固定调用 MemOS Search。</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="java"><code><span leaf=""><span class="code-snippet__type">List</span>&lt;String&gt; <span class="code-snippet__variable">readableCubeIds</span> <span class="code-snippet__operator">=</span> <span class="code-snippet__keyword">new</span> <span class="code-snippet__title">ArrayList</span>&lt;&gt;();</span></code><br/><code><span leaf="">readableCubeIds.add(<span class="code-snippet__string">&#34;user_profile&#34;</span>);</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">if</span> (agentId != <span class="code-snippet__literal">null</span>) {</span></code><br/><code><span leaf="">    readableCubeIds.add(<span class="code-snippet__string">&#34;agent_&#34;</span> + agentId);</span></code><br/><code><span leaf="">}</span></code><br/><code><span leaf="">MemOSClient.<span class="code-snippet__type">SearchRequest</span> <span class="code-snippet__variable">searchRequest</span> <span class="code-snippet__operator">=</span> <span class="code-snippet__keyword">new</span> <span class="code-snippet__title">MemOSClient</span>.SearchRequest();</span></code><br/><code><span leaf=""><span class="code-snippet__comment">// 一次 Search 同时覆盖用户画像和当前 Agent 的记忆 cube。</span></span></code><br/><code><span leaf="">searchRequest.setQuery(buildSearchQuery(userMessage, context));</span></code><br/><code><span leaf="">searchRequest.setUserId(memOSUserId);</span></code><br/><code><span leaf="">searchRequest.setTopK(DEFAULT_TOP_K);</span></code><br/><code><span leaf="">searchRequest.setMode(<span class="code-snippet__string">&#34;fast&#34;</span>);</span></code><br/><code><span leaf="">searchRequest.setRelativity(<span class="code-snippet__number">0.45</span>);</span></code><br/><code><span leaf="">searchRequest.setDedup(<span class="code-snippet__string">&#34;mmr&#34;</span>);</span></code><br/><code><span leaf="">searchRequest.setReadableCubeIds(readableCubeIds);</span></code><br/><code><span leaf="">searchRequest.setIncludePreference(<span class="code-snippet__literal">true</span>);</span></code><br/><code><span leaf="">searchRequest.setPrefTopK(<span class="code-snippet__number">6</span>);</span></code><br/><code><span leaf=""><span class="code-snippet__type">List</span>&lt;MemOSMemory&gt; <span class="code-snippet__variable">searchResults</span> <span class="code-snippet__operator">=</span></span></code><br/><code><span leaf="">    memOSClient.searchMemory(searchRequest).getMemories();</span></code><br/><code><span leaf=""><span class="code-snippet__comment">// 转换阶段会过滤低分结果、截断单条内容，再按 score 降序返回。</span></span></code><br/><code><span leaf="">result.addAll(convertToMemoryUnitDTOs(searchResults, tenantId, userId, agentId));</span></code><br/><code><span leaf="">result.sort((a, b) -&gt; {</span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">if</span> (a.getScore() == <span class="code-snippet__literal">null</span> &amp;&amp; b.getScore() == <span class="code-snippet__literal">null</span>) <span class="code-snippet__keyword">return</span> <span class="code-snippet__number">0</span>;</span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">if</span> (a.getScore() == <span class="code-snippet__literal">null</span>) <span class="code-snippet__keyword">return</span> <span class="code-snippet__number">1</span>;</span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">if</span> (b.getScore() == <span class="code-snippet__literal">null</span>) <span class="code-snippet__keyword">return</span> -<span class="code-snippet__number">1</span>;</span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">return</span> Double.compare(b.getScore(), a.getScore());</span></code><br/><code><span leaf="">});</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">搜索参数说明：</span></span></span></p><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.24722222222222223" data-s="300,640" data-type="png" data-w="1080" type="block" data-imgfileid="100154007" src="https://wechat2rss.xlab.app/img-proxy/?k=eb5d6be8&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYbCgqLLrBla681ibuc63L7OD20gpAMpNDhnm858wq2Zp9wgibJtibjM8MnjRv1MbBfkQVMRSGRmbhibzha82EQv3ib5R7LXECT0HrSs%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">readableCubeIds 当前包含 user_profile 和 agent_{agentId}；同时开启 preference 检索，prefTopK=6 用于补充用户偏好。检索结果随后还会经过 score &lt; 0.3 过滤和单条 1000 字符截断，避免低相关或过长内容挤占上下文。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">3、Token Budget 分配策略</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">以下片段承接 5.2 的检索结果，userProfileRaw 与 agentMemoryRaw 分别是按 scope 汇总后的文本。为防止记忆撑爆 Agent 上下文，我们设计了 Token Budget 分配机制。</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="cs"><code><span leaf=""><span class="code-snippet__built_in">int</span> budget = DEFAULT_LONG_MEMORY_TOKEN_BUDGET; <span class="code-snippet__comment">// 4000 tokens</span></span></code><br/><code><span leaf=""><span class="code-snippet__built_in">int</span> userProfileRawTokens =</span></code><br/><code><span leaf="">    TikTokensUtil.tikTokensCount(userProfileRaw != <span class="code-snippet__literal">null</span> ? userProfileRaw : <span class="code-snippet__string">&#34;&#34;</span>);</span></code><br/><code><span leaf=""><span class="code-snippet__comment">// user_profile 最多占 60%；实际未用满时，剩余预算让给 Agent 记忆。</span></span></code><br/><code><span leaf=""><span class="code-snippet__keyword">if</span> (userProfileRawTokens &lt;= budget * <span class="code-snippet__number">0.6</span>) {</span></code><br/><code><span leaf="">    userProfile = userProfileRaw;</span></code><br/><code><span leaf="">    agentMemory = truncateLongMemory(agentMemoryRaw, budget - userProfileRawTokens);</span></code><br/><code><span leaf="">} <span class="code-snippet__keyword">else</span> {</span></code><br/><code><span leaf="">    userProfile = truncateLongMemory(userProfileRaw, (<span class="code-snippet__built_in">int</span>) (budget * <span class="code-snippet__number">0.6</span>));</span></code><br/><code><span leaf="">    <span class="code-snippet__comment">// 重新计算截断后的 token 数，避免把截断前的估算带入剩余预算。</span></span></code><br/><code><span leaf="">    <span class="code-snippet__built_in">int</span> userProfileTokens =</span></code><br/><code><span leaf="">        TikTokensUtil.tikTokensCount(userProfile != <span class="code-snippet__literal">null</span> ? userProfile : <span class="code-snippet__string">&#34;&#34;</span>);</span></code><br/><code><span leaf="">    agentMemory = truncateLongMemory(agentMemoryRaw, budget - userProfileTokens);</span></code><br/><code><span leaf="">}</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">截断算法采用按行截断，保留完整语义：</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="javascript"><code><span leaf=""><span class="code-snippet__title">String</span>[] lines = longMemory.<span class="code-snippet__title">split</span>(<span class="code-snippet__string">&#34;\n&#34;</span>, -<span class="code-snippet__number">1</span>);</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">for</span> (<span class="code-snippet__title">String</span> line : lines) {</span></code><br/><code><span leaf="">    <span class="code-snippet__comment">// 按行累计 token，尽量保留一条记忆的完整内容。</span></span></code><br/><code><span leaf="">    int lineTokens = <span class="code-snippet__title">TikTokensUtil</span>.<span class="code-snippet__title">tikTokensCount</span>(line + <span class="code-snippet__string">&#34;\n&#34;</span>);</span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">if</span> (currentTokens + lineTokens &gt; budget) {</span></code><br/><code><span leaf="">        <span class="code-snippet__keyword">break</span>;</span></code><br/><code><span leaf="">    }</span></code><br/><code><span leaf="">    truncated.<span class="code-snippet__title">append</span>(line);</span></code><br/><code><span leaf="">    currentTokens += lineTokens;</span></code><br/><code><span leaf="">}</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">user_profile 最多占 60% 预算；如果实际占用更少，剩余空间分给 Agent 记忆。两类内容都按行累加 token，达到预算后停止追加，避免拆散单条记忆。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">六、长期记忆写入实现详解</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.9064814814814814" data-w="1080" style="-webkit-tap-highlight-color:rgba(0, 0, 0, 0);margin:0px;padding:0px;outline:0px;color:rgba(0, 0, 0, 0.9);font-family:&#34;PingFang SC NEW&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size:16px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:0.544px;orphans:2;text-align:start;text-indent:0px;text-transform:none;widows:2;word-spacing:0px;-webkit-text-stroke-width:0px;white-space:normal;background-color:rgb(255, 255, 255);text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;user-select:auto;width:100%;" data-backw="578" data-backh="524" src="https://wechat2rss.xlab.app/img-proxy/?k=42ec6c4d&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FFMFU1P6sHHuhwHYiaVR33pL5UILUGvT676BMeL5t3TrYHJ7oqxxf2ypLC3pa4JBusjBxtrEey07SSobMbBWwakjQadOf2kOBrphczrZWKkiaw%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg%26tp%3Dwxpic%26wxfrom%3D5%26wx_lazy%3D1%23imgIndex%3D15"/></span></span></p><p style="line-height: 1.75;text-align: center;"><span style="font-size: 15px;color: rgb(62, 62, 62);"><span leaf=""><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">写入时序图</span></span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">1、写入入口与去重</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">会话结束时，系统触发记忆写入流程，首先使用 Redis Set 记录已处理消息的 hash 并做去重。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">类说明：</span>MemoryRpcServiceImpl 负责会话结束后的写入编排，onSessionEndAsync 先获取会话级 Redis 锁，再由 processSessionEnd 按消息 hash 过滤本次新增内容并提前记录已处理 hash，随后根据 Agent 配置选择 provider：MemOS 路径先进行 LLM 记忆判断，再交给 MemoryPersistenceServiceImpl 持久化；MySQL、Mem0 路径则组装完整上下文和最新 user 输入后调用 createMemory。记忆处理完成后，同一异步线程继续检查是否需要生成上下文摘要。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">设计要点：</span></span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">分布式锁防止并发处理同一会话。</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">MD5(role:content) 生成消息唯一标识。</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">TTL 7 天自动清理过期记录。</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">onSessionEndAsync 使用 10 分钟的会话锁，已处理消息 hash 的 TTL 为 7 天。hash 会在 LLM 判断和 MemOS 持久化之前写入，用来挡住重复结束事件。但这一层属于 best-effort：Redis 读取失败时，当前实现会把整段会话作为新增内容继续处理；hash 写入失败也只记录日志。外部服务失败后没有自动回放，因此运行侧需要同时关注重复写入和处理未完成两类异常。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">2、LLM 智能判断</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">完整 Prompt 定义了记忆类别、scope、importance 和 JSON 输出约束，下面只保留新增消息标记与模型调用主线。judge 会先调用 LLM；调用异常或返回为空时，降级到仅基于新增消息的规则判断。LLM 返回不为空时，还会统一补齐缺省字段、过滤空内容，并将单条记忆截断到 200 字符。</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="typescript"><code><span leaf=""><span class="code-snippet__keyword">private</span> <span class="code-snippet__title">MemoryJudgeResult</span> <span class="code-snippet__title">judgeByLLM</span>(<span class="code-snippet__params"><span class="code-snippet__title">Long</span></span><span class="code-snippet__params"> tenantId, </span><span class="code-snippet__params"><span class="code-snippet__title">Long</span></span><span class="code-snippet__params"> modelId,</span></span></code><br/><code><span leaf="">        <span class="code-snippet__title">List</span>&lt;<span class="code-snippet__title">MemoryMessage</span>&gt; fullContext, <span class="code-snippet__title">List</span>&lt;<span class="code-snippet__title">MemoryMessage</span>&gt; newMessages) {</span></code><br/><code><span leaf="">    <span class="code-snippet__title">Set</span>&lt;<span class="code-snippet__title">String</span>&gt; newMessageKeys = newMessages.<span class="code-snippet__title">stream</span>()</span></code><br/><code><span leaf="">        .<span class="code-snippet__title">map</span>(m -&gt; (m.<span class="code-snippet__title">getRole</span>() != <span class="code-snippet__literal">null</span> ? m.<span class="code-snippet__title">getRole</span>() : <span class="code-snippet__string">&#34;user&#34;</span>)</span></code><br/><code><span leaf="">            + <span class="code-snippet__string">&#34;:&#34;</span> + (m.<span class="code-snippet__title">getContent</span>() != <span class="code-snippet__literal">null</span> ? m.<span class="code-snippet__title">getContent</span>() : <span class="code-snippet__string">&#34;&#34;</span>))</span></code><br/><code><span leaf="">        .<span class="code-snippet__title">collect</span>(<span class="code-snippet__title">Collectors</span>.<span class="code-snippet__title">toSet</span>());</span></code><br/><code><span leaf="">    <span class="code-snippet__title">StringBuilder</span> content = <span class="code-snippet__keyword">new</span> <span class="code-snippet__title">StringBuilder</span>(<span class="code-snippet__string">&#34;## 完整对话上下文\n\n&#34;</span>);</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">for</span> (<span class="code-snippet__title">MemoryMessage</span> message : fullContext) {</span></code><br/><code><span leaf="">        <span class="code-snippet__title">String</span> role = message.<span class="code-snippet__title">getRole</span>() != <span class="code-snippet__literal">null</span> ? message.<span class="code-snippet__title">getRole</span>() : <span class="code-snippet__string">&#34;user&#34;</span>;</span></code><br/><code><span leaf="">        <span class="code-snippet__title">String</span> text = message.<span class="code-snippet__title">getContent</span>() != <span class="code-snippet__literal">null</span> ? message.<span class="code-snippet__title">getContent</span>() : <span class="code-snippet__string">&#34;&#34;</span>;</span></code><br/><code><span leaf="">        content.<span class="code-snippet__title">append</span>(newMessageKeys.<span class="code-snippet__title">contains</span>(role + <span class="code-snippet__string">&#34;:&#34;</span> + text)</span></code><br/><code><span leaf="">                ? <span class="code-snippet__string">&#34;[[NEW] &#34;</span> : <span class="code-snippet__string">&#34;[&#34;</span>)</span></code><br/><code><span leaf="">            .<span class="code-snippet__title">append</span>(role).<span class="code-snippet__title">append</span>(<span class="code-snippet__string">&#34;]: &#34;</span>).<span class="code-snippet__title">append</span>(text).<span class="code-snippet__title">append</span>(<span class="code-snippet__string">&#34;\n&#34;</span>);</span></code><br/><code><span leaf="">    }</span></code><br/><code><span leaf="">    <span class="code-snippet__title">MemoryJudgeResult</span> result = iModelRpcService.<span class="code-snippet__title">call</span>(</span></code><br/><code><span leaf="">        tenantId, modelId, <span class="code-snippet__variable">JUDGE_SYSTEM_PROMPT</span>, content.<span class="code-snippet__title">toString</span>(),</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">new</span> <span class="code-snippet__title">ParameterizedTypeReference</span>&lt;<span class="code-snippet__title">MemoryJudgeResult</span>&gt;() {});</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">return</span> result == <span class="code-snippet__literal">null</span> ? <span class="code-snippet__literal">null</span> : <span class="code-snippet__title">validateAndFixResult</span>(result);</span></code><br/><code><span leaf="">}</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">判断要点：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">按 role:content 生成消息 key 并标记重点内容，相同内容的历史消息也可能一并命中。</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">按 5 类信息定义 importance 区间（1-10）。</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">明确 scope 归属规则。</span></span></p></li></ul><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">3、去重与冲突处理</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">在持久化前进行本地相似度去重，减少不必要的写入：<span textstyle="" style="font-weight: bold;">类说明</span>：MemoryPersistenceServiceImpl<a class="wx_topic_link" data-recommend="" data-topic="1" style="color: #576B95 !important;" topic-id="mtkyt23p-k5h9yo">#calculateSimilarity</a> 按 exact、contains、字符级 Jaccard（阈值 0.7）和短文本 Levenshtein（阈值 0.8）依次判断，相似即标记为重复；空值或未达到阈值则返回 none。它只负责同批次的本地预去重，跨历史记忆的冲突仍交给后续冲突服务处理。</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="cs"><code><span leaf="">batchPersist 完成本地去重后，先按 memCubeId 分组，再调用 batchDetectConflict 获取每条候选记忆的冲突结果。下面只保留逐条决定<span class="code-snippet__string">&#34;写入新记忆、跳过，或记录待失效旧记忆&#34;</span>的核心循环：</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">for</span> (<span class="code-snippet__built_in">int</span> i = <span class="code-snippet__number">0</span>; i &lt; memoryList.size(); i++) {</span></code><br/><code><span leaf="">    MemoryToSave memory = memoryList.<span class="code-snippet__keyword">get</span>(i);</span></code><br/><code><span leaf="">    MemoryConflictResult conflict = i &lt; conflictResults.size()</span></code><br/><code><span leaf="">        ? conflictResults.<span class="code-snippet__keyword">get</span>(i) : MemoryConflictResult.noConflict();</span></code><br/><code></code><br/><code><span leaf="">    <span class="code-snippet__keyword">if</span> (!conflict.isHasConflict()) {</span></code><br/><code><span leaf="">        messagesToStore.<span class="code-snippet__keyword">add</span>(createMessage(memory.getContent()));</span></code><br/><code><span leaf="">        <span class="code-snippet__keyword">continue</span>;</span></code><br/><code><span leaf="">    }</span></code><br/><code></code><br/><code><span leaf="">    ConflictResolutionResult resolution =</span></code><br/><code><span leaf="">        memoryConflictService.resolveConflict(</span></code><br/><code><span leaf="">            tenantId, memOSUserId, memCubeId,</span></code><br/><code><span leaf="">            memory.getContent(), conflict, modelId);</span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">if</span> (resolution.isShouldStoreNew()) {</span></code><br/><code><span leaf="">        messagesToStore.<span class="code-snippet__keyword">add</span>(createMessage(memory.getContent()));</span></code><br/><code><span leaf="">        <span class="code-snippet__keyword">if</span> (CollectionUtils.isNotEmpty(resolution.getMemoryIdsToExpire())) {</span></code><br/><code><span leaf="">            memoryIdsToDelete.addAll(resolution.getMemoryIdsToExpire());</span></code><br/><code><span leaf="">        }</span></code><br/><code><span leaf="">    }</span></code><br/><code><span leaf="">}</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这里的“批量”主要指按 memCubeId 分组、复用一批待写入内容；冲突服务的批量方法在实现内部仍逐条调用检测接口，再逐条决定保留新记忆、跳过或标记旧记忆。因此它减少了分组和编排开销，但不能等同于一次网络请求完成全部冲突判断。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">4、先写后删策略</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">为避免数据丢失，采用&#34;先写新记忆，后删旧记忆&#34;策略。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">类说明：</span>MemoryPersistenceServiceImpl<a class="wx_topic_link" data-recommend="" data-topic="1" style="color: #576B95 !important;" topic-id="mtkyt23p-505zgr">#batchPersist</a> 按 memCubeId 组装 MemOS 的 AddMemoryRequest，写入 userId、writableCubeIds 和 messages，并以 async、fine 模式调用 addMemory。只有返回结果中包含新增记忆时，才把冲突旧记忆 ID 交给 deleteMemories；删除异常只记录 warning，已经写入的新记忆继续保留。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这是一种&#34;写入优先&#34;的风险控制，而不是事务级一致性：MemOS 是外部 HTTP 服务，平台无法用本地事务同时包住新增和删除。当前删除失败只记录 warning，属于 best-effort；旧记忆可能暂时保留，后续检索或下一次冲突处理再进行清理。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">七、核心设计与运行观测</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这套实现把记忆处理拆成两条独立链路：请求前并行加载短期历史和长期记忆，会话结束后异步完成筛选、去重和持久化。核心策略集中在四点：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">并行加载：</span>短期记忆和长期记忆提交到同一个专用线程池，主流程在 join 处汇合。</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">新增消息标记：</span>使用 [[NEW]] 标记本次新增消息，让 LLM 借助完整上下文提取新信息。</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">预算控制：</span>短期历史采用滑动窗口并预留摘要空间，长期记忆按 scope 分组后分配固定 tokens。</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">可靠写入：</span>Redis 锁和 hash 负责幂等，MemOS 侧先写新记忆、再尽力删除冲突旧记忆。</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">运行观测能力：</span>系统提供运行概览、记忆类型分布、时间趋势、Top Agents 和 Cube 明细等查询能力，可用于了解记忆数据的规模、分类、来源及变化趋势，并支持按时间范围查看长期记忆搜索趋势，适合日常巡检、数据分布分析和异常定位。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">八、总结与后续工作</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">短期记忆负责把当前会话带入下一轮，长期记忆负责把经过筛选的用户事实和 Agent 经验带到后续会话。两条链路在请求前并行读取，在会话结束后通过异步任务衔接；长期记忆再按 scope 和 Token Budget 控制注入内容。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">当前方案已覆盖 Redis/MySQL 回退、MemOS 语义检索、LLM 判断、本地去重、冲突处理和先写后删。仍需补齐生产流量下的延迟与失败率观测，以及外部记忆服务失败后的补偿机制。</span></span></p></div><div data-role="paragraph" style="font-family:sans-serif;"><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">作者丨偶啦</span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;text-align: left;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">来源丨公众号：得物技术（ID：gh_13ba5621e65c）</span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">dbaplus社群欢迎广大技术人员投稿，投稿邮箱：</span></span><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">editor@dbaplus.cn</span></span></p><p class="mp_profile_iframe_wrp" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-service_type="1" data-verify_status="2"></mp-common-profile></p><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img" data-aistatus="1" data-imgfileid="100130225" data-ratio="0.07777777777777778" data-s="300,640" type="block" data-w="1080" src="https://wechat2rss.xlab.app/img-proxy/?k=f32823a4&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FufWcjcomw8Zf2jiaBBH3vdgfP4A2rem5YEAHYH074dc4GibhojA5B3lLZrXLDRciaVnficveaHcAUCiaIPoDsTkAduA%2F640%3Fwx_fmt%3Dpng"/></p></div></div><p style="display: none;"><mp-style-type data-value="3"></mp-style-type></p>



<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=dd8ab934&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzkzMjYzNjkzNw%3D%3D%26mid%3D2247638413%26idx%3D1%26sn%3D24fdf225cd57fdcaa1f315ed354484e4">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Tue, 10 Nov 2026 07:15:00 +0800</pubDate>
    </item>
    <item>
      <title>9.2级漏洞、七成网站依赖、48小时全网恐慌：拯救互联网的，竟是一个“无名之辈”</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzkzMjYzNjkzNw==&amp;mid=2247638411&amp;idx=1&amp;sn=b0d52ae2d0e54f351dc76eb11c4b5ce9</link>
      <description>“如果这个人出了什么意外，那就全完了，所有人都得跟着倒霉。”</description>
      <content:encoded><![CDATA[<p>原创 <span>整理自</span> <span>2026-11-09 07:15</span> <span style="display: inline-block;">广东</span></p>






  
  <p><img src="https://wechat2rss.xlab.app/img-proxy/?k=3d7c2664&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FgiamgWvCHDYZXG5etdsTgv50oAkdzGe6VE3CSPkbibkYT0m3V2BH84K5r04OiczlItcrTibvDBaYhd95p4ia6oehe3ia1QSd1scbVp1GbXTFiansJs%2F0%3Fwx_fmt%3Djpeg"/></p>
  <p>“如果这个人出了什么意外，那就全完了，所有人都得跟着倒霉。”</p>
  <p class="mp_profile_iframe_wrp" style="margin-bottom: 0px;" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-servicetype="0" data-verify_status="2"></mp-common-profile></p><div data-role="outer" label="edit by 135editor" data-pm-slice="0 0 []"><div data-role="paragraph"><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">维护全球无数网站的安全，听起来本该是一个庞大团队的工作。但过去二十多年，</span><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">Ondřej Surý</span><span textstyle="" style="color: rgb(62, 62, 62);">一直在业余时间默默完成这项任务。</span></span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">他自愿维护两个流行的Linux发行版Debian和Ubuntu的PHP软件包，把官方源码打包成网站运营者能轻松安装的版本。没有多少报酬，也很少有人知道他的名字。</span></span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">而前段时间，这位无名之辈安静的日常被打破了。</span></span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">10月21日，PHP被曝出两个</span></span><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">CVSS评分9.2的</span></span><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">高危安全漏洞。</span><span textstyle="" style="color: rgb(62, 62, 62);">作为约70%的网站都在使用的编程语言，它的安全问题足以牵动大半个互联网。</span></span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">这两个漏洞由网络安全研究人员借助OpenAI的前沿大模型发现。一旦遭到利用，攻击者不仅能完全接管服务器、窃取或拷贝内部数据，甚至能直接让网站瘫痪。</span></span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">负责维护PHP的官方团队（PHP基金会）虽然提前收到了漏洞信息，但补丁还没正式放出，漏洞细节就泄露到论坛。一场多方竞速的危机就此上演：</span><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">基金会需要紧急开发并发布补丁；全球各地的开发者需要尽快完成部署；而攻击者则抓紧这个空窗期发起攻击。</span></span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">Cloudflare首席执行官Matthew Prince后来回忆，漏洞公开前的10小时，他们监测到了数千次攻击尝试；而在公开后的短短45分钟内，攻击量飙升至数万次；两小时内突破数十万次，之后更是达到了数百万次。</span></span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">在漫天告警、所有人四处寻找救命补丁的焦灼里，一个人的名字被反复提起。</span></span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">这个人，正是Ondřej Surý。</span></span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf="" data-pm-slice="1 1 [&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;outer&#34;,&#34;class&#34;:&#34;article135&#34;,&#34;label&#34;:&#34;edit by 135editor&#34;,&#34;data-pm-slice&#34;:&#34;0 0 []&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;paragraph&#34;,&#34;class&#34;:&#34;_135editor&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;p&#34;,&#34;attributes&#34;:{&#34;style&#34;:&#34;line-height:1.75;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;node&#34;,{&#34;tagName&#34;:&#34;span&#34;,&#34;attributes&#34;:{&#34;style&#34;:&#34;font-size:15px;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;}]"><span textstyle="" style="color: rgb(62, 62, 62);">Surý住在捷克，并不是PHP基金会的员工，目前担任Internet Systems Consortium的DNS工程总监。10月21日补丁发布后，多亏了他和极少数几位志愿者的努力，大量网站才能迅速完成修复。</span></span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">“世界上竟然有这么一个人，</span></span><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">他几乎包揽了全球大部分PHP的分发工作。</span></span><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">”一位名叫Ian Landsman的开发者发推写道，“如果这个人出了什么意外，那就全完了，所有人都得跟着倒霉。”</span></span></span></p><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img" data-aistatus="1" data-backh="233" data-backw="578" data-imgfileid="100154759" data-ratio="0.40371621621621623" data-s="300,640" type="block" data-type="png" data-w="592" style="width:100%;" src="https://wechat2rss.xlab.app/img-proxy/?k=cd58fbb8&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FgiamgWvCHDYaOkPrp6z6PogibsTwicTVUczicEFGVQdhNxN0kRnvfZbHmRiaPQwwolA2yQrnDSx1V275QNRoZJicwOlGnFfqXYTnNK3pWZEIbJy8U%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">有网友直接感慨：“他拯救了互联网。”</span></span></span></p><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img" data-aistatus="1" data-backh="461" data-backw="578" data-imgfileid="100154760" data-ratio="0.7969543147208121" data-s="300,640" type="block" data-type="png" data-w="591" style="width:100%;" src="https://wechat2rss.xlab.app/img-proxy/?k=1c9ff350&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FgiamgWvCHDYazoRLryM7oEwbILwuxmkibXtQJ2LW53BYLZybeOUphue6TRIgBUqxJG4EfsBlWO1NJBTqFeARVtNS6nG6D4ib16NnhpmPY2SOsM%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">按理说，帮大半个互联网挡下危机的他，应该度过了一个惊心动魄的不眠之夜。但在《大西洋月刊》专访中，Surý给出的回答却完全出乎意料：</span><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">他并没有太手忙脚乱。尽管事态紧急，但凭借自己的经验和事先准备，他有信心应对。</span></span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">为什么Surý能如此从容？这场危机背后还有哪些细节？以下是《大西洋月刊》记者Charlie Warzel与Surý的对话实录。</span></span></span></p><div data-role="title" data-tools="135编辑器" data-id="99381" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgba(0, 0, 0, 0.9);font-size: 17px;letter-spacing: 0.544px;text-align: justify;text-decoration-thickness: initial;background-color: #ffffff;visibility: visible;font-family:system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;"><div style="-webkit-tap-highlight-color: transparent;margin: 10px auto;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;text-align: center;visibility: visible;line-height: 1.75em;"><div style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;display: inline-block;visibility: visible;"><div data-brushtype="text" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 4px 2em;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 16px;letter-spacing: 1.5px;color: #138bed;visibility: visible;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;clear: both;min-height: 1em;line-height: 1.75em;visibility: visible;"><strong style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;visibility: visible;"><span style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;visibility: visible;"><span style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;visibility: visible;"><span style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;visibility: visible;"><span leaf="">《大西洋月刊》专访</span></span></span></span></strong></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：请尽量用通俗易懂的语言</span></span><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">，告诉我过去72小时里发生了什么。</span></span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Surý：</span></span><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(62, 62, 62);">那周</span></span><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">早些时候，PHP项目团队通知我，代码中存在一个严重的安全漏洞。周二，有人泄露了即将发布的漏洞信息。所以，PHP项目内部决定，把原本定在周四的发布计划提前到周三。这个时候，局面开始有些失控了，因为我们突然少了一整天的准备时间。</span></span></span></p><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：我想换个更直观的角度来梳理一下：是大约有70%的网站在使用PHP语言吗？</span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Surý：</span></span><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">我听说过这个数据。</span></span></span></p><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：平时安全人员挖掘漏洞，往往是为了防御，而不一定是为了发起攻击。但这次真正的问题在于，漏洞被披露的范围太广了，而且留给大家打补丁的时间太短，对吧？</span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Surý：</span></span><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">让我澄清一下，关键在于漏洞的严重级别，这次的严重性非常罕见。远程代码执行（RCE）是危害最大的漏洞类型，因为攻击者可以直接在跑PHP的服务器上执行任意代码。这也是为什么整个互联网会陷入恐慌。正如你所说，全球约70%的网站都在用PHP，一旦攻击者真的能在这上面执行代码，后果不堪设想。</span></span></span></p><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：你刚才说，尽管网上炸开了锅，但对你而言，过去48小时并没有太手忙脚乱。从外界的视角来看，这挺让人意外的。我不断看到网友说：“负责修复这一切的其实就一个人，而且他还在靠Patreon（众筹打赏）维持生计。”网友的话可能有些夸张，但确实道出了部分真相：你几乎凭一己之力，帮到了数以百万计的人。对你来说，这怎么可能不算是疯狂的时刻呢？</span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Surý：</span></span><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">原因有两点。第一，这项维护工作我已经做了20多年，大部分流程都已经自动化了。但真正让我没觉得手忙脚乱的原因是：</span><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">我自己的服务器上并没有运行 PHP。</span><span textstyle="" style="color: rgb(62, 62, 62);">我确实觉得自己要对互联网用户负责，但不会说很慌乱。如果我当时正好在亚得里亚海的船上度假，连不上网，那对我来说才会是真正的麻烦。好在，我有充足的时间来打包这些程序。</span></span></span></p><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：这确实挺让人意外的。</span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Surý：</span></span><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">即使没有我，大家也能从其它渠道拿到PHP源码并自行编译。</span><span textstyle="" style="color: rgb(62, 62, 62);">只不过那样一来，对所有人来说都会麻烦得多。而且还有不少用户没有能力立刻升级PHP。PHP项目组只负责发布源码，</span>我的工作是把源码打包成服务器上可以直接安装的软件包。</span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">这种方式很方便，速度快，还能自动化部署，</span></span><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(62, 62, 62);">你能直接在成百上千台服务器上批量安装，不用自己编译源码。</span></span><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">如果我不在，大家就得花更多时间，有些人甚至根本无法完成。</span>所以，<span textstyle="" style="font-weight: bold;">其实应该归功于PHP项目组，是他们把我拉进了提前获知漏洞的保密小组。</span></span></span></p><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：收到通知的时候，你有没有立刻意识到事情很严重，心里很紧张？</span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Surý：</span></span><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(62, 62, 62);">我的第一反应是，这是个很严重的漏洞，</span></span><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">必须马上修复。但我没有很紧张，至少对我个人而言是这样。当然，这确实让很多人慌了神。但对我来说，更像是：</span><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">出了问题，要解决，那我们按部就班处理掉就行。而且我有充足的时间提前做好准备</span></span></span><span style="font-size:15px;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">。</span><span textstyle="" style="color: rgb(62, 62, 62);">如果留给我的准备时间很短，压力肯定会很大。但这次没有，毕竟我只是一名志愿者。</span></span></span></p><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：我每次写网络安全、开源相关报道时，都会碰到很多像你这样的维护者：</span></span><span leaf="" style="line-height: 1.75;font-size: 15px;" data-pm-slice="1 1 [&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;outer&#34;,&#34;class&#34;:&#34;article135&#34;,&#34;label&#34;:&#34;edit by 135editor&#34;,&#34;data-pm-slice&#34;:&#34;0 0 []&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;paragraph&#34;,&#34;class&#34;:&#34;_135editor&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;p&#34;,&#34;attributes&#34;:{&#34;style&#34;:&#34;line-height: 1.75;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;node&#34;,{&#34;tagName&#34;:&#34;span&#34;,&#34;attributes&#34;:{&#34;style&#34;:null},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;}]"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">完全出于热爱来做这份工作</span></span><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">，大部人都默默无闻。</span></span><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">假如发生意外，比如你出事了，会有人立刻接上你的工作吗？</span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Surý：</span></span><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">我其实一直在思考应急预案。我正在和Freexian的Raphaël Hertzog对接。我的优势是经验充足，清楚怎么把这套流程跑通。Freexian团队本身实力很强，如果真有突发状况，他们有能力接手这项工作。从昨天开始，不断有人给我捐款，金额大小都有，非常感谢大家。</span></span></span></p><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：如果这次没有这么快打上补丁，会发生什么？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Surý：</span></span><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(62, 62, 62);">后果会很严重</span></span><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(62, 62, 62);">。最基础的情况是网页被篡改、网站被迫下线，这类事件在互联网上本就时有发生。更危险的是，</span><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">攻击者拿到权限后，会把服务器纳入僵尸网络。</span></span><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">现在做这类攻击的大多是有组织的犯罪团伙，已经不是早年那些在地下室里自娱自乐的黑客。这背后有一条很长的利益链，他们可以出售僵尸网络的访问权，或是拿这些服务器挖加密货币。风险到现在依然存在，还有不少站点没有完成PHP补丁升级。</span></span></span></p><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：我在X上看到一条帖子说，并非所有PHP版本都放出了补丁，现在有三分之一的互联网处于长期受损或高危的状态。这说法准确吗？</span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Surý：</span></span><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(62, 62, 62);">这个</span></span><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">传言不准确。旧版本同样可以打补丁。</span></span></span></p><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：也就是说，</span></span><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">并不是三分之一的互联网都陷入危险了。</span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Surý：</span></span><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">对，这个说法并不准确。只要愿意投入精力，旧版PHP都可以完成修复。</span></span></span></p><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：</span></span><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">当下网络安全局势确实不容乐观。我看到有人把这次漏洞连同其它由AI智能体发起的攻击，称为 “黑色十月”。</span></span><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">不少人担心，不管是攻击侧还是防御侧的Agent，都有能力挖掘这类漏洞。安全圈子里一直有一种焦虑：害怕未来漏洞的发现、利用速度会突破人类的处理上限，而现在，这份担忧正在变成现实。也有一部分人认为这其中存在一种平衡：</span></span><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">既然有专攻漏洞挖掘、漏洞利用的Agent，自然也会有专注防御的Agent与之抗衡。</span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Surý：</span></span><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">我们能看到的事实是，漏洞相关的攻防节奏确实在加速，这点毋庸置疑。防御方同样可以使用大模型来找漏洞。但我认为，归根结底还是在于：</span><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">IT基础设施往往被视作理所当然、被人忽视的底座。</span></span></span></p><p style="line-height: 1.75;"><span leaf="" style="font-size: 15px;"><span textstyle="" style="color: rgb(62, 62, 62);">各行各业对基础设施维护的重视程度和资金投入都严重不足。不光是企业系统，大量老旧消费设备也会沦为攻击目标。我承认现在变化太快，压得防御人员疲于奔命。但换个角度看，这或许会成为一个转折点，倒逼大家真正重视基础设施安全。</span></span></p><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：你觉得大家真的会重视起来吗？</span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Surý：</span></span><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">也许我太乐观了，但我认为大家最终会意识到，我们不能再这样下去了。这个问题积压了很久，迟早会酿成重大事故。这次事件只是敲响一次警钟，未来可能还会有类似的危机。</span></span></span></p><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：互联网一部分基础设施，居然高度依赖一两个人，这点让我很震惊。这种脆弱性让人感到不安，你希望看到怎样的改变？</span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Surý： </span></span><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">我刚做开源的时候，只觉得这件事很有意思，到现在我依然这么认为。但大环境已经不一样了，如今的开源，有时更像一种变相的剥削。我期待出现新的模式：</span><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">开源维护者可以从最大的受益方那里，拿到和投入时间相匹配的回报。</span><span textstyle="" style="color: rgb(62, 62, 62);">我希望企业能认清这一点，看清这就是剥削。剥削本身无法长久。如果现状持续下去，后果会很难看。开源维护者早晚都会失去继续坚持的动力。</span></span></span></p><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：听起来，你并没有把功劳都揽到自己身上。但事实上，你做了大量的工作，并且帮助了很多人。经历了这一切，那晚睡觉前，想到自己发挥的关键作用，你感觉如何？</span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Surý：</span></span><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">我妻子常说我是个“情感绝缘体”，但其实并不是。</span></span><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">看到社交平台上满屏的感谢，还有一封封致谢邮件，心里确实挺温暖的。它让我感受到这份工作的意义，真切体会到自己做的事情是有价值的。</span></span></span></p><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q： 整个互联网都感谢你的付出。借着这个机会，</span></span><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">对于普通用户在日常网络安全方面，你有什么建议？</span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf="" style="line-height: 1.75;font-size: 15px;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Surý：</span></span><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">我的建议是相信专业人士。</span></span><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">遇到危机时我们都该如此：听专家的建议，相信他们。依靠负责维护这些系统的人，他们知道该怎么处理。</span></span></span></p><div data-tools="135编辑器" data-id="85988" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="max-width:100% !important;margin:0 auto;padding: 0;border:none;display:inline-block;width:100%;box-sizing:border-box;" data-width="100%"><p style="margin:0;padding:0;font-size:18px;letter-spacing:-2px;display: inline-block;box-sizing:border-box;"><span style="font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span style="color: #138bde;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: #138bde;opacity: 0.7;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: #138bde;opacity: 0.5;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: #138bde;opacity: 0.3;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span></strong></span></p><div style="margin-left: 10px;color: #138bde;display: inline-block;"><p data-brushtype="text" style="font-size:16px;color:inherit;margin-top:0;margin-bottom:0;"><span style="font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">参考链接</span></strong></span></p></div></div></div><p data-role="list"><ul style="list-style-type: disc;margin:0px;padding:0 0 0 30px;list-style-position:outside;" class="list-paddingleft-2"><li><p style="line-height:1.75;"><span style="font-size: 12px;color: #7f7f7f;"><span leaf=""><a href="https://www.theatlantic.com/technology/2026/10/man-who-saved-internet-php-vulnerability/689123/" target="_blank">https://www.theatlantic.com/technology/2026/10/man-who-saved-internet-php-vulnerability/689123/</a></span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 12px;color: #7f7f7f;"><span leaf=""><a href="https://www.bbc.com/news/articles/cw30ejqljl43o" target="_blank">https://www.bbc.com/news/articles/cw30ejqljl43o</a></span></span></p></li></ul></p></div><div data-role="paragraph" style="font-family:sans-serif;"><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">整理丨dbaplus社群</span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span style="color: #888888;font-size: 14px;letter-spacing: 0.5px;text-align: justify;caret-color: #ff0000;text-decoration-thickness: initial;display: inline !important;font-family:Helvetica, Arial, sans-serif;"><span leaf="">*仅为提供参考和学习交流，不代表dbaplus社群立场！</span></span><span leaf="">dbaplus社群欢迎广大技术人员投稿，投稿邮箱：</span></span><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">editor@dbaplus.cn</span></span></p><p class="mp_profile_iframe_wrp" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-servicetype="0" data-verify_status="2"></mp-common-profile></p><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img" data-aistatus="1" data-imgfileid="100130225" data-ratio="0.07777777777777778" data-s="300,640" type="block" data-w="1080" src="https://wechat2rss.xlab.app/img-proxy/?k=f32823a4&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FufWcjcomw8Zf2jiaBBH3vdgfP4A2rem5YEAHYH074dc4GibhojA5B3lLZrXLDRciaVnficveaHcAUCiaIPoDsTkAduA%2F640%3Fwx_fmt%3Dpng"/></p></div></div><p style="display: none;"><mp-style-type data-value="3"></mp-style-type></p>



<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=5fc676a8&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzkzMjYzNjkzNw%3D%3D%26mid%3D2247638411%26idx%3D1%26sn%3Db0d52ae2d0e54f351dc76eb11c4b5ce9">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Mon, 09 Nov 2026 07:15:00 +0800</pubDate>
    </item>
    <item>
      <title>从怒斥到真香定律，Linus现用Claude Code改内核 ：性能暴涨23倍，结果被维护者发现Bug……</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzkzMjYzNjkzNw==&amp;mid=2247638392&amp;idx=1&amp;sn=05c0dba4861117a09483a09a255c7ee3</link>
      <description>人对代码质量的把控，始终是最后一道防线。</description>
      <content:encoded><![CDATA[<p>原创 <span>整理自</span> <span>2026-11-06 07:15</span> <span style="display: inline-block;">广东</span></p>






  
  <p><img src="https://wechat2rss.xlab.app/img-proxy/?k=7f77e5b3&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FgiamgWvCHDYYVA9HyZPwF8KJ7ggpBKudcMEZrkCCLFIR6uJCLxggaucJiaLUbgIOhsYeoUfCIicQUM44ZvAiaPoo0I1KfQEgcY1aibrjYwxmUdYQ%2F0%3Fwx_fmt%3Djpeg"/></p>
  <p>人对代码质量的把控，始终是最后一道防线。</p>
  <p class="mp_profile_iframe_wrp" style="margin-bottom: 0px;" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-servicetype="0" data-verify_status="2"></mp-common-profile></p><div data-role="outer" label="edit by 135editor" data-pm-slice="0 0 []"><div data-role="paragraph"><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Linux 创始人、长期担任首席维护者的 Linus Torvalds 借助 Anthropic 的 Claude Code 改内核。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">10 月 13 日，他提交了一组 10 个补丁的合集。在他的 Ryzen Threadripper 上运行的合成基准测试中，这组补丁将<span textstyle="" style="font-weight: bold;">吞吐量提升了 23 倍</span>。但补丁还没正式合入主线，<span textstyle="" style="font-weight: bold;">社区维护者就揪出了一个连 Linus 和 AI 都没发现的 Bug。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">大神都有兜不住的Bug？这要从一个困扰了开发者们两年多的性能问题说起。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">一、一个两年无解的内核瓶颈</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">2024 年，Oracle 工程师、资深 Linux 内核内存管理开发者 Matthew Wilcox 在处理客户工作负载时，发现了页缓存的 folio 引用计数争用问题，并标记下来。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">根据 Hardware Busters 的测试数据，在 Linus 的 Core i7-8565U 笔记本上的 8 线程测试中，<span textstyle="" style="font-weight: bold;">folio 引用计数争用占到了跨核 HITM 开销的 99.92%。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">之前，为了解决页缓存引用计数的性能瓶颈，Linus 自己写过一版修复方案，断断续续用了 18 个月，但这个版本一直存在缺陷。其他开发者也尝试过不同的优化思路，同样没能彻底解决问题。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">二、Linus 亲自承认用 AI 写内核代码</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">针对这个久攻未决的瓶颈，Linus 拿出了新的优化方案。令人震惊的是，该方案竟然是 Linus 借助 AI 完成的。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">10 月 11日，Phoronix 的 Michael Larabel 发现，Linus 的内核代码树中出现了一个名为 <span textstyle="" style="font-weight: bold;">noref-filemap-read-with-llm</span> 的新分支。 熟悉 Linus 开发习惯的人都知道，他的代码树极少收录主线开发分支之外的内容。</span></span></p><p style="line-height:1.75;"><span leaf=""><img alt="noref-filemap-read-with-llm Git 分支" class="rich_pages wxw-img" data-aistatus="1" data-backh="222" data-backw="578" data-imgfileid="100154567" data-ratio="0.38333333333333336" style="width:100%;" data-type="other" data-w="900" src="https://wechat2rss.xlab.app/img-proxy/?k=d8e2526d&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYaghibK0uwTOWwmpic9VZaK5mjPCVsBWCgJanhXho17qPs0T28HSRJP43GZPJxO0YLUy102CdibzeTdBSlJ8H2SGYicEIta3WtEoEI%2F640%3Fwx_fmt%3Dother%26from%3Dappmsg"/></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这个包含 8 个补丁的版本基于 Linux 7.3-rc6 开发，提交记录里清晰说明了 Claude Code 的具体分工。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">在补丁信息中，Linus 确认了 AI 的参与：</span></span></span></p><div data-tools="135编辑器" data-id="5" data-color="rgb(198, 198, 199)" data-custom="rgb(198, 198, 199)" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;border: 0px none;z-index: 0;max-width: 100%;font-size: 16px;widows: 1;visibility: visible;" data-pm-slice="0 0 []"><div style="max-inline-size: 100%;margin: 2px auto;padding: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;max-width: 100%;font-size: 14px;line-height: 25px;border-width: 2px;border-style: dashed;border-color: #c6c6c7;visibility: visible;"><p style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;clear: both;min-height: 1em;cursor: text;max-width: 100%;vertical-align: inherit;line-height: 1.5em;visibility: visible;"><span style="caret-color: red;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">“上述代码、测试程序、审查工作以及本文初稿都是在我的指导下，由一位 LLM 编码助理（Claude Code）完成的。基准测试都是在我的机器上运行的。”</span></span></span></p></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这与 Linus 此前的公开立场形成了鲜明对比。他曾将 AI 描述为“90% 是营销”，也曾批评开发者“用 AI 写了 99% 的代码”。而现在，<span textstyle="" style="font-weight: bold;">他不仅在内核之外用 Google 的 Antigravity 进行了一些虚拟编程， 还用 AI 辅助内核调试。</span></span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">三、性能提升23倍，但也有代价</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">让业内意外的不只是 Linus 用上了 AI，更是他提交的这组补丁走了一条更大胆的技术路线。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">早前有人尝试过的思路是：读取拷贝时不持有 folio 引用，读完再校验数据有效性，但该方案在内存回收、页替换场景下存在竞态条件。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">而 13 日 Linus 推出的 10 补丁 rcu-free-v3 系列，是新增 PG_rcu_free 标志位，采用 RCU 延迟回收机制，只要用户态数据拷贝过程不触发缺页异常，就能在整个读取周期内安全访问 folio 结构。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">根据 Threadripper 基准测试结果，两个版本的性能提升非常显著：</span></span></p><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img js_insertlocalimg" data-ratio="0.5977777777777777" data-s="300,640" data-type="png" data-w="900" style="width:100%;" type="block" data-backw="578" data-backh="346" data-imgfileid="100154568" src="https://wechat2rss.xlab.app/img-proxy/?k=d93d479e&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FgiamgWvCHDYYla7HYsGLAfD7mprsiaIyb5iciamaJnuiaKYaRyMTxIticuzrMwibWtQXQcl8IUV3sJDC6wO9jvtxibC8YWMsGhcVwctWjRQkIF7aOGY%2F640%3Fwx_fmt%3Dwebp%26from%3Dappmsg"/></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">最初的 8 补丁版本在 Linus 的笔记本上就已经翻了<span textstyle="" style="font-weight: bold;">近三倍的吞吐量</span>：8 线程场景下，每秒读取次数从 1000 万提升至 3300 万，单次读取消耗的内核周期数从约 2950 降至 725。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">而优化后的 10 补丁版本，在 64 线程 Threadripper 的高并发争用场景下提升更夸张：吞吐量从每秒 1330 万次读取跃升至 3.04 亿次，单次读取的内核周期数从近 2 万降至 735，也就是<span textstyle="" style="font-weight: bold;"> 23 倍的性能提升</span>。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">但 Linus 也明确提醒，<span textstyle="" style="font-weight: bold;">在实际工作负载中，基准测试的性能涨幅会小很多。</span>这是极端合成基准的结果，不代表 Linux 整体性能提升。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">而性能提升也并非没有代价。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">据 Hardware Busters 报道，在 8 补丁最初实现版本中，只要单个 CPU 的待回收页面队列<span textstyle="" style="font-weight: bold;">超过 1024 个</span>，延迟回收机制就会触发强制快速宽限期，加急完成页面回收。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">此外，针对未映射的用户页读取操作，在回退到原有流程前会额外触发一次缺页异常，导致单线程下 16 字节读取的周期数<span textstyle="" style="font-weight: bold;">从约 4150 攀升至 6550</span>。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">目前这一性能回退问题在 rcu-free-v3 版本中是否已修复，还没有明确结论。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">四、维护者质疑，大神也有没兜住的Bug？</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">针对 Linus 的方案，最早发现该内核瓶颈的Matthew Wilcox 对新增的 PG_rcu_free 标志位提出异议，建议改用页面类型标识，同时配合在 RCU 宽限期后回收非活跃链表中的 folio。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Linus 否决了这两种思路。他认为，该标志位<span textstyle="" style="font-weight: bold;">必须在 folio 仍可被映射到用户空间时就完成设置，而非活跃链表回收机制无法覆盖文件截断（truncate）和打洞（hole-punch）两类操作场景。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">此前针对该瓶颈提交过优化方案的内核开发者 <span textstyle="" style="font-weight: bold;">Kiryl Shutsemau</span> 也参与了讨论。他提议将该标志位的使用限定在 64 位系统上，这一方案得到了 ARM 工程师、Linux 内存管理子系统维护者 David Hildenbrand 的支持。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">真正关键的是，Shutsemau 还在 filemap_read_rcu_batch() 函数中发现了一处竞态条件：<span textstyle="" style="font-weight: bold;">folio 替换完成后再扩展文件大小（i_size），可能会暴露从未实际写入的数据。</span>Linus 建议提前读取文件大小，并合并 folio 校验逻辑，Shutsemau 已将该方案整合进了修订版补丁。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">随后，Linus 将后续开发工作移交给了 Shutsemau。</span></span></p><p style="line-height: 1.75;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);">10 月 19 日，Shutsemau 发布了一组补丁集。这套补丁基于之前 Linus 的代码思路改造实现，核心是<span textstyle="" style="font-weight: bold;">修改 Linux 内核内存管理逻辑，做到不需要持有 folio 引用就可以完成页缓存读取。</span></span></p><p style="line-height: 1.75;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);">他在补丁说明中解释了背后的原理：</span></p><div data-tools="135编辑器" data-id="5" data-color="rgb(198, 198, 199)" data-custom="rgb(198, 198, 199)" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;border: 0px none;z-index: 0;max-width: 100%;font-size: 16px;widows: 1;visibility: visible;" data-pm-slice="0 0 []"><div style="max-inline-size: 100%;margin: 2px auto;padding: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;max-width: 100%;font-size: 14px;line-height: 25px;border-width: 2px;border-style: dashed;border-color: #c6c6c7;visibility: visible;"><p style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;clear: both;min-height: 1em;cursor: text;max-width: 100%;vertical-align: inherit;line-height: 1.5em;visibility: visible;"><span style="caret-color: red;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">“当多个 CPU 对同一个文件执行小块读取时，每个 CPU 都要对同一个 folio 做一次引用获取、一次引用释放，导致引用计数在多个 CPU 之间来回颠簸。该补丁集让 filemap_read() 函数以及共享内存（shmem）场景，都可以跳过引用获取步骤，直接从页缓存拷贝数据。这是对 Linus 原 RFC 方案的重构：读取进程正在拷贝的 folio 页，只会在 RCU 宽限期结束后才会被释放。”</span></span></span></p></div></div><p style="line-height: 1.75;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);">他还在 EXT4、TMPFS、XFS 三种文件系统以及原始块设备上验证了这套优化的效果。测试基于 AMD Ryzen Threadripper 处理器，采用 64 线程并发，分别在开启和关闭默认 CPU 安全缓解机制的场景下完成。</span></p><p style="line-height: 1.75;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);">测试结果相当亮眼：</span></p><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.5811111111111111" data-s="300,640" data-type="webp" data-w="900" style="width:100%;" type="block" data-backw="578" data-backh="336" data-imgfileid="100154569" src="https://wechat2rss.xlab.app/img-proxy/?k=26af9a07&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYaavYmUlSB0CMHlFHg2PgEpzhU0CXmjugUogsadyibiaS8aXRwicSahLbPlibx4NFfrqwm0b0aKLewsqchf2grw6ywBoDCIa8CAC3w%2F640%3Fwx_fmt%3Dwebp%26from%3Dappmsg"/></p><p style="line-height: 1.75;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);">提升效果相当惊艳。这组补丁目前还处在 RFC 征求意见阶段，仍有部分设计细节没有最终落地，但这些问题预计很快就能解决，距离合入内核主线已经不远了。</span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">五、结语</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Linus 曾批评“AI 写了 99% 代码”的浮夸论调，而这次 AI 辅助开发、人类审查兜底的实践，恰恰给出了最明确的答案：AI 是提升开发效率的利器，但工具终究只是工具，<span textstyle="" style="font-weight: bold;">人对代码质量的把控，始终是最后一道防线。</span></span></span></p><div data-tools="135编辑器" data-id="85988" data-color="#138bde" data-custom="#138bde" style="font-family: sans-serif;"><div style="max-width:100% !important;margin:0 auto;padding: 0;border:none;display:inline-block;width:100%;box-sizing:border-box;" data-width="100%"><p style="margin:0;padding:0;font-size:18px;letter-spacing:-2px;display: inline-block;box-sizing:border-box;"><span style="font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span style="color: #138bde;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: #138bde;opacity: 0.7;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: #138bde;opacity: 0.5;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: #138bde;opacity: 0.3;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span></strong></span></p><div style="margin-left: 10px;color: #138bde;display: inline-block;"><p data-brushtype="text" style="font-size:16px;color:inherit;margin-top:0;margin-bottom:0;"><span style="font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">参考链接</span></strong></span></p></div></div></div><p data-role="list"><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="color: #7f7f7f;font-size: 12px;"><span leaf=""><a href="https://www.phoronix.com/news/Linus-Torvalds-Claude-Code" target="_blank">https://www.phoronix.com/news/Linus-Torvalds-Claude-Code</a></span></span></p></li><li><p style="line-height:1.75;"><span style="color: #7f7f7f;font-size: 12px;"><span leaf=""><a href="https://thenewstack.io/torvalds-claude-code-kernel/" target="_blank">https://thenewstack.io/torvalds-claude-code-kernel/</a></span></span></p></li></ul></p><p data-role="list"><ul class="list-paddingleft-1"><li><p style="line-height: 1.75;"><span leaf="" style="color: rgb(127, 127, 127);font-size: 12px;"><a href="https://www.phoronix.com/news/Reading-Page-Cache-WO-Folio-Ref" target="_blank">https://www.phoronix.com/news/Reading-Page-Cache-WO-Folio-Ref</a></span></p></li></ul></p><div data-role="paragraph" style="font-family:sans-serif;"><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">整理丨dbaplus社群</span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span style="color: #888888;font-size: 14px;letter-spacing: 0.5px;text-align: justify;caret-color: #ff0000;text-decoration-thickness: initial;display: inline !important;font-family:Helvetica, Arial, sans-serif;"><span leaf="">*仅为提供参考和学习交流，不代表dbaplus社群立场！</span></span><span leaf="">dbaplus社群欢迎广大技术人员投稿，投稿邮箱：</span></span><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">editor@dbaplus.cn</span></span></p><p class="mp_profile_iframe_wrp" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-servicetype="0" data-verify_status="2"></mp-common-profile></p><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img" data-aistatus="1" data-imgfileid="100130225" data-ratio="0.07777777777777778" data-s="300,640" type="block" data-w="1080" src="https://wechat2rss.xlab.app/img-proxy/?k=f32823a4&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FufWcjcomw8Zf2jiaBBH3vdgfP4A2rem5YEAHYH074dc4GibhojA5B3lLZrXLDRciaVnficveaHcAUCiaIPoDsTkAduA%2F640%3Fwx_fmt%3Dpng"/></p></div></div></div><p style="display: none;"><mp-style-type data-value="3"></mp-style-type></p>



<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=4654ac48&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzkzMjYzNjkzNw%3D%3D%26mid%3D2247638392%26idx%3D1%26sn%3D05c0dba4861117a09483a09a255c7ee3">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Fri, 06 Nov 2026 07:15:00 +0800</pubDate>
    </item>
    <item>
      <title>还好大促前刷到了！一种基于分布式缓存的强一致性热点库存扣减方案</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzkzMjYzNjkzNw==&amp;mid=2247638381&amp;idx=1&amp;sn=11f13017068dfecae6169cd8fdbbdc20</link>
      <description>如何在保证扣减强一致性的同时，提升库存热点扣减TPS和扣减稳定性？</description>
      <content:encoded><![CDATA[<p><span>聆枫</span> <span>2026-11-05 07:15</span> <span style="display: inline-block;">广东</span></p>




  <p>以下文章来源于：千问AI平台</p>
  <strong>千问AI平台</strong>
  <p>千问AI平台，为AI Agent 而生</p>



  
  <p><img src="https://wechat2rss.xlab.app/img-proxy/?k=d36cc8b0&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FvCTfE5pGMricXDmSDaUBqNsNvOqVV6dAVVO7Uvibfp7MgIesVW78dnxTQZyaHClpmh0fEET03jzfcV7wmkpvSB8Q%2F0%3Fwx_fmt%3Djpeg"/></p>
  <p>如何在保证扣减强一致性的同时，提升库存热点扣减TPS和扣减稳定性？</p>
  <p class="mp_profile_iframe_wrp" nodeleaf="" style="margin-bottom: 0px;"><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-service_type="1" data-verify_status="2"></mp-common-profile></p><div data-role="outer" label="edit by 135editor" data-pm-slice="0 0 []"><div data-role="paragraph"><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">前言</span></strong></span></p></div></div></div></div><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">本文主要介绍了针对热点深库存下单抢购场景，库存团队设计并实现的一种基于Redis分桶扣减计数和合并提交扣减DB的方案；该方案基于分布式缓存实现，但也能做到不超卖不少卖，在保证扣减强一致性的同时，也提升了库存热点扣减TPS和扣减稳定性。</span></span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">一、背景介绍</span></strong></span></p></div></div></div></div><p style="line-height: 1.75em;"><span style="font-size: 15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">自库存团队成立以来，随着业务的不断发展，库存扣减性能优化一直是库存团队不断面临的挑战；近几年，库存和数据库团队一起，从数据库内核优化、到应用层优化、再到扣减架构升级，持续的提升库存DB扣减的性能。在前述优化的基础上，库存数据库的整体性能得到了很好的提升。</span></span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">然而随着直播业务的发展，热点扣减的场景越来越频繁，对于深库存热点扣减的场景，日常我们只能通过限流的方式来保护DB，库存合并扣减就是在这样的背景下提出的，我们希望继续优化热点扣减的性能，使库存扣减不成为热点下单链路的瓶颈所在。</span></span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">二、方案调研</span></strong></span></p></div></div></div></div><p style="line-height: 1.75em;"><span style="font-size: 15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">传统的提高热点扣减的方案都是通过分布式缓存实现，该类方案通过将库存从 MySQL 划分到多个Redis分桶，扣减的时候直接走Redis进行扣减，分析此类方案，我们会发现：</span></span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">1）该类基于缓存的扣减方案确实能够大幅提升扣减的性能；</span></span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">2）但是这个库存扣减方案在实际应用中也会存在一些问题：</span></span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height: 1.75em;"><span style="font-size: 15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">无法避免库存少卖：</span><span textstyle="" style="color: rgb(62, 62, 62);">针对Redis失败（如超时）的场景，应用层实际并不知道Redis库存是操作成功还是操作失败。为了避免库存超卖，对于扣减超时的场景，应用层只能默认当做失败处理；对于库存回补的场景，应用层只能默认当做成功处理。此时</span><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">整体是业务有损的，所以Redis分桶扣减方案一般是用在卖家限购、权益这类非实物类库存扣减的场景，这类场景业务接受少卖。</span></span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height: 1.75em;"><span style="font-size: 15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">对于稍微复杂的库存扣减模型无法支持：</span><span textstyle="" style="color: rgb(62, 62, 62);">Redis库存扣减方案中使用incr和decr实现库存的加减，利用lowBound防止库存减到负数，value即是剩余的库存数量；这个方案只支持库存记录仅包含一个数值的库存模式， 对于sq- 同时wq+ 这种模式无法支持。</span></span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height: 1.75em;"><span style="font-size: 15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">库存扣减完全依赖Redis：</span><span textstyle="" style="color: rgb(62, 62, 62);">当前扣减方案需要强保障Redis的稳定性，如果Redis异常则整个扣减链路异常。</span></span></span></p></li></ul><p style="line-height: 1.75em;"><span style="font-size: 15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">我们想利用Redis提升扣减性能，但是我们的库存扣减模型相对更加复杂、同时我们的业务场景对于库存数据准确性要求更高，</span><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">绝对不允许超卖少卖</span><span textstyle="" style="color: rgb(62, 62, 62);">；传统的基于redis分桶扣减的方案并不完全适合我们的业务场景。</span></span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">三、合并扣减方案</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">介绍合并扣减详细方案之前，先简单说明下库存域的几个基本概念，方便大家更好理解后续的内容。</span></span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">1） 库存核心字段：</span></span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">可售库存：</span><span textstyle="" style="color: rgb(62, 62, 62);">sq，实际可售的库存数量；</span></span></span></p></li><li><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">预扣库存：</span><span textstyle="" style="color: rgb(62, 62, 62);">wq，用户下单后，库存sq转向wq；</span></span></span></p></li><li><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">占用库存：</span><span textstyle="" style="color: rgb(62, 62, 62);">oq，货品仓库存模式，付款之后，库存从wq转向oq。</span></span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">2）库存扣减明细（也叫单据）：是库存扣减的快照，明细是不可或缺的。明细的作用：</span></span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height: 1.75em;"><span style="font-size: 15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">记录扣减信息：</span><span textstyle="" style="color: rgb(62, 62, 62);">下单是交易会告诉我们扣多少库存，后续付款或者订单取消时，上游不用关心库存的回补数量，库存内部从明细恢复；</span></span></span></p></li><li><p style="line-height: 1.75em;"><span style="font-size: 15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">用于分布式系统交互过程中的幂等实现：</span><span textstyle="" style="color: rgb(62, 62, 62);">同一个单据调了两次扣减；单据回补超时，重试可幂等；</span></span></span></p></li><li><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">负责库存扣减生命周期状态流转。</span></span></span></p></li></ul><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">1、整体思路</span></strong></span></p></div></div></div><p style="line-height: 1.75em;"><span style="font-size: 15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">我们既想利用分布式缓存（Redis）提升扣减性能，但同时又不能直接依赖Redis作为库存存储介质；因此我们的方案里面，Redis只用来做扣减计数以防止超卖，实际扣减是否成功以库存扣减明细为准。 整体思路如下：</span></span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.44907407407407407" data-w="1080" style="width:100%;" data-backw="578" data-backh="260" src="https://wechat2rss.xlab.app/img-proxy/?k=4a102b55&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FZ6bicxIx5naIT2dp3BUtWXhbULL3LiaEMicUTbsh3jIoGibSd541enEotePt7gGk4qJ0AqyyHyl4BynNK4pDIFnh8Q%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">1）DB行的库存提前预留（锁）一部分，锁的这个库存还在DB行上，同时也初始化到redis里面用于扣减计数；</span></span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">2）合并扣减下单过程中，先扣减redis库存，redis库存够扣的情况下，再往DB插入扣减明细，明细插入成功最终才算扣减成功；</span></span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">3）应用层的合并扣减管理模块，热点下单延迟1s后，通过扫描扣减明细，计算实际应该扣减的数量，一次提交库存变更到DB。</span></span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">接下来介绍各个分模块的设计。</span></span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">2、锁库存模块</span></strong></span></p></div></div></div><p style="line-height: 1.75em;"><span style="font-size: 15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">1）锁库存模块将DB行库存从sq字段（可售）锁到lq字段（预锁库存），同时锁库存单据；</span></span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">2）锁库存核心实现，不是通过将sq减去然后加到lq，而是sq不动，锁库存直接加到lq；DB扣减时通过 where sq-lq&gt;0 控制最终sq的数量不能小于lq。</span><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">这个设计使得锁库存之后，库存展示链路完全不受影响，查询可售库存时也完全不需要关心锁的库存值，大大的降低整个链路上的复杂性，这是一个非常重要的设计。</span></span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">3）每次锁定的lq数量，初始化到Redis里进行扣减计数。</span></span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><img class="rich_pages wxw-img" data-aistatus="1" data-backh="306" data-backw="578" data-ratio="0.5296296296296297" style="width:100%;" data-w="1080" src="https://wechat2rss.xlab.app/img-proxy/?k=04561c49&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FZ6bicxIx5naIT2dp3BUtWXhbULL3LiaEMicbUSZ7UZhibRbA6TrPpR4EYHs669ECnCQEDsDeAHmbG3jHvdQA0cibHzQ%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">多个redis分桶通过redis分桶缓存进行索引：</span></span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.26666666666666666" data-w="1080" style="width:100%;" data-backw="578" data-backh="154" src="https://wechat2rss.xlab.app/img-proxy/?k=bdaea25c&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FZ6bicxIx5naIT2dp3BUtWXhbULL3LiaEMicnWPhsyucxq6aepvuUDeAxWLfib9pQEcN3KLQoUKE3oWGma07YXBnKbw%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">3、下单扣减模块</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">先扣redis分桶库存，成功则继续插入DB明细；失败则兼容走老的DB扣减流程：</span></span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.6157407407407407" data-w="1080" style="width:100%;" data-backw="578" data-backh="356" src="https://wechat2rss.xlab.app/img-proxy/?k=833e66ea&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FZ6bicxIx5naIT2dp3BUtWXhbULL3LiaEMicgDTr0sQRiczkOrPJ6rdvOXR824PZPmMyvgSutEjDorPZibl6fDqfqXkA%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">4、合并提交模块</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">1）先失效合并提交对应的redis分桶，防止后续继续有交易流量扣减此redis分桶；</span></span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">2）根据分桶key扫描此分桶关联的所有扣减明细，计算库存扣减数量，合并扣减DB。</span></span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">实际Redis分桶扣减的库存数量，以合并下单明细为准，通过扫描明细上的扣减库存总和得到；</span></span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height: 1.75em;"><span style="font-size: 15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">这里我们针对数据库明细表，设计了覆盖索引（invId，lockOrderId，quantity），通过sum(quantity) 走索引就能直接得到每个Redis分桶实际扣减的库存；</span><span textstyle="" style="color: rgb(62, 62, 62);">压测和线上效果都表明，此扫描单据的SQL对DB热点扣减的性能影响非常小。</span></span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.6268518518518519" data-w="1080" style="width:100%;" data-backw="578" data-backh="362" src="https://wechat2rss.xlab.app/img-proxy/?k=d9ffa1a8&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FZ6bicxIx5naIT2dp3BUtWXhbULL3LiaEMic0dkjp87he2EKHO6DEGXRDU3JaLJz6ERoshUJMk4CCVS1oVbz9884bA%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">5、库存回收模块</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">1）库存回收指将预锁定的库存释放回收到可售卖的状态，以下几种场景需要回收库存：</span></span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height: 1.75em;"><span style="font-size: 15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">商家编辑场景，直接走的DB扣减，redis有剩余库存，而商家编辑时将总库存编辑成0，此时我们需要先释放预锁库存；</span></span></span></p></li><li><p style="line-height: 1.75em;"><span style="font-size: 15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">临界场景：Redis分桶只有1件库存，DB两件库存，下单两件库存库存，此时将Redis的库存回收到DB后继续扣减。</span></span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">2）库存回收在实现上可以直接通过调用分桶合并提交来完成。</span></span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">6、防超卖少卖设计</span></strong></span></p></div></div></div><p style="line-height: 1.75em;"><span style="font-size: 15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">1）前面锁库存模块也已经提到过，DB可售sq锁到lq，扣减SQL层直接</span><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">通过 set sq = sq -δq where sq-lq - δq&gt; 0 的方式保证DB不超卖。</span></span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">2）而Redis扣减，分桶的剩余库存值不能小于0，保证不超卖；同时如果Redis数据丢了，</span><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">实际这个Redis分桶库存扣减了多少，以DB合并下单明细为准，也不会少卖。</span></span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">3）高并发场景下，下单扣减和合并提交单据扫描并发的情况下，可能会出现少扫描了单据，如果少扫描单据了，则会超卖；我们</span><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">通过Redis扣减屏障防止此并发场景下的超卖；</span><span textstyle="" style="color: rgb(62, 62, 62);">具体链路如下：</span></span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.7490740740740741" data-w="1080" style="width:100%;" data-backw="578" data-backh="433" src="https://wechat2rss.xlab.app/img-proxy/?k=533da851&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FZ6bicxIx5naIT2dp3BUtWXhbULL3LiaEMicTSQa3icHfVAPRhBe4e6YOsOxjTpux3y1TmqfC6oUsUZYI40M8PnwWlg%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">7、自动锁库存模块</span></strong></span></p></div></div></div><p style="line-height: 1.75em;"><span style="font-size: 15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">通过热点识别能力，感知交易相关系统的热点品库存查询，提前将满足条件的商品库存进行自动锁库存；只要一开始提前锁了任意数量的库存，后续下单扣减过程中，则会继续自动触发锁库存。</span></span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">8、性能优化效果</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">接下来我们看下合并扣减的效果：</span></span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">1）压测效果</span></span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">从压测效果上看，单行热点扣减场景下，非合并扣减tps峰值约1.4w，合并扣减峰值3.2w；整体提升1倍以上扣减性能（实际线上场景，由于入口做了限流，所以线上达不到压测的流量峰值）。</span></span></span></p><p style="line-height:1.75;"><span style="font-size:15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">2）线上效果</span></span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">线上由于入口开了限流，库存扣减峰值tps都在7k+，差异体现在扣减成功率和耗时上：</span></span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">走到合并扣减的热点品，库存扣减成功率在100%，接口扣减耗时7ms+；未走到合并扣减的热点品，库存扣减成功率在80%上下，接口扣减耗时15ms+。</span></span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">结语</span></strong></span></p></div></div></div></div><p style="line-height: 1.75em;"><span style="font-size: 15px;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">以上则是基于分布式缓存的强一致库存扣减方案的全部内容，欢迎大家一起交流。</span></span></span></p></div><div data-role="paragraph" style="font-family:sans-serif;"><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">作者丨聆枫</span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;text-align: left;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">来源丨公众号：阿里云开发者（ID：</span><span style="color: rgb(136, 136, 136);font-family: Helvetica, Arial, sans-serif;font-size: 14px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: 0.5px;orphans: 2;text-align: left;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;display: inline !important;float: none;" data-pm-slice="0 0 []"><span leaf="">ali_tech</span></span><span leaf="">）</span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">dbaplus社群欢迎广大技术人员投稿，投稿邮箱：</span></span><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">editor@dbaplus.cn</span></span></p><p class="mp_profile_iframe_wrp" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-service_type="1" data-verify_status="2"></mp-common-profile></p><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.07777777777777778" data-s="300,640" data-w="1080" type="block" data-imgfileid="100130225" src="https://wechat2rss.xlab.app/img-proxy/?k=f32823a4&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FufWcjcomw8Zf2jiaBBH3vdgfP4A2rem5YEAHYH074dc4GibhojA5B3lLZrXLDRciaVnficveaHcAUCiaIPoDsTkAduA%2F640%3Fwx_fmt%3Dpng"/></p></div></div><p style="display: none;"><mp-style-type data-value="3"></mp-style-type></p>



<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=d4207600&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzkzMjYzNjkzNw%3D%3D%26mid%3D2247638381%26idx%3D1%26sn%3D11f13017068dfecae6169cd8fdbbdc20">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Thu, 05 Nov 2026 07:15:00 +0800</pubDate>
    </item>
    <item>
      <title>入职第一天，被前同事写的SQL查询语句，吓到当场离职……</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzkzMjYzNjkzNw==&amp;mid=2247638379&amp;idx=1&amp;sn=23932cae6f2bb72d6588037feda864c9</link>
      <description>写得乱七八糟的SQL，根本不叫技术，纯粹是给别人挖坑！</description>
      <content:encoded><![CDATA[<p>原创 <span>Rohan Dutt</span> <span>2026-11-04 07:15</span> <span style="display: inline-block;">广东</span></p>






  
  <p><img src="https://wechat2rss.xlab.app/img-proxy/?k=00bf9743&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYbiaj9TB9sxrvZLUNicNpMs5BtUdicUneVlNULibeia7jG70jleeAugE96lMYeiatpsRGeWvTHAE60j6eSTBHXqBkiavs6PbFWia6BPsLs%2F0%3Fwx_fmt%3Djpeg"/></p>
  <p>写得乱七八糟的SQL，根本不叫技术，纯粹是给别人挖坑！</p>
  <p class="mp_profile_iframe_wrp" style="margin-bottom: 0px;" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-service_type="1" data-verify_status="2"></mp-common-profile></p><div data-role="outer" label="edit by 135editor" data-pm-slice="0 0 []"><div data-role="paragraph"><div data-tools="135编辑器" data-id="88516" style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;color: #333333;font-size: 17px;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, Arial, sans-serif;" data-pm-slice="0 0 []"><div style="margin: 0.5em 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><div style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;line-height: 1.75em;"><div data-width="100%" style="margin: -10px 0px;padding: 0px 10px;max-width: 100%;display: inline-block;vertical-align: top;width: 100%;word-wrap: break-word !important;box-sizing:border-box;"><div hm_fix="461:527" style="margin: 0px;padding: 10px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;border-width: 2px;border-style: solid;border-color: white;background-color: #efefef;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="font-family: Helvetica, Arial, sans-serif;font-size: 15px;color: #7f7f7f;letter-spacing: 0.544px;caret-color: red;"><span leaf="">把SQL查询写好，让意图、假设和计算逻辑自己就能解释清楚，不需要额外说明。</span></span></p></div></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img class="rich_pages wxw-img" data-aistatus="1" data-backh="323" data-backw="578" data-imgfileid="100153414" data-ratio="0.558" style="width:100%;" data-type="png" data-w="1000" src="https://wechat2rss.xlab.app/img-proxy/?k=384b2d18&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FgiamgWvCHDYZIVA1eUnDLxrYbp9BZBtYyrJVEia6SNYwBRZczJgvHOpNhWicL6GJ4pZ4xgFkKqCugpiaLXFsEXtpLeMxlSYzoJibPE7x5ODlD5TY%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">上个月，我打开了一个SQL文件。当时我就想，这都是什么鬼？！</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">1400行嵌套混乱的代码：没有注释，没有结构，完全不知所云。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">到处都是 tbl_a、final_temp_v3 这种别名。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">我花了一天半才把它理顺。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">最离谱的是，查询居然成功了。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">可等到财务部门问为什么营收数据对不上时，所有人都哑口无言。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">写得乱七八糟的 SQL 根本不叫技术，纯粹是给别人挖坑。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">我曾经亲眼目睹一位同事凌晨两点重写了一整段查询语句。为什么？因为一个 WHERE 条件被藏在了六个子查询的深处，根本找不到。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">团队每年都要浪费好几周去修这种“自以为聪明”的代码。如果你的 SQL 语句需要翻译（解释）才能看懂，那你不是在写代码，而是给未来制造麻烦。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">一、架构原则</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">不想让别人反复追问你的代码逻辑，必须一开始就注重代码的可读性。以下是我遵循的架构原则，确保每条查询都清晰易懂，而不是暗藏玄机。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">1、清晰的架构</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">1）利用 CTE 摆脱子查询的噩梦</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">嵌套子查询就像剥洋葱，只会让人越看越头疼。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">公共表表达式 (CTE) 可以让你自上而下梳理逻辑，让数据流向变得线性清晰。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">2）“人类可读性”规则</span></span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">规范别名</span>：将t1or替换a为active_customersor monthly_recurring_revenue；</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">布尔标记字段：</span>与其写 status_id IN (1, 4, 7)，不如新增一个名为 is_eligible_for_discount（是否符合折扣资格）的判断字段；</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">线性逻辑：</span>把 SQL 当作菜谱来写。准备好食材（ CTE 定义），混合它们（表连接），最后摆盘（最终查询）。</span></span></p></li></ul><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">2、“自带说明”改造</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">假设我们正在计算客户留存率。在“改造前”的写法中，你会看到层层嵌套的括号。而改造之后的逻辑一目了然。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">1）改造前（混乱版）</span></span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="sql"><code><span leaf=""><span class="code-snippet__keyword">SELECT</span> t1.id, t1.rev, t2.last_login </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">FROM</span> ( <span class="code-snippet__keyword">SELECT</span>  <span class="code-snippet__operator">*</span>  <span class="code-snippet__keyword">FROM</span> sales <span class="code-snippet__keyword">WHERE</span> amt <span class="code-snippet__operator">&gt;</span>  <span class="code-snippet__number">100</span> ) t1 </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">JOIN</span> ( <span class="code-snippet__keyword">SELECT</span> user_id, <span class="code-snippet__built_in">MAX</span> (dt) <span class="code-snippet__keyword">as</span> last_login <span class="code-snippet__keyword">FROM</span> logs <span class="code-snippet__keyword">GROUP</span>  <span class="code-snippet__keyword">BY</span>  <span class="code-snippet__number">1</span> ) t2 </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">ON</span> t1.id <span class="code-snippet__operator">=</span> t2.user_id </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">WHERE</span> t2.last_login <span class="code-snippet__operator">&lt;</span>  <span class="code-snippet__string">&#39;2025-01-01&#39;</span> ;</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">2）“改造后”（自带说明版）</span></span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="sql"><code><span leaf=""><span class="code-snippet__keyword">WITH</span> high_value_sales <span class="code-snippet__keyword">AS</span> ( </span></code><br/><code><span leaf="">    <span class="code-snippet__comment">-- 筛选超过 100 美元的交易以隔离关键客户</span></span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">SELECT</span> </span></code><br/><code><span leaf="">         customer_id, </span></code><br/><code><span leaf="">        amount <span class="code-snippet__keyword">AS</span> revenue </span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">FROM</span> sales </span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">WHERE</span> amount <span class="code-snippet__operator">&gt;</span>  <span class="code-snippet__number">100</span></span></code><br/><code><span leaf=""> ), </span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf="">customer_activity_tracking <span class="code-snippet__keyword">AS</span> ( </span></code><br/><code><span leaf="">    <span class="code-snippet__comment">-- 识别每个用户最近的交互</span></span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">SELECT</span> </span></code><br/><code><span leaf="">         user_id, </span></code><br/><code><span leaf="">        <span class="code-snippet__built_in">MAX</span> (login_date) <span class="code-snippet__keyword">AS</span> last_active_date </span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">FROM</span> user_logs </span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">GROUP</span>  <span class="code-snippet__keyword">BY</span> user_id </span></code><br/><code><span leaf="">) </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">SELECT</span> </span></code><br/><code><span leaf="">     hvs.customer_id, </span></code><br/><code><span leaf="">    hvs.revenue, </span></code><br/><code><span leaf="">    cat.last_active_date </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">FROM</span> high_value_sales hvs </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">JOIN</span> customer_activity_tracking cat <span class="code-snippet__keyword">ON</span> hvs.customer_id <span class="code-snippet__operator">=</span> cat.user_id </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">WHERE</span> cat.last_active_date <span class="code-snippet__operator">&lt;</span>  <span class="code-snippet__string">&#39;2025-01-01&#39;</span> ;</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">这样写的优势：</span></span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">逻辑隔离：</span>如果“收入”逻辑发生变化，你能知道改哪个 CTE ，不用改动连接逻辑；</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">可审计性：</span>当财务部门询问该项收入时，你可以直接指向 high_value_sales 代码块，从命名就能一目了然；</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">10 秒测试：</span>一名初级开发能否在 10 秒内看懂这段代码的用途？如果不能，就需要重构。</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这一套方法给我们团队带来的改变简直惊人，再也不用为了解释数据看板的逻辑而开“紧急会议”了。</span></span></p><div data-role="paragraph" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;" data-pm-slice="0 0 []"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="color: #7f7f7f;font-size: 15px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="" data-pm-slice="1 1 [&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;outer&#34;,&#34;class&#34;:&#34;article135&#34;,&#34;label&#34;:&#34;edit by 135editor&#34;,&#34;data-pm-slice&#34;:&#34;0 0 []&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;paragraph&#34;,&#34;class&#34;:&#34;_135editor&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;},&#34;para&#34;,{&#34;tagName&#34;:&#34;p&#34;,&#34;attributes&#34;:{&#34;style&#34;:&#34;line-height:1.75;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;},&#34;node&#34;,{&#34;tagName&#34;:&#34;span&#34;,&#34;attributes&#34;:{&#34;style&#34;:&#34;font-size: 15px; color: #3e3e3e;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;}]">小建议：写 SQL 的时候，哪怕明年凌晨三点困得睁不开眼，你也能看懂自己写的代码。</span></span></p></div></div></div></div><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">二、让 SQL 更易于理解的 4 个架构优化 </span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">你有没有盯着半年前自己写的 SQL，感觉像是在看外星古文？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">我曾经花了一整个下午，才看懂自己当年 “自以为很巧妙” 的查询语句。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">现在才明白，所谓的“巧妙”，到头来只是“坑未来的自己”。这真是个大教训。想要从根源上避免别人（包括未来的自己）追问你的代码逻辑，你就得写出自带解释、一看就懂的查询。</span></span></p><div data-role="paragraph" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;" data-pm-slice="0 0 []"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="color: #7f7f7f;font-size: 15px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="" data-pm-slice="1 1 [&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;outer&#34;,&#34;class&#34;:&#34;article135&#34;,&#34;label&#34;:&#34;edit by 135editor&#34;,&#34;data-pm-slice&#34;:&#34;0 0 []&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;paragraph&#34;,&#34;class&#34;:&#34;_135editor&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;},&#34;para&#34;,{&#34;tagName&#34;:&#34;p&#34;,&#34;attributes&#34;:{&#34;style&#34;:&#34;line-height:1.75;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;},&#34;node&#34;,{&#34;tagName&#34;:&#34;span&#34;,&#34;attributes&#34;:{&#34;style&#34;:&#34;font-size: 15px; color: #3e3e3e;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;}]">说明：每种优化的完整实操流程我都会详细展开，这里先讲清楚重要性和方法。</span></span></p></div></div></div></div><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">1、 CTE 堪称救星</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这种 WHERE EXISTS (SELECT… FROM (SELECT…)) 套来套去的写法趁早别用了！子查询嵌套简直是人脑的递归噩梦。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">改用 CTE ，将逻辑拆成线性、连贯的流程。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">上个月我用这种方法重构了一个长达 200 行的复杂代码。我同事的反应是：“等等……这居然能看懂了？” </span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">2、字段命名语义化（请不要使用缩写）</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">字段命名至关重要。revenue_after_refunds这样写并不算长，反而更友好。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">用 a、b、t1 这种别名，就像你把厨房里所有罐子都贴上 “食物” 标签一样敷衍。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">当你凌晨两点还在调试代码时，未来的你一定会由衷庆幸：至少知道每个字段到底代表什么。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">3、缩进 = 氧气（给查询一点呼吸空间）</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">缩进是留白，让你的逻辑能呼吸，更易读。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">我曾遇到过一个 bug，JOIN 语句藏得像海盗宝藏似的。这种问题本该 5 分钟定位，结果硬生生花了两小时。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">从那以后，我格式化代码格外认真：JOIN、AND 条件、CASE 语句全部对齐排版，整齐规范。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">4、把假设打上标签（你没听错）</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">不要只写代码做了什么，SQL 本身已经能看出来。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">关键是写下为什么这么做：# Ignores test accounts，处理耗时约2秒。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">三个月后你只会抓狂：“我当初为什么要把 user_id &gt; 1000 排除掉？！” 你记不住，但注释可以。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">经得起追问的 SQL 优化示例</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">下面是一组专业级的进阶优化对比。场景为计算净营收，同时过滤内部测试数据、处理复杂退款逻辑。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">逻辑噩梦（优化之前）：</span></span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="sql"><code><span leaf=""><span class="code-snippet__keyword">SELECT</span> t1.id, <span class="code-snippet__built_in">SUM</span> (t1.amt <span class="code-snippet__operator">-</span> t2.ref_amt) <span class="code-snippet__keyword">as</span> net </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">FROM</span> orders t1 </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">LEFT</span>  <span class="code-snippet__keyword">JOIN</span> ( <span class="code-snippet__keyword">SELECT</span> ord_id, <span class="code-snippet__built_in">SUM</span> (amount) <span class="code-snippet__keyword">as</span> ref_amt <span class="code-snippet__keyword">FROM</span> refunds <span class="code-snippet__keyword">GROUP</span>  <span class="code-snippet__keyword">BY</span>  <span class="code-snippet__number">1</span> ) t2 <span class="code-snippet__keyword">ON</span> t1.id <span class="code-snippet__operator">=</span> t2.ord_id </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">WHERE</span> t1.status_id <span class="code-snippet__keyword">NOT</span>  <span class="code-snippet__keyword">IN</span> ( <span class="code-snippet__number">4</span> , <span class="code-snippet__number">9</span> ) <span class="code-snippet__keyword">AND</span> t1.u_id <span class="code-snippet__operator">&gt;</span>  <span class="code-snippet__number">1000</span> </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">GROUP</span>  <span class="code-snippet__keyword">BY</span>  <span class="code-snippet__number">1</span> ;</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">自带说明的杰作（优化之后）：</span></span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="sql"><code><span leaf=""><span class="code-snippet__keyword">WITH</span> refund_aggregates <span class="code-snippet__keyword">AS</span> ( </span></code><br/><code><span leaf="">    <span class="code-snippet__comment">-- 对每个订单的退款金额求和，以避免多对一连接膨胀</span></span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">SELECT</span> </span></code><br/><code><span leaf="">         order_id, </span></code><br/><code><span leaf="">        <span class="code-snippet__built_in">SUM</span> (refund_amount) <span class="code-snippet__keyword">AS</span> total_refunded_amount </span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">FROM</span> order_refunds </span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">GROUP</span>  <span class="code-snippet__keyword">BY</span> order_id </span></code><br/><code><span leaf="">), </span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf="">filtered_active_orders <span class="code-snippet__keyword">AS</span> ( </span></code><br/><code><span leaf="">    <span class="code-snippet__comment">-- 排除已取消 (4) 和欺诈 (9) 的订单</span></span></code><br/><code><span leaf="">    <span class="code-snippet__comment">-- 排除内部测试帐户（ID &gt; 1000 为生产用户）</span></span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">SELECT</span> </span></code><br/><code><span leaf="">         order_id, </span></code><br/><code><span leaf="">        customer_id, </span></code><br/><code><span leaf="">        gross_transaction_amount </span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">FROM</span> transaction_ledger </span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">WHERE</span> status_id <span class="code-snippet__keyword">NOT</span>  <span class="code-snippet__keyword">IN</span> ( <span class="code-snippet__number">4</span> , <span class="code-snippet__number">9</span> ) </span></code><br/><code><span leaf="">      <span class="code-snippet__keyword">AND</span> user_id <span class="code-snippet__operator">&gt;</span>  <span class="code-snippet__number">1000</span></span></code><br/><code><span leaf=""> ) </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">SELECT</span> </span></code><br/><code><span leaf="">     orders.order_id, </span></code><br/><code><span leaf="">    (orders.gross_transaction_amount <span class="code-snippet__operator">-</span>  <span class="code-snippet__built_in">COALESCE</span> (refunds.total_refunded_amount, <span class="code-snippet__number">0</span> )) <span class="code-snippet__keyword">AS</span> net_realized_revenue </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">FROM</span> filtered_active_orders <span class="code-snippet__keyword">AS</span> orders </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">LEFT</span>  <span class="code-snippet__keyword">JOIN</span> refund_aggregates <span class="code-snippet__keyword">AS</span> refunds </span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">ON</span> orders.order_id <span class="code-snippet__operator">=</span>退款订单号；</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">真相：</span>这不是为了写出完美代码，而是为了以后不恨自己，这是为了热爱你的工作……</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">现在多花五分钟，将来能省下五小时的暴躁调试。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">当业务方或资深架构师质疑你的逻辑时，你完全不必慌。</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">你的同事：交口称赞</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">你的精神状态：安稳平和</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">未来的你：轻松起飞</span></span></p></li></ul><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">三、提升可读性的进阶写法</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">同时我也很快意识到，</span><span style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);" data-pm-slice="0 0 []"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);">有时候修复不光是加几条注释的事。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">那是结构性问题。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">我开始用 CTE 把一堵密密麻麻的代码墙，梳理成按时间顺序展开的逻辑叙事。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">你不用像考古学家那样一层层深挖子查询，而是像读一本书一样，从上到下看懂就完事。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">1、“嵌套地狱”与“叙事式 CTE”</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">核心原则：</span>如果你的逻辑需要超过 5 秒才能看懂，那它就是不合格的，必须重构。清晰易懂不是锦上添花，而是代码的生命线。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">重构后的标准写法：</span></span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="sql"><code><span leaf=""><span class="code-snippet__comment">/* 目的：计算 2025 财年的年度客户流失率。</span></span></code><br/><code><span leaf="">   理由：根据领导层 2025 年 11 月 12 日的指示，不包括试用账户。*/ </span></code><br/><code><span leaf=""><span class="code-snippet__operator">*/</span> </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">WITH</span> valid_subscriptions <span class="code-snippet__keyword">AS</span> ( </span></code><br/><code><span leaf="">    <span class="code-snippet__comment">-- 过滤掉内部测试帐户和过期试用帐户</span></span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">SELECT</span> </span></code><br/><code><span leaf="">         user_id, </span></code><br/><code><span leaf="">        subscription_start_date, </span></code><br/><code><span leaf="">        total_recurring_revenue </span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">FROM</span> production_schema.subscriptions </span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">WHERE</span> is_internal_account <span class="code-snippet__operator">=</span>  <span class="code-snippet__literal">FALSE</span>  </span></code><br/><code><span leaf="">      <span class="code-snippet__keyword">AND</span> subscription_status <span class="code-snippet__operator">!=</span>  <span class="code-snippet__string">&#39;trial_expired&#39;</span></span></code><br/><code><span leaf=""> ), </span></code><br/><code><span leaf="">annual_revenue_calculation <span class="code-snippet__keyword">AS</span> ( </span></code><br/><code><span leaf="">    <span class="code-snippet__comment">-- 按用户汇总收入以处理多计划帐户</span></span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">SELECT</span> </span></code><br/><code><span leaf="">         user_id, </span></code><br/><code><span leaf="">        <span class="code-snippet__built_in">SUM</span> (total_recurring_revenue) <span class="code-snippet__keyword">AS</span> total_user_revenue </span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">FROM</span> valid_subscriptions </span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">WHERE</span> subscription_start_date <span class="code-snippet__operator">&gt;=</span>  <span class="code-snippet__string">&#39;2025-01-01&#39;</span> </span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">GROUP</span>  <span class="code-snippet__keyword">BY</span>  <span class="code-snippet__number">1</span></span></code><br/><code><span leaf=""> ) </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">SELECT</span>  </span></code><br/><code><span leaf="">    <span class="code-snippet__built_in">COUNT</span> (user_id) <span class="code-snippet__keyword">AS</span> total_active_customers, </span></code><br/><code><span leaf="">    <span class="code-snippet__built_in">SUM</span> (total_user_revenue) <span class="code-snippet__keyword">AS</span> total_fiscal_revenue </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">FROM</span> annual_revenue_calculation;</span></code><br/></pre></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">2、严苛型架构师的三大守则</span></strong></span></p></div></div></div><div data-role="paragraph" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="color: #7f7f7f;font-size: 15px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">说明：</span><span style="font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: rgb(255, 255, 255);line-height: 25.6px;text-decoration: inherit;max-width: 100%;clear: both;min-height: 1em;color: rgb(127, 127, 127);font-size: 15px;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;box-sizing: border-box !important;overflow-wrap: break-word !important;" data-pm-slice="0 0 []"><span leaf="" style="color: rgb(127, 127, 127);font-size: 15px;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;">这相当于把文档工作开到</span></span><strong style="font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: rgb(255, 255, 255);line-height: 25.6px;text-decoration: inherit;max-width: 100%;clear: both;min-height: 1em;color: rgb(127, 127, 127);font-size: 15px;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="color: rgb(127, 127, 127);font-size: 15px;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;">地狱难度</span></strong><span leaf="" style="font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: rgb(255, 255, 255);line-height: 25.6px;text-decoration: inherit;max-width: 100%;clear: both;min-height: 1em;color: rgb(127, 127, 127);font-size: 15px;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;box-sizing: border-box !important;overflow-wrap: break-word !important;">…</span><span leaf="">…（不感兴趣可以忽略）</span></span></p></div></div></div></div><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">元数据层规范：</span>我开始对每张表、每个字段都使用 COMMENT ON 命令添加注释。现在，字段与表的说明直接固化在数据库结构中。团队成员不再反复问基础问题，因为答案就写在元数据里。只要开发人员查看表结构，文档说明就直接呈现在眼前。</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">强制代码检查规则：</span>我在开发环境中集成了一个SQL 代码检查工具，并配置规则直接禁止 rev_tot、t1 这类敷衍命名，同时强制规范缩进与语义化命名。现在，在提交合并请求之前，工具就会提前标出不规范写法。</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">上下文动机注释：</span>我不只注释代码做了什么（代码本身已经能体现），还注释为什么这样做：- 仅保留2023年数据，避免历史冗余数据干扰（业务方要求）。这样就不会再出现团队群里紧急追问的情况。我的查询语句，本身就能解释自己存在的意义。</span></span></p></li></ul><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">四、逻辑自查：建立专业可信度</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">打开你最近写的一段 SQL 脚本。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">试着重构其中一个 CTE</span> 或子查询，给它起一个清晰到不是技术岗产品经理都能看懂的名字。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">把 mau_temp 改成 monthly_active_users（月活跃用户）。把 t1 改成 filtered_transaction_logs（已过滤交易日志）。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">你会发现，当你大声读出这段逻辑时，不用任何额外说明，思路瞬间就通了。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这就是命名的力量。它能把一段晦涩的代码谜题，变成一段通顺易懂的逻辑叙事。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">编写自解释 SQL 查询的详细步骤：</span></span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">步骤1：用命名 CTE 替代子查询</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">实操流程：</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">1）定位到实现某条具体业务规则的嵌套子查询；</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">2）将其抽离至 WITH 子句中，并使用语义清晰、面向结果的命名；</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">3）在主逻辑块中直接引用这个命名好的 CTE。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">例子：</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="sql"><code><span leaf=""><span class="code-snippet__comment">-- 修改前（逻辑隐藏较深，需要进行思维导图）</span></span></code><br/><code><span leaf=""><span class="code-snippet__keyword">SELECT</span> order_id </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">FROM</span> orders </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">WHERE</span> customer_id <span class="code-snippet__keyword">IN</span> ( <span class="code-snippet__keyword">SELECT</span> id <span class="code-snippet__keyword">FROM</span> customers <span class="code-snippet__keyword">WHERE</span> status <span class="code-snippet__operator">=</span>  <span class="code-snippet__string">&#39;active&#39;</span> ); </span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf=""><span class="code-snippet__comment">-- 修改后（逻辑线性且自描述）</span></span></code><br/><code><span leaf=""><span class="code-snippet__keyword">WITH</span> active_customers <span class="code-snippet__keyword">AS</span> ( </span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">SELECT</span> id </span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">FROM</span> customers </span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">WHERE</span> status <span class="code-snippet__operator">=</span>  <span class="code-snippet__string">&#39;active&#39;</span></span></code><br/><code><span leaf=""> ) </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">SELECT</span> order_id </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">FROM</span> orders </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">WHERE</span> customer_id <span class="code-snippet__keyword">IN</span> ( <span class="code-snippet__keyword">SELECT</span> id <span class="code-snippet__keyword">FROM</span> active_customers);</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">结果：</span>查询语句读起来就像一组指令，未来的你（或是同事）不用一层层去找括号，就能立刻看清逻辑依赖关系。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">步骤2：使用能完整说明含义的字段别名</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">实操流程：</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">1）遍历查询语句，找出 SELECT 子句或复杂计算中含义模糊的字段名称；</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">2）将其替换为能体现设计意图的别名，明确说明数据的状态与用途；</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">3）应用到 JOIN 关联条件中，让表与表之间的关联关系一目了然。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">例子：</span></span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="sql"><code><span leaf=""><span class="code-snippet__comment">-- 修改前（计算不明确）</span></span></code><br/><code><span leaf=""><span class="code-snippet__keyword">SELECT</span></span></code><br/><code><span leaf="">     (price <span class="code-snippet__operator">*</span> quantity) <span class="code-snippet__operator">-</span> discount <span class="code-snippet__keyword">AS</span> final_amount </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">FROM</span> orders; </span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf=""><span class="code-snippet__comment">-- After ( Explicit business logic) </span></span></code><br/><code><span leaf=""><span class="code-snippet__keyword">SELECT</span></span></code><br/><code><span leaf="">     (price <span class="code-snippet__operator">*</span> quantity) <span class="code-snippet__operator">-</span> discount <span class="code-snippet__keyword">AS</span> total_revenue_net_of_discounts </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">FROM</span> orders;</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">结果：</span>业务分析师不用对照数据字典就能直接理解你的查询结果。由于字段名称本身就定义了数据含义，排查问题也变得一目了然。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">步骤3：有策略地使用留白和缩进</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">实操流程：</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">1）将主要子句（SELECT、FROM、WHERE、GROUP BY）</span><span style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);" data-pm-slice="0 0 []"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);">各放一行</span></span><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);">；</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">2）缩进JOIN条件和子逻辑，体现层级关系；</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">3）用空行分隔数据准备阶段（CTE）和最终聚合阶段。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">例子：</span></span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="sql"><code><span leaf=""><span class="code-snippet__comment">-- 修改前（数据密集，解析困难）</span></span></code><br/><code><span leaf=""><span class="code-snippet__keyword">SELECT</span> o.id, c.name, <span class="code-snippet__built_in">SUM</span> (p.amount) <span class="code-snippet__keyword">AS</span> revenue <span class="code-snippet__keyword">FROM</span> orders o <span class="code-snippet__keyword">JOIN</span> customers c <span class="code-snippet__keyword">ON</span> o.customer_id <span class="code-snippet__operator">=</span> c.id <span class="code-snippet__keyword">JOIN</span> payments p <span class="code-snippet__keyword">ON</span> o.id <span class="code-snippet__operator">=</span> p.order_id <span class="code-snippet__keyword">WHERE</span> o.status <span class="code-snippet__operator">=</span>  <span class="code-snippet__string">&#39;completed&#39;</span>  <span class="code-snippet__keyword">AND</span> c.is_active <span class="code-snippet__operator">=</span>  <span class="code-snippet__literal">TRUE</span>  <span class="code-snippet__keyword">GROUP</span>  <span class="code-snippet__keyword">BY</span> o.id, c.name; </span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf=""><span class="code-snippet__comment">-- 修改后（结构化且易于扫描）</span></span></code><br/><code><span leaf=""><span class="code-snippet__keyword">SELECT</span></span></code><br/><code><span leaf="">     o.id, </span></code><br/><code><span leaf="">    c.name, </span></code><br/><code><span leaf="">    <span class="code-snippet__built_in">SUM</span> (p.amount) <span class="code-snippet__keyword">AS</span> lifetime_settled_revenue </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">FROM</span> orders o </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">JOIN</span> customers c </span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">ON</span> o.customer_id <span class="code-snippet__operator">=</span> c.id </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">JOIN</span> payments p </span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">ON</span> o.id <span class="code-snippet__operator">=</span> p.order_id </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">WHERE</span></span></code><br/><code><span leaf="">     o.status <span class="code-snippet__operator">=</span>  <span class="code-snippet__string">&#39;completed&#39;</span> </span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">AND</span> c.is_active <span class="code-snippet__operator">=</span>  <span class="code-snippet__literal">TRUE</span> </span></code><br/><code><span leaf=""><span class="code-snippet__keyword">GROUP</span>  <span class="code-snippet__keyword">BY</span></span></code><br/><code><span leaf="">     o.id, </span></code><br/><code><span leaf="">    c.name;</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">结果：</span></span><span style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);" data-pm-slice="0 0 []"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);">你的查询看起来像一份专业的技术规范书，向同事传递一个信号：逻辑严谨、值得信赖。</span></span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">步骤4：将业务前提直接嵌入查询语句</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">实操流程：</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">1）找出代码中隐含的业务逻辑（例如 “仅适用于美国用户”“排除内部测试账号” 等）；</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">2）添加行内注释，使用统一标识前缀（如 -- #），将业务规则与普通代码说明区分开；</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">3）把注释直接写在对应逻辑的位置，而不是只放在文件头部。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">例子：</span></span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="sql"><code><span leaf=""><span class="code-snippet__keyword">WITH</span> regional_customer_base <span class="code-snippet__keyword">AS</span> ( </span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">SELECT</span> </span></code><br/><code><span leaf="">         user_id, </span></code><br/><code><span leaf="">        signup_date </span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">FROM</span> customers </span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">WHERE</span> country_code <span class="code-snippet__operator">=</span>  <span class="code-snippet__string">&#39;US&#39;</span> </span></code><br/><code><span leaf="">    <span class="code-snippet__comment">-- # 业务规则：根据 2025 年税务合规更新，排除地区（波多黎各、关岛、美属维尔京群岛）</span></span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">AND</span> state_code <span class="code-snippet__keyword">NOT</span>  <span class="code-snippet__keyword">IN</span> ( <span class="code-snippet__string">&#39;PR&#39;</span> , <span class="code-snippet__string">&#39;GU&#39;</span> , <span class="code-snippet__string">&#39;VI&#39;</span> ) </span></code><br/><code><span leaf="">)</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">结果：</span>你的查询将具备可审计性。当业务方质疑数据为什么发生变化时，理由已经在代码记录的版本历史中写好了，不用临时回忆或反复沟通。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">你编写的代码不只是给数据库执行，更是给未来需要维护数据库的人看的。</span></span></p></div><div data-role="paragraph" style="font-family:sans-serif;"><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">作者丨</span><span style="color: #888888;font-size: 14px;letter-spacing: 0.5px;text-align: justify;text-decoration-thickness: initial;display: inline !important;font-family:Helvetica, Arial, sans-serif;"><span leaf="">Rohan Dutt     编译丨dbaplus社群</span></span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;text-align: left;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">来源丨网址：<a href="https://medium.com/@Rohan_Dutt/how-to-write-sql-queries-that-are-self-documenting-before-your-logic-starts-getting-interrogated-6c1ba8915e0d" target="_blank">https://medium.com/@Rohan_Dutt/how-to-write-sql-queries-that-are-self-documenting-before-your-logic-starts-getting-interrogated-6c1ba8915e0d</a></span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">dbaplus社群欢迎广大技术人员投稿，投稿邮箱：</span></span><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">editor@dbaplus.cn</span></span></p><p class="mp_profile_iframe_wrp" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-service_type="1" data-verify_status="2"></mp-common-profile></p><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img" data-aistatus="1" data-imgfileid="100130225" data-ratio="0.07777777777777778" data-s="300,640" type="block" data-w="1080" src="https://wechat2rss.xlab.app/img-proxy/?k=f32823a4&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FufWcjcomw8Zf2jiaBBH3vdgfP4A2rem5YEAHYH074dc4GibhojA5B3lLZrXLDRciaVnficveaHcAUCiaIPoDsTkAduA%2F640%3Fwx_fmt%3Dpng"/></p></div></div><p style="display: none;"><mp-style-type data-value="3"></mp-style-type></p>



<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=48b6a867&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzkzMjYzNjkzNw%3D%3D%26mid%3D2247638379%26idx%3D1%26sn%3D23932cae6f2bb72d6588037feda864c9">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Wed, 04 Nov 2026 07:15:00 +0800</pubDate>
    </item>
    <item>
      <title>16岁高中生凌晨敲下admin，竟闯入微软17.3万亿行核心库！全网看傻眼……</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzkzMjYzNjkzNw==&amp;mid=2247638378&amp;idx=1&amp;sn=dc507d483888fd6f711b24c40fc8829e</link>
      <description>市值数万亿美元的科技帝国，防线怎么会脆弱得像一层窗户纸？</description>
      <content:encoded><![CDATA[<p><span>尚未抵达notyet</span> <span>2026-11-03 07:15</span> <span style="display: inline-block;">广东</span></p>




  <p>以下文章来源于：尚未抵达notyet</p>
  <strong>尚未抵达notyet</strong>
  <p>尚未抵达notyet面向需要判断 AI 机会与风险的读者，长期关注黑箱机制、模型幻觉、平台规则与不可见的算法舞台。</p>



  
  <p><img src="https://wechat2rss.xlab.app/img-proxy/?k=76239d2d&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FgiamgWvCHDYaZEW082SpMuq4HEBMMHXibJuZCqGHWibbicXBW5UhXEO2KUfLUwApy9edyEkkwQFC05H0ib6PwaKA49Y6qcOeiaiao4JvNK4BkvKF0o%2F0%3Fwx_fmt%3Djpeg"/></p>
  <p>市值数万亿美元的科技帝国，防线怎么会脆弱得像一层窗户纸？</p>
  <p class="mp_profile_iframe_wrp" style="margin-bottom: 0px;" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-servicetype="0" data-verify_status="2"></mp-common-profile></p><div data-role="outer" label="edit by 135editor" data-pm-slice="0 0 []"><div data-role="paragraph"><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">凌晨两点，万籁俱寂。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">16岁的高中生 Faav 坐在卧室电脑前。父母正在隔壁房间熟睡，他刚刚写完周五的学校作业，顺手点开了一条卡了整整十天的代码线索。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">他在键盘上敲下了五个字母：<span textstyle="" style="font-weight: bold;">admin</span>。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">回车，屏幕瞬间弹回一个孤零零的数字：<span textstyle="" style="font-weight: bold;">1</span>。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">紧接着，一串长得让人眼晕的数字跳了出来：<span textstyle="" style="font-weight: bold;">17333335124315</span>。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">17.3万亿行记录。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">那一刻，这个16岁的少年死死盯着屏幕，激动得差点叫出声来。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">但他硬生生捂住了嘴，他怕吵醒熟睡的父母，只能一遍又一遍地核对算术。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">手里既无微软员工账号与内部密码，更缺少合法的加密签名，这个还没成年的高中生，仅凭一张自己手搓的“空白假证”和一个最老套的默认用户名，就以最高管理员的身份，大摇大摆地走进了<span textstyle="" style="font-weight: bold;">微软内部分析平台 Titan</span> 的心脏。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img class="rich_pages wxw-img" data-aistatus="1" data-backh="378" data-backw="578" data-ratio="0.6546296296296297" style="-webkit-tap-highlight-color:rgba(0, 0, 0, 0);margin:0px;padding:0px;outline:0px;color:rgba(0, 0, 0, 0.9);font-family:&#34;PingFang SC NEW&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size:16px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:0.544px;orphans:2;text-align:start;text-indent:0px;text-transform:none;widows:2;word-spacing:0px;-webkit-text-stroke-width:0px;white-space:normal;background-color:rgb(255, 255, 255);text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;user-select:auto;width:100%;" data-w="1080" src="https://wechat2rss.xlab.app/img-proxy/?k=afe358d8&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FziczBxEktqDFEZYVHmhL20wr94robChBfx9w8dXGGaOtvmYOqVACv5wtvNkdGFBaFaNiawZVQCm4mGddxPegm2uvrk15HDSvkibcDz5ib5zLUpM%2F640%3Fwx_fmt%3Dother%26from%3Dappmsg%26tp%3Dwxpic%26wxfrom%3D5%26wx_lazy%3D1%26watermark%3D1%23imgIndex%3D1"/></span></span></p><p style="text-align:center;line-height: 1.75;"><span style="color: #7f7f7f;font-size: 12px;"><span leaf="">▲ 漏洞公开后，16岁研究者 Faav 在 X 上感叹：“依然不敢相信，凌晨两点敲下‘admin’，就让我进了微软17万亿行记录。”</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">消息一出，整个国际安全圈彻底炸锅。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">所有人都在追问同一个问题：<span textstyle="" style="font-weight: bold;">市值数万亿美元的科技帝国，防线怎么会脆弱得像一层窗户纸？</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">顺着少年公开的调查笔记往回追查，一条环环相扣、堪比好莱坞谍战片的“数字侦察链”浮出了水面。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">一、第一重异常：锁死的正门，与敞开的“说明书”</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">故事的起点，要倒回2026年8月25日。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Faav 虽然只有16岁，但已经是漏洞赏金圈的“老手”。早在15岁时，他就挖出过微软访客签到系统的漏洞。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">为了在课余时间抓虫，他自己写了一个名叫 <span textstyle="" style="font-weight: bold;">Antares</span> 的个人 AI 辅助狩猎工具，专门在后台自动扫描大厂的子域名、反复试错。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">8月25日这天，AI 助手把微软的内部数据分析平台 <span textstyle="" style="font-weight: bold;">Titan</span> 标记为了一条可疑线索。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">从表面上看，Titan 固若金汤。任何外部访客点开它的网页前端，都会被一堵冷冰冰的提示墙挡回来：“<span textstyle="" style="font-weight: bold;">需要 VPN（VPN Required）</span>”。在普通人眼里，这就是一扇锁死的铁门。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">但 Antares 顺着网络解析往下摸，发现了一个极其反常的现象：<span textstyle="" style="font-weight: bold;">网页正门确实锁了，但负责干活的后端 API 接口，竟然挂在另一台公开可达的 Azure 云服务主机上。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">荒唐的场面还在后头。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">在这台公网主机的根路径下，微软工程师竟然把一整套 <span textstyle="" style="font-weight: bold;">Swagger/OpenAPI 交互式文档</span>原封不动地忘在了公网上。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">什么是 Swagger 文档？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">打个比方，黑客平时搞渗透，就像蒙着眼睛在黑屋子里摸索开关，得花几个星期去猜接口叫什么名字、参数怎么填。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">而暴露在公网的 Swagger 文档，相当于<span textstyle="" style="font-weight: bold;">银行金库的设计师直接把《金库内部结构与开锁说明书》贴在了后门玻璃上。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">说明书上清清楚楚地列着四条核心通道。其中第三条名叫 /v2/Query，文档里甚至贴心地注明：这个接口不仅能查数据，还<span textstyle="" style="font-weight: bold;">直接接受原始 SQL 语句（Raw SQL）</span>。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">正门挂着“闲人免进”，后窗却大敞四开，窗台上还摆着操作指南。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">在国际权威的 <span textstyle="" style="font-weight: bold;">OWASP API 安全标准（API9:2023）</span> 中，这种脱离了统一网关监管、在公网裸奔的接口，有一个专门的称呼，“<span textstyle="" style="font-weight: bold;">影子 API（Shadow API）</span>”。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">二、第二重追查：乘着“时光机”，唤醒三年前的僵尸</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">拿到说明书后，Faav 立即对着 /v2/Query 发送了一条最基础的测试指令：SELECT 1。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">服务器拒绝了他，返回 401 未授权错误。同时，接口还需要一个正确的“路由键（Routing Value）”，也就是告诉系统你要查哪个具体的数据集。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">去哪找微软内部的路由键？暴力盲猜不仅慢，还会触发警报。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这位16岁少年展现出了惊人的老辣。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">他没有硬撞服务器，而是打开了被称为“互联网时光机”的<span textstyle="" style="font-weight: bold;">互联网档案馆（Wayback Machine）</span>，把时间拨回了 <span textstyle="" style="font-weight: bold;">2023年</span>。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">在三年前保存下来的 Titan 历史登录页与隐私页快照里，他翻出了一套早就撤下的旧版 <span textstyle="" style="font-weight: bold;">Apache Superset 前端配置文件</span>。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这些沉睡在历史缓存里的 JavaScript 代码，像化石一样完整保留了平台当年的家底：里面清清楚楚写着 <span textstyle="" style="font-weight: bold;">56个后端数据表路由定义</span>，其中就包括一个名叫 TestData 的测试路由。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Faav 把这56个三年前的“老古董”放进2026年的线上接口里挨个测试。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">结果令人瞠目结舌，<span textstyle="" style="font-weight: bold;">其中整整30个路由，在三年后的今天依然完全存活（Live）</span>！</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="1.4287037037037038" data-w="1080" style="-webkit-tap-highlight-color:rgba(0, 0, 0, 0);margin:0px;padding:0px;outline:0px;color:rgba(0, 0, 0, 0.9);font-family:&#34;PingFang SC NEW&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size:16px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:0.544px;orphans:2;text-align:start;text-indent:0px;text-transform:none;widows:2;word-spacing:0px;-webkit-text-stroke-width:0px;white-space:normal;background-color:rgb(255, 255, 255);text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;user-select:auto;width:100%;" data-backw="578" data-backh="826" src="https://wechat2rss.xlab.app/img-proxy/?k=19e4fa4a&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FziczBxEktqDFPvZstFzvFwV6ic5KwIa2lzeNNs9RgVPVqyDkVQfbghR9QSibQUygNDDSgBDTFSHZ5M41QtYmouhdcN6n7VRwLwXiaSVqkWibhxvE%2F640%3Fwx_fmt%3Dother%26from%3Dappmsg%26tp%3Dwxpic%26wxfrom%3D5%26wx_lazy%3D1%26watermark%3D1%23imgIndex%3D2"/></span></span></p><p style="text-align:center;line-height: 1.75;"><span style="font-size: 12px;color: #7f7f7f;"><span leaf="">▲ 安全博主制作的案件图解：前端挂着 VPN 门禁，背后却是暴露的 Swagger 文档、互联网档案馆里的旧配置，以及不验签的令牌。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这就是大厂微服务架构里最要命的顽疾，“<span textstyle="" style="font-weight: bold;">僵尸 API（Zombie API）</span>”。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">很多人以为，只要把网页上的旧按钮删掉，旧功能就下线了。但在庞大的企业云端，工程师往往害怕“删掉旧接口会搞崩某个不知名的老业务”，于是只拆前端、不关后端。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">三年前的网页快照，就这样穿过时间裂缝，成了撬开今天微软大门的铁撬棍。</span></span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">三、致命一击：AI 卡壳十天，人类一秒破局</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">路由打通了，只剩最后一道关卡：身份认证。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Titan 系统要求访问者出示一枚<span textstyle="" style="font-weight: bold;"> JWT（JSON 网络令牌）</span>。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">为了方便理解，你可以把 JWT 想象成一张<span textstyle="" style="font-weight: bold;">电子工作证</span>。这张工作证由三部分组成：<span textstyle="" style="font-weight: bold;">头部</span>（写着防伪算法）、<span textstyle="" style="font-weight: bold;">载荷</span>（印着你的姓名、部门、权限），以及决定真伪的第三部分，<span textstyle="" style="font-weight: bold;">加密签名</span>（相当于防伪钢印）。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">正常情况下，保安（服务器）拿到工作证，第一步必须先拿验钞机照一下<span textstyle="" style="font-weight: bold;">防伪钢印</span>。钢印是真的，再去读上面印着的名字</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">在接下来的十天里，AI 助手 Antares 对着这个接口不断变换参数试错。在成百上千次报错中，Faav 敏锐地捕捉到了一个诡异的细节：<span textstyle="" style="font-weight: bold;">无论怎么涂改工作证上的部门和名字，哪怕不更换后面的防伪钢印，系统居然都照单全收！</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">一个大胆的念头冒了出来：难道这个保安根本不看防伪钢印？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Faav 立即动手伪造了一张假证。他在头部声明里写上<span textstyle="" style="font-weight: bold;"> &#34;alg&#34;:&#34;none&#34;（无加密算法）</span>，把第三段的签名直接留空。结果，这张连防伪章都没有的白条，一路绿灯通过了租户、受众和应用 ID 的全部检查！</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">然而，就在距离终点只有一步之遥的地方，AI 卡住了。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">无论 AI 怎么尝试，系统始终冷冰冰地报错：<span textstyle="" style="font-weight: bold;">User not found（用户未找到）</span>。因为令牌里代表用户名的字段叫 upn（用户主体名称），在微软体系里，这通常是一串邮箱地址。AI 助手死守着这个逻辑，夜以继日地猜了无数个微软员工风格的邮箱，全都吃了闭门羹。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">线索僵持了整整十天，直到9月5日那个周五的凌晨一点，做完功课的 Faav 重新坐回电脑前，看着满屏的报错，人类的直觉突然跳出了 AI 的思维定式：<span textstyle="" style="font-weight: bold;">既然这个系统底层用的是开源的 Apache Superset，万一后端程序员偷懒，根本没把 upn 当成微软邮箱，而是直接拿去查本地数据库的用户名呢？</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">本地数据库最默认的管理员叫什么？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">他删掉邮箱，随手敲进了 admin。屏幕跳出数字 1，admin 被直接映射为本地1号用户，系统最高管理员。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">AI 用十天的枯燥穷举把人送到了门前，而人类用凌晨一点的灵光一闪，拧开了门锁。</span>正如安全大V vx-underground 看完报告后的黑色幽默短评：“这蠢得太离谱了，但我喜欢。”</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">四、17.3万亿行背后，与5000美元的“耳光”</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">门推开后，里面的景象让这个16岁少年屏住了呼吸。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">他先用 SHOW DATABASES 看了一眼平台元数据库。光是与 Titan 相关的内部目录与配置里，就躺着<span textstyle="" style="font-weight: bold;">约2.5万条账号记录、17,990条微软员工邮箱、1.5万条员工组织记录</span>，以及355个数据库配置和2.1万条 SQL 定义。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">接着，他看到了独立的<span textstyle="" style="font-weight: bold;">必应（Bing）搜索分析数据源</span>。为了证明漏洞的真实性，同时严守白帽黑客的法律与道德边界，他格外谨慎地只做了“有界采样”，<span textstyle="" style="font-weight: bold;">仅提取了两行必应样本</span>（只包含国家或州级的粗略反向 IP 位置，不涉及具体个人身份），绝不多碰一条客户隐私。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">最后，他做了一次全局摸底。那30个存活的历史路由，背后连通着<span textstyle="" style="font-weight: bold;"> 17个 ClickHouse 分析数据库、9,863张独立数据表。</span>他调取系统元数据进行汇总核对，算出了那个震惊全网的存储规模数字：17,333,335,124,315 行。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这里必须严谨地划清一条界限：<span textstyle="" style="font-weight: bold;">“能够触及”不等于“已经泄露”</span>。17.3万亿行是包含历史、重复和派生数据在内的平台总存储规模估算，Faav 从未搬走这17万亿行数据，整起事件里也没有任何客户隐私（PII）遭到窃取。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">发现问题的当晚（9月5日），Faav 就把报告交给了微软安全响应中心（MSRC）。微软四天后（9月9日）锁死了该接口。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">然而，当9月17日微软公布赏金数额时，全网替这位少年打抱不平，<span textstyle="" style="font-weight: bold;">仅仅 5,000 美元（约合人民币3.5万元）</span>。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">不仅如此，在文章公开发表前，微软还对他的博客行使了<span textstyle="" style="font-weight: bold;">编辑审查权</span>，删减了部分章节与图表，并重新修饰了关于漏洞影响范围的表述。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="2.7601851851851853" data-w="1080" style="-webkit-tap-highlight-color:rgba(0, 0, 0, 0);margin:0px;padding:0px;outline:0px;color:rgba(0, 0, 0, 0.9);font-family:&#34;PingFang SC NEW&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size:16px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:0.544px;orphans:2;text-align:start;text-indent:0px;text-transform:none;widows:2;word-spacing:0px;-webkit-text-stroke-width:0px;white-space:normal;background-color:rgb(255, 255, 255);text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;user-select:auto;width:100%;" data-backw="578" data-backh="1595" src="https://wechat2rss.xlab.app/img-proxy/?k=389d2cd1&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FziczBxEktqDGpHsicbXRYpRiajcQXz2JTNoiaX4Y71HzGSup6OUYGVAGGXwibibK40dQ5LAa8936QznniaRiaPOlqDMTZichoQT6rk3m54rdjhlKuUOE%2F640%3Fwx_fmt%3Dother%26from%3Dappmsg%26tp%3Dwxpic%26wxfrom%3D5%26wx_lazy%3D1%26watermark%3D1%23imgIndex%3D3"/></span></span></p><p style="text-align:center;line-height: 1.75;"><span style="font-size: 12px;color: #7f7f7f;"><span leaf="">▲ 突发新闻账号 International Cyber Digest 汇总了“未签名令牌、5000美元赏金与微软修改描述”等细节，阅读量迅速突破百万。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">“5000美元简直像一记耳光！”X 平台上的安全从业者们炸开了锅。有人直言，这种直接捅穿内部分析底座、连着17个核心库的漏洞，赏金至少该是五位数甚至六位数。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Faav 本人倒是显得很平静。他在评论区坦言，开会时他确实礼貌地问过微软能不能提高赏金或给点额外奖金，但对方以<span textstyle="" style="font-weight: bold;">“公司政策不允许”</span>为由拒绝了。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">他之所以依然愿意给微软挖漏洞，很大程度上是因为微软允许他在修补后公开写出这些精彩的技术故事。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">五、最昂贵的围墙，防不住最朴素的偷懒</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">复盘整起事件，全程既不涉及高深莫测的零日漏洞，也无需算力恐怖的超级计算机破解。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">一个16岁的高中生之所以能单枪匹马走入微软的数据腹地，靠的是对手接连犯下的四个低级错误：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">以偏概全的防线：</span>以为前端网页挂个 VPN 提示，后面的 API 就安全了；</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">随手乱丢的图纸：</span>把生产环境的 Swagger 接口文档直接敞开在公网上；</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">死而不僵的旧账：</span>三年前的测试路由从未物理下线，留给互联网档案馆当了跳板；</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">形同虚设的验票：</span>校验证件上的每一行字，唯独跳过了最核心的密码学签名验证。</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">在 AI 编程与自动化工具狂飙突进的今天，这起深夜奇袭给所有科技巨头敲响了一记警钟：<span textstyle="" style="font-weight: bold;">当微服务膨胀到成千上万个时，冲垮安全防线的往往是内部失控的“影子资产”与某一行偷懒省掉的验签代码，而非外部最顶尖的攻击长矛。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">毕竟，如果你在每扇防盗门上都装了最先进的读卡器，却允许任何人拿一张手写的白纸刷开门锁，那么门后的金库修得再大，也不过是一座不设防的沙堡。</span></span></p></div><div data-role="paragraph" style="font-family:sans-serif;"><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">作者丨林予</span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;text-align: left;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">来源丨公众号：尚未抵达notyet（ID：not-yethere）</span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">dbaplus社群欢迎广大技术人员投稿，投稿邮箱：</span></span><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">editor@dbaplus.cn</span></span></p><p class="mp_profile_iframe_wrp" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-servicetype="0" data-verify_status="2"></mp-common-profile></p><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.07777777777777778" data-s="300,640" data-w="1080" type="block" data-imgfileid="100130225" src="https://wechat2rss.xlab.app/img-proxy/?k=f32823a4&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FufWcjcomw8Zf2jiaBBH3vdgfP4A2rem5YEAHYH074dc4GibhojA5B3lLZrXLDRciaVnficveaHcAUCiaIPoDsTkAduA%2F640%3Fwx_fmt%3Dpng"/></p></div></div><p style="display: none;"><mp-style-type data-value="3"></mp-style-type></p>



<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=2d8506a8&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzkzMjYzNjkzNw%3D%3D%26mid%3D2247638378%26idx%3D1%26sn%3Ddc507d483888fd6f711b24c40fc8829e">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Tue, 03 Nov 2026 07:15:00 +0800</pubDate>
    </item>
    <item>
      <title>被Oracle收购45天后就离职了！14年老员工回忆：Sun只是输在“懒得做生意”</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzkzMjYzNjkzNw==&amp;mid=2247638375&amp;idx=1&amp;sn=c35ad1bf68447d8621c088ef559758b0</link>
      <description>Sun 为什么倒下？Oracle 收购后发生了什么？AWS 如何抢占云计算先机？</description>
      <content:encoded><![CDATA[<p>原创 <span>整理自</span> <span>2026-11-02 07:15</span> <span style="display: inline-block;">广东</span></p>






  
  <p><img src="https://wechat2rss.xlab.app/img-proxy/?k=b88c76cb&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FgiamgWvCHDYYpfEQRYIea8icwsFt8T9WymTmj1H4Ifoy6R5JZTkXpmDFicLW2zYAicNw7JXEibP7icibPicOkX2wnI1gmU4fzrP1v9dAh935iaobjGdg%2F0%3Fwx_fmt%3Djpeg"/></p>
  <p>Sun 为什么倒下？Oracle 收购后发生了什么？AWS 如何抢占云计算先机？</p>
  <p class="mp_profile_iframe_wrp" style="margin-bottom: 0px;line-height: 1.6em;" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-service_type="1" data-verify_status="2"></mp-common-profile></p><div data-role="outer" label="edit by 135editor" data-pm-slice="0 0 []"><div data-role="paragraph"><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">四十多年前，Sun Microsystems 是硅谷最有影响力的科技公司之一。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">2009 年，Sun 被 Oracle 收购。45 天后，在 Sun 待了 14 年工程师 Bryan Cantrill 辞职了。他说不是因为待遇，而是因为 &#34;感到羞耻&#34;—— 他无法为一家被客户极度不信任的公司工作。离开 Oracle 后，他加入 Joyent 和与 AWS 正面竞争，又在 2019 年创立了 Oxide。</span></span></p><p style="line-height: 1.75;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);">与其说这是 </span><span style="font-size: 15px;color: #3e3e3e;"><span leaf="" data-pm-slice="1 1 [&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;outer&#34;,&#34;class&#34;:&#34;article135&#34;,&#34;label&#34;:&#34;edit by 135editor&#34;,&#34;data-pm-slice&#34;:&#34;0 0 []&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;paragraph&#34;,&#34;class&#34;:&#34;_135editor&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;p&#34;,&#34;attributes&#34;:{&#34;style&#34;:&#34;line-height:1.75;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;node&#34;,{&#34;tagName&#34;:&#34;span&#34;,&#34;attributes&#34;:{&#34;style&#34;:&#34;font-size: 15px; color: #3e3e3e;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;}]">Bryan 的</span></span><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);">一段职业生涯回顾，不如说是一部硅谷公司兴衰亲历记：<span textstyle="" style="font-weight: bold;">Sun 为什么倒下？Oracle 收购后发生了什么？AWS 如何抢占云计算先机？</span></span><span style="font-size: 15px;color: #3e3e3e;"><span leaf="" data-pm-slice="1 1 [&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;outer&#34;,&#34;class&#34;:&#34;article135&#34;,&#34;label&#34;:&#34;edit by 135editor&#34;,&#34;data-pm-slice&#34;:&#34;0 0 []&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;paragraph&#34;,&#34;class&#34;:&#34;_135editor&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;p&#34;,&#34;attributes&#34;:{&#34;style&#34;:&#34;line-height:1.75;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;node&#34;,{&#34;tagName&#34;:&#34;span&#34;,&#34;attributes&#34;:{&#34;style&#34;:&#34;font-size: 15px; color: #3e3e3e;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;}]"><span textstyle="" style="font-weight: bold;">Bryan </span></span></span><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-weight: bold;">为什么要逆势开公司？</span>以下是访谈的核心内容：</span></p><div data-tools="135编辑器" data-id="5" data-color="rgb(198, 198, 199)" data-custom="rgb(198, 198, 199)" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;border: 0px none;z-index: 0;max-width: 100%;font-size: 16px;widows: 1;visibility: visible;"><div style="max-inline-size: 100%;margin: 2px auto;padding: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;max-width: 100%;font-size: 14px;line-height: 25px;border-width: 2px;border-style: dashed;border-color: #c6c6c7;visibility: visible;"><p style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;clear: both;min-height: 1em;cursor: text;max-width: 100%;vertical-align: inherit;line-height: 1.5em;visibility: visible;"><span style="caret-color: red;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">一、在 Sun Microsystems 工作的岁月</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 14px;font-weight: 400;letter-spacing: normal;font-style: normal;color: #333333;text-decoration: none solid #333333;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">二、如何成长为杰出的工程师</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 14px;font-weight: 400;letter-spacing: normal;font-style: normal;color: #333333;text-decoration: none solid #333333;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">三、为什么讨厌 Oracle 收购案？</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 14px;font-weight: 400;letter-spacing: normal;font-style: normal;color: #333333;text-decoration: none solid #333333;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">四、为什么 Bezos 是资本主义的顶级掠食者</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 14px;font-weight: 400;letter-spacing: normal;font-style: normal;color: #333333;text-decoration: none solid #333333;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">五、创立自己的公司 Oxide</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 14px;font-weight: 400;letter-spacing: normal;font-style: normal;color: #333333;text-decoration: none solid #333333;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">六、为什么专注通用 CPU 而不是 GPU</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 14px;font-weight: 400;letter-spacing: normal;font-style: normal;color: #333333;text-decoration: none solid #333333;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">七、AI 热潮与衰退中的建议</span></span></span></p></div></div><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.51796875" data-s="300,640" data-type="png" data-w="1280" style="width:100%;" type="block" data-croporisrc="https://mmbiz.qpic.cn/mmbiz_png/giamgWvCHDYZDhEDgV4gyCk4lIp6vILEByEjFLXnff8sCHatuFgCDlCMJOibT5tvCZIsIVp2VdpzSuEtaWtO0HotYR394IcibVWABvBibtloKdU/0?wx_fmt=png&amp;from=appmsg" data-cropx1="2.7681660899653977" data-cropx2="1599.9999999999998" data-cropy1="0" data-cropy2="827.6816608996539" data-backw="577" data-backh="299" data-imgfileid="100154414" src="https://wechat2rss.xlab.app/img-proxy/?k=7cc81714&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FgiamgWvCHDYbJRwJLsc1gdWs4ibqg3aick9At4v0LFweLwmicVNvI2gHJLFYOPVK0vSIOq6iarz8FvJQ6jA6JubohZQdI833ZXEhUy0X4K8nhCXQ%2F640%3Fwx_fmt%3Djpeg"/></p><p style="line-height: 1.75;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);">以下为这场访谈的中文编译。</span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">一、在 Sun Microsystems 工作的岁月</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：你的职业生涯起步于 Sun Microsystems，这是一家颇具传奇色彩的公司。你刚进这行的时候，整个行业是什么样的？那时候有没有类似现在 FAANG 这种级别的公司？Sun 当时是什么画风？</span></span><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">其他几家公司又是什么情况？</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Bryan：</span></span><span leaf="">每个时代其实都有类似 FAANG 这种级别的公司。60 年代有个组合叫&#34;The Bunch&#34;——Burroughs、UNIVAC、NCR、Control Data，还有 Honeywell，这几家合起来就叫这个。<span textstyle="" style="font-weight: bold;">那时候就是 IBM 和 &#34;The Bunch&#34; 两分天下。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">但到我那个年代，行业正好卡在一个低谷期。我是 1996 年毕业的，1995 年就开始到处面试了，那个年代微软简直一家独大。我当时心里特别明确，出于原则，我是不会去微软的。</span></span></p><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：为什么呢？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Bryan：</span></span><span leaf=""><span textstyle="" style="font-weight: bold;">我觉得比尔盖茨毁了我的童年。</span>我是在 80 年代个人电脑时代长大的，那时候用电脑就等于要忍受烂系统。微软的 DOS 完全没有内存保护，一个程序出问题，整个机器直接重启。比如你正在 WordPerfect 或 WordStar 里写文章，机器说重启就重启，你只能祈祷自己刚存过盘，或者手里有打印出来的纸质版。一直到上大学我才反应过来：微处理器里其实早就有内存保护了，我整个青少年时期硬件都有这个功能，但 DOS 根本就没用它。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">后来我在工作站上第一次接触 Unix，我到现在都记得那种震撼——一个窗口开着命令行，另一个窗口通过 FTP 从 wuarchive 下载 EGA 游戏，第三个窗口干别的，第四个窗口在编译代码，这些事情居然能同时运行，我当时整个人都惊呆了，心想这怎么可能。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">回头再看，我凭什么要忍微软的烂东西？微软本质上根本不是一家操作系统公司，虽然他们是最大的操作系统供应商。</span><span leaf="">微软基因里最核心的东西是编译器，他们本来就是靠编译器起家的。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">苹果当时也没好到哪去，那时候乔布斯早就被踢走了。Mac 界面是干净一些，但同样没用内存保护，这简直不可理喻。微软非常反竞争，后来 Netscape 案的事实认定也证明了他们手段下三滥。这家公司从来不是靠技术取胜的，而是靠抢位子，抢到了就开始滥用市场地位搞垄断。</span></span></p><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：</span></span><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">这种滥用行为具体是怎么回事？简单说说。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Bryan：</span></span><span leaf="">微软有个屡试不爽的套路。如果一家有潜力的公司做出一款有市场的应用，微软就会宣布这个功能即将成为操作系统的新特性，但实际上它根本不会做出来。这就是所谓的 &#34;雾件&#34;，这个词就算不是微软发明的，它也绝对把这门艺术发扬光大了。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">微软就靠这种平庸的策略占据主导地位。但公平地说，他们真进场之后产品也会慢慢变好。比如现在还在用的 Microsoft Word，但当年 WordPerfect 才是真正的主流文字处理器，还有 WordStar。微软的 Word 一开始非常烂，后来慢慢完善，最终取代了 WordPerfect，部分原因就是他们开始把 Word 和操作系统捆绑销售。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">所以微软的反竞争是根深蒂固的。这不是个人观点，这是 Alsop 法官做出的事实认定。后来比尔盖茨到了中年，公司变了很多，90 年代末反垄断案之后也有变化。但我当时就是不会去微软工作。</span></span></p><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：我看到你离开 Sun 时写的公开告别帖，你说刚加入时只确定了两件事：一是想做操作系统内核开发，二是不太想为 Sun 工作。但看起来你在 Sun 工作得还不错。是什么让你从 &#34;我不想在这干&#34; 变成 &#34;我喜欢在这干&#34; 的？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Bryan：</span></span><span leaf="">我之前和 Sun 的其他团队聊过，接触的人都不错，但就是感受不到激情，PBN 团队尤其没有激情。后来遇到 Kevin Clark 和 Jeff Bonwick ，他们充满能量，看到了操作系统领域所有可以创新的地方，想把烂代码撕掉换成漂亮的代码，和我有一样的劲头。遇到他们之后我就确定了，我要去 Sun 工作，如果他们给我 offer，我绝对去。</span></span></p><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：Sun 股价跌了 98%，一度低于现金价值，当时裁员情况是什么样的？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Bryan：</span></span><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);">Sun 最初还在苦苦支撑。</span><span leaf="">Scott McNealy 出了名的不想裁员，但那是个错误，拖得太久了。一旦开始裁员，就停不下来。</span><span leaf="">我数过，八年里大概裁了 35 轮，规模有大有小。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">说起来有点阴暗，我们当时有个办法，虽然那时候还没有 REST API，但可以通过员工目录工具编程获取数据。我们每天跑一个脚本，叫 &#34;讣告&#34;，告诉你谁不在公司了。小裁员你能看到零星几个人消失，大裁员就看到一下走了 1500 人、3000 人。</span></span></p><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：公司知道你们有这个权限吗？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Bryan：</span></span><span leaf=""><span textstyle="" style="font-weight: bold;">Sun 的优点和缺点都是没人真正管事。</span>我们用的是官方组织架构工具，没有违规。Sun 算是相当透明的公司，我们没做什么出格的事，只是用这个办法了解公司里发生了什么，就是一轮接一轮的裁员，没完没了。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">当时每家公司都在裁员。2000 年春天 Pets.com 倒闭，整个行业靠惯性撑到年底，到 2000 年末，互联网泡沫才真正全面破裂，Sun 也未能幸免。911 事件更是雪上加霜，科技行业此后沉寂了五年。Y Combinator 大约在 2006 年成立，我觉得部分原因就是当时存在资本真空，有人能解决有趣的问题，却融不到钱创业。那几年的日子确实非常难熬。</span></span></p><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：你曾经发过一条帖子，说</span></span><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">&#34;</span></span><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">创业公司要是失败了，别急着把锅甩给团队。成功往往是团队厉害，失败却几乎都是领导层不行</span></span><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">。</span></span><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">&#34;这个观点对 Sun 适用吗？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Bryan：</span></span><span leaf=""><span textstyle="" style="font-weight: bold;">我不认为 Sun 失败了。</span>Sun 1983 年创立，2008 到 2009 年被收购，这已经是非常出色的成绩。它是上市公司，位列财富 200 强，多少孩子因为父母在 Sun 工作才上得起大学。Sun 或许没有达到自己的雄心，但在我看来，它是成功的。</span></span></p><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：事后看来，如果当时有不同的领导，结局可以改变吗？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Bryan：</span></span><span leaf="">我觉得有可能。Sun 最终没能作为独立公司存活下来，原因有很多。<span textstyle="" style="font-weight: bold;">互联网泡沫时期，我们对高利润上了瘾，之后一直没能摆脱这种依赖，而且接受 x86 也太晚了。</span>公司内部变得四分五裂，一轮轮裁员也无济于事。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">我们 Fishworks 团队当时在做存储设备，我觉得如果 Sun 保持独立，这款产品完全可以成为公司新产品开发的典范，但这需要真正对这个方向感兴趣的领导层，而我们当时没有。</span><span leaf="">事后回头看，也许确实到了该改变的时候。这就像正常健康的森林里会发生的林火。林火本来就是森林生命周期的一部分，要有它，森林才能迎来重生。Sun 成功过，但也走到了尽头，该翻篇了。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">二、如何成长为杰出的工程师</span></strong></span></p></div></div></div></div><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：从 MTS3 一路做到杰出工程师，如果回头拆解这段成长，有哪些让你印象深刻的高光时刻？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Bryan：</span></span><span leaf="">我从来没把注意力放在职级、排名或晋升上。我宁愿晋升得慢一点也不愿被拔得太高，我不想做表演性质的工作。Sun 是一家非常能包容有主见的工程师的公司，<span textstyle="" style="font-weight: bold;">我想做的就是解决客户的问题，把操作系统做成我认为它该有的样子，实现操作系统该有的愿景。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">说实话，1996 年只有 Sun 还在真正投入操作系统研发。其他公司都把未来押在了微软和 Windows 身上，所有电脑厂商都在放弃自研操作系统、放弃 Unix，那是 Unix 最黑暗的年代。身处 Solaris 内核开发团队，我们充满激情，也有机会大展拳脚。晋升不过是水到渠成的结果。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Sun 有一套正式的绩效考核流程，但这套考核从来没让我表现得更好。这么说可能显得天真，但绩效考核的本质不是帮你提升，而是衡量你的表现。可它本该是用来给反馈、帮每个人做到最好的。一年一考的周期我觉得糟透了：你提交自评，收到的上级评价跟你的自评几乎一模一样，只是多了些语法错误。每次评审，哪怕是晋升评审，都让人提不起劲。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">我职业生涯里真正有成就感的时刻从来都不是晋升，而是<span textstyle="" style="font-weight: bold;">完成一项重要的工作，解决一个棘手的 bug，或是和同事一起做成了一件我们原以为不可能的事。</span>那些时刻才真正推动我成长。</span></span></p><p style="line-height: 1.75;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);">Sun 的晋升流程很传统，表现好的人往上升一级。但公司有一套很荒谬的评级机制，分三档：最高档、优秀、良好，比例大概是 70% 良好、20% 优秀、10% 最高档。规则是拿到最高档就必须晋升，于是最高档反而成了晋升的代名词。</span></p><p style="line-height: 1.75;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);">也正因为如此，每次评审经理都会带着歉意跟我说：你这段时间的工作非常出色、有创新性，比一两年前做得还好，<span textstyle="" style="font-weight: bold;">但我只能给你优秀，因为给你最高档就得晋升，而你一年前刚升过，公司不希望有人 18 个月内连升两级。</span>我就说，行吧，你觉得没问题就行。</span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Sun 有个叫 KEEP 的关键员工激励计划，相当于年度分红。Staff 工程师能拿到 KEEP 奖金，奖金好的时候他们会请大家吃饭，感觉像挖矿小镇挖到了金矿。我就想，等我升到 Staff 工程师就好了。结果我 2000 或 2001 年升到 Staff 工程师的时候，正好互联网泡沫破裂，KEEP 奖金为零。从那以后 Sun 市值在公开市场跌了 98%。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">再往上是高级 Staff 工程师，然后是杰出工程师。这个级别有两条晋升路径。第<span textstyle="" style="font-weight: bold;">一条是从高级 Staff 工程师晋升</span>，过程非常政治化：由现任杰出工程师投票决定你能不能加入他们的圈子，这简直是把民主用在了不该用的地方，晋升难度极大。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">第二条路是被 Sun 收购，谈判时对方有足够筹码顺带提出 &#34;我们的 CTO 必须是杰出工程师&#34;。</span>于是就会有你从没听过的人突然成了杰出工程师，一问才知道是收购来的。内部成长起来的和收购来的杰出工程师，差别一眼就能看出来。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">当时 Sun 的 CTO 是 Greg Papadopoulos，我非常感激他。他支持了我们在旧金山的一个团队，叫 Fishworks，我们在那里开发了一款新存储产品，卖得非常好。杰出工程师的晋升需要另一位杰出工程师来推荐。Greg </span></span><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">亲自推荐了我，全票通过。Greg 其实更把这件事看作公司层面的认可，而不是对我个人的评价，这样很好。我做的工作在某种程度上是无可争议的，这就是我想要的职业发展方式。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">三、为什么讨厌Oracle收购案？</span></strong></span></p></div></div></div></div><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：Sun 最终被 Oracle 收购了，为什么当时那么有争议？维基百科上甚至有个页面专门讲 Sun 被收购，读起来像讣告一样，很多顶级工程师都走了。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Bryan：</span></span><span leaf="">Scott McNealy 给 Sun 写的墓志铭是：<span textstyle="" style="font-weight: bold;">大杀四方，玩得尽兴，不搞歪门邪道，热爱客户，改变计算世界。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">那时有一份很有意思的 SEC 备案文件，很戏剧化。当时 IBM 和惠普都在争着收购 Sun，而且各自都在给对手使绊子，想把 Sun 抢到手。因为它们收购 Sun 的动机，本身就带着打击、报复的意味。这两家本来都是 Sun 的竞争对手，结果就在他们互相较劲、互相拆台的时候，Oracle 突然杀出来，把 Sun 买走了。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">收购很迅速，其实这件事没什么争议，花了些时间才完成交割。Oracle 没什么追求，像只章鱼，唯一关心的就是怎么把自己喂饱。但 Sun 完全不是这样。Sun 有一种特质，我不会叫它纯粹主义，但 <span textstyle="" style="font-weight: bold;">Sun 总是努力为客户做正确的事，努力解决有商业价值的技术难题，给工程师极大的自由去做这些事。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">它吸引的就是想做大事、有野心的人，也因为鼓励这种技术进取心，成为工程师的好去处。所以 NFS、ZFS、Java、Solaris，还有我参与的那些技术，全都是从 Sun 出来的。这么多开创性技术都来自 Sun，就是因为那种热情和独立性。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">但 Oracle 完全没有这些，它只关心一件事，就是自己的利润。收购时我还在想，这下有意思了，我们终于有个商业头脑厉害的人了。Sun 在商业执行上确实摔过很多跟头，我以为 Oracle 会更擅长经营企业，结果是我高估了。</span></span></p><p style="line-height: 1.75;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-weight: bold;">Oracle 的核心能力是锁定客户，扼杀竞争，然后涨价。</span>Oracle 没有赢得客户的信任。你要是去问客户：你们信任 Oracle 吗？答案肯定是不信。这个事实本身就说明了一切。我不想为这种公司工作。</span></p><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：收购后顶级工程师大规模离职，大家私下会商量着离开吗？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Bryan：</span></span><span leaf="">那当然。收购正式完成前，有些工程师会被直接裁掉，不会转成 Oracle 员工。但他们能拿到相当丰厚的遣散费。于是就出现了排队求裁的盛况，人人都在打听怎么才能被裁。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">至今还有人对此愤愤不平，说谁谁被裁拿了一年遣散费，我是因为实在没法昧着良心干下去才辞职的，45 天就走了，一分钱没有。我们当时在旧金山的 Fishworks 团队，我还一度有点乐观，觉得也许能把两家公司的优势结合起来。结果证明根本不是那么回事。</span></span></p><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：是什么原因让你迅速离职？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Bryan：</span></span><span leaf="">我非常清楚这是一家截然不同的公司。从下定决心到真正离开，又拖了大概 30 到 45 天。这期间 Oracle 又接连给了我好几个理由，让我越发觉得实在没办法在这干下去。Sun 有很多很多缺点，但它赢得了客户的信任。客户是真心实意地支持我们，希望我们赢。因为我们对客户坦诚，哪怕有时候说了实话对自己不利，我们也会照实说，绝不欺骗客户。客户非常看重这一点，而 Oracle 没有这份信任。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">我意识到一件事：<span textstyle="" style="font-weight: bold;">我没法为一家客户极度不信任的公司工作。</span>这严重消解了我工作的意义感。在 Sun 我偶尔会觉得尴尬，但从未感到羞耻。在 Oracle，我感到羞耻。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">四、为什么 Bezos 是资本主义的顶级掠食者</span></strong></span></p></div></div></div></div><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：Sun 被收购后，你下一家公司是 Joyent，我知道这家公司和 AWS 竞争。你说过一句有意思的话，Bezos 是资本主义的顶级掠食者。为什么这么说？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Bryan：</span></span><span leaf="">亚马逊在巅峰期的执行力惊人。Bezos 真正厉害的地方在于，让亚马逊挖到一座金矿，而且不全是靠运气。<span textstyle="" style="font-weight: bold;">他们做出了 S3 和 EC2，意识到自己抓住了多大的机会，在所有人反应过来之前就抢占了云计算的先机。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">2010 到 2015 年，每届 re:Invent 都是降价加一批新服务。作为客户你会觉得太好了，有什么理由不用呢。这就是我说的顶级掠食者。他做的是一门利润极高的生意，但他用了一个绝妙的手段：亚马逊不单独披露 AWS 收入。电商和 AWS 混在一起，只报亚马逊总收入。分析师在电话会议上问，他们就说我们不讨论这个。作为上市公司居然能这么干。加上持续降价，外界就觉得云是门烂生意，没人敢进来。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">但我们因为和亚马逊竞争、做过公有云，知道内情，根本不是那么回事。这门生意利润率非常高，亚马逊执行力极强，那些年做得很出色。现在当然还是很赚钱的公司，但已经不是当年那个样子了。</span></span></p><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：</span></span><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">为什么 </span></span><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);" data-pm-slice="1 1 [&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;outer&#34;,&#34;label&#34;:&#34;edit by 135editor&#34;,&#34;data-pm-slice&#34;:&#34;0 0 []&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;paragraph&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;p&#34;,&#34;attributes&#34;:{&#34;style&#34;:&#34;line-height: 1.75;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null}]"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Bezos </span></span><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">会继续如此无情地不断扩张，而不是榨取剩余价值呢？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Bryan：</span></span><span leaf="">因为他不是普通掠食者，而是资本主义的顶级掠食者。这就是他厉害的地方：<span textstyle="" style="font-weight: bold;">他要扩大优势，让没人能跟我竞争，让没人敢进这行。</span>而且他用的是正道——好产品+合理价格。你会觉得，行，这是双赢。那个时代对云原生公司的创新至关重要。但和亚马逊竞争非常残酷，你得找到自己的赛道，我们找到了能竞争的赛道，但很艰难。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">五、创立自己的公司 Oxide</span></strong></span></p></div></div></div></div><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：你创立了 Oxide，这背后有什么故事？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Bryan：</span></span><span leaf="">我一直知道自己想创业，而且认定了要和 Steve 一起。我去 Joyent 之前并不认识他，去那有部分是为了逃离 Oracle，另外也因为那边允许我招人。我到了 Joyent 才认识 Steve，发现这个人极其优秀。Steve 负责市场和销售，我们合作非常紧密，我便认定一定要和他一起创业。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">我认识一位知名 VC，他曾在邮件里说 &#34;你放在我面前的任何东西我都会投&#34;。我跟 Steve 说，那我们就放手做内心真正想做的，造一台机架级计算机。Steve 在 Dell 十年、我在 Sun 14 年、我们又一起在 Joyent 十年，这是刻在骨子里的事。我们想全栈自研板卡、交换机、直流母线和所有软件，造一台自己真正想要的机器。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">真正的催化剂是我们在 Open Compute 峰会上看到了 Tioga Pass，那种震撼就像一个用了多年 DOS 的人第一次发现 Unix，原来计算机可以是这个样子。我们决定为企业市场打造这样的产品。这个想法非常反直觉，而反直觉恰恰是风投喜欢的特质。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">我回去找那个说 &#34;投任何东西&#34; 的 VC，讲了 45 秒他就说 &#34;停，开电脑公司我不感兴趣&#34;。我说你几年前邮件里说会投任何东西，他说 &#34;听起来不像我&#34;。我要挂电话，他又叫住说不投但可以帮忙。我早就想好答案了，说想跟他投过的那个失败公司的创始人聊聊，了解哪里出了问题。他牵了线。</span></span></p><p style="line-height: 1.75;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);">那家公司的方向和 Oxide 很像，但他们没融多少钱，可以说融得太少了。他们做出来的东西比我们在 Oxide 做的小得多。Oxide 的最小可行产品就是一个机架，很大，我们花了三年多才开发出来。</span><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);">他们开发得快一些，但产品要小得多。基本上可以把它看作 2013 年左右的 Nitro。AWS 的 Nitro 为 AWS 承担了大量关键的计算卸载，所以它也可以算作 Nitro 的早期雏形。但它其实并没有市场。</span></p><p data-pm-slice="0 0 []" style="line-height: 1.75;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);">不过他们找到了一个客户，一家大银行，客户很满意，特别想在他们的活动目录服务器上用。这款产品终于有市场匹配了，然后融了一大笔钱，招了庞大的销售团队。问题是，这家全球最大的银行之一，只想在六台活动目录服务器上跑，所以就买六台。你会想，全球有几家最大的银行？嗯，还有几家，总共能卖个几十台吧，没问题。</span></p><p style="line-height: 1.75;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);">等他们意识到销售团队有一大堆人要养的时候，已经晚了。这不是一个归零的项目，他们被收购了，但收购的方式让创始人极其不满。他觉得是 VC 在错误的时间给他灌了太多钱，逼他做了错误的事，然后他被困在收购公司里，非常不开心。</span></p><p style="line-height: 1.75;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);">就是这个人，我跟他描述我们在 Oxide 想做的事，他说，这是自杀任务。我只记得在小笔记本上写下 &#34;自杀任务&#34; 四个字，还画了下划线，心想，<span textstyle="" style="font-weight: bold;">我们在执行自杀任务，有意思。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">六、为什么专注通用 CPU 而不是 GPU</span></strong></span></p></div></div></div></div><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：现在说到机架级计算，我想到的更多是 GPU 机架而不是 CPU，你们做 GPU 吗？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Bryan：</span></span><span leaf="">这个问题问得好。2019 年起步时 GPU 当然存在也重要，但那不是我们的重点。我们专注通用计算、通用存储、通用网络，有太多东西可以去构建和差异化。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">我们想从第一性原理出发构建系统，在软硬件接口层保持透明，写最底层的软件，做的是软硬件协同设计的产品。</span>要做到这一点就得能写非常底层的软件，而这和 Nvidia 不兼容。Nvidia 执行力很强，但它是一家非常封闭的公司。这意味着 Oxide 面前有两扇门，一扇是和 Nvidia 竞争，一扇是和 Nvidia 合作，两扇我都不想进。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">我当然不想和 Nvidia 竞争，虽然现在竞争似乎比以前更现实了，但我们也没法合作，因为双方对系统该怎么构建的看法完全不同。Nvidia 的思路是他们要掌控整个技术栈，不管合作方是谁。那行，我们就专注通用 CPU。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">有意思也有点意外的是，GPU 赛道非常拥挤，Nvidia 一家独大，周围一堆竞争者，打得很血腥。而通用 CPU 那边还是惠普、戴尔、Supermicro，还在做他们一直做的那套老东西。所以<span textstyle="" style="font-weight: bold;">在软硬件协同产品这个方向，我们是独一份。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">不断有公司找上门，我一开始觉得不合适，因为对方有大量 GPU。结果对方说，我们也有大量 CPU。不只是 AI 负载，高性能计算也是如此，专用计算都需要搭配大量通用 CPU。你用 ChatGPT 浏览网页时看到的那个转圈加载图标，不是 GPU 在跑，是 CPU 在跑，CPU 的作用至关重要。所以我们比以往更专注通用 CPU，要把产品做到理想状态，还有大量工作要做。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">未来某个时候我们可能会做加速器，但可预见的未来不会。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">七、AI 热潮与衰退中的建议</span></strong></span></p></div></div></div></div><p style="line-height: 1.75;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Q：你经历过很多次繁荣和衰退，说实话我都不知道现在是繁荣还是衰退，AI 发展快得不行，但又到处在裁员。以你经历过繁荣衰退的经验，对现在市场里的人有什么建议？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">Bryan：</span></span><span leaf="">我觉得周期性是这个行业固有的。我刚搬来硅谷时想，太好了，我做软件的，不会受繁荣衰退影响。我祖父是石油工程师，我从小听着工厂建了又关、管道建了又关的故事长大，石油行业就是大起大落。我当时以为自己能免疫，现在回头看，太天真了。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">我们这行也有周期，原因说起来有点意思：<span textstyle="" style="font-weight: bold;">无论太乐观还是太悲观，我们都会过度反应。我的建议是，别盲从别人。总有人跟你说这个是未来、那个已经死了，你得自己判断。</span>1996 年有人跟我说操作系统已经没前途了，我幸好没听；2019 年有人说不能开电脑公司，我们幸好没听；风投说只投 SaaS，现在 SaaS 也不好过。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">同样的道理，如果你真心想做 SaaS，即便现在有人说 SaaS 会被生成式 AI 和 LLM 辅助编程挤压，这话也有道理，但只要你心在这行，就别被悲观或乐观的情绪左右。<span textstyle="" style="font-weight: bold;">自己判断，做你内心真正认同的事。</span>用乔布斯的话说，这是你想在宇宙中留下的印记。如今 LLM 的进展确实惊人，如果你真的被它吸引，那就去做。</span></span></p></div><div data-role="paragraph" style="font-family:sans-serif;"><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span style="color: #888888;font-size: 14px;letter-spacing: 0.5px;text-align: justify;text-decoration-thickness: initial;display: inline !important;font-family:Helvetica, Arial, sans-serif;"><span leaf="">整理丨dbaplus社群</span></span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;text-align: left;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">来源丨网址：<a href="https://www.youtube.com/watch?v=qhSL-5GtmQM" target="_blank">https://www.youtube.com/watch?v=qhSL-5GtmQM</a></span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">dbaplus社群欢迎广大技术人员投稿，投稿邮箱：</span></span><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">editor@dbaplus.cn</span></span></p><p class="mp_profile_iframe_wrp" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-service_type="1" data-verify_status="2"></mp-common-profile></p><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.07777777777777778" data-s="300,640" data-w="1080" type="block" data-imgfileid="100130225" src="https://wechat2rss.xlab.app/img-proxy/?k=f32823a4&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FufWcjcomw8Zf2jiaBBH3vdgfP4A2rem5YEAHYH074dc4GibhojA5B3lLZrXLDRciaVnficveaHcAUCiaIPoDsTkAduA%2F640%3Fwx_fmt%3Dpng"/></p></div></div><p style="display: none;"><mp-style-type data-value="3"></mp-style-type></p>



<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=54a8b692&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzkzMjYzNjkzNw%3D%3D%26mid%3D2247638375%26idx%3D1%26sn%3Dc35ad1bf68447d8621c088ef559758b0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Mon, 02 Nov 2026 07:15:00 +0800</pubDate>
    </item>
    <item>
      <title>从数据治理到知识建设：企业Agent落地需要补哪些工程能力？</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzkzMjYzNjkzNw==&amp;mid=2247638375&amp;idx=2&amp;sn=3cfedc6ea6461248519029e8f3d1b7a9</link>
      <description>企业Agent知识建设四步法，让AI员工真正上岗</description>
      <content:encoded><![CDATA[<p><span>dbaplus社群</span> <span>2026-11-02 07:15</span> <span style="display: inline-block;">广东</span></p>






  
  <p><img src="https://wechat2rss.xlab.app/img-proxy/?k=d9611747&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYbYY5GpzwbNcszDe6uHPUqFtP2ibwb5GKocvYXqb3CgNnGaicYv6d467a8LNrsTCzSY6j36KjAJoR5vUDcfMM8a9ws1LlfhB8ib54%2F0%3Fwx_fmt%3Djpeg"/></p>
  <p>企业Agent知识建设四步法，让AI员工真正上岗</p>
  <div data-role="outer" label="edit by 135editor" data-tplid="295085" data-pm-slice="0 0 []"><div data-role="outer" label="edit by 135editor"><div data-tools="135编辑器" data-id="us-3745001"><div style="box-sizing: border-box;padding:0 5px;"><div data-role="paragraph" style=""><div data-role="paragraph" style=""><div data-role="paragraph" style="font-family:sans-serif;"><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="" data-pm-slice="1 1 [&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;outer&#34;,&#34;class&#34;:&#34;article135&#34;,&#34;label&#34;:&#34;edit by 135editor&#34;,&#34;data-tplid&#34;:&#34;295085&#34;,&#34;data-pm-slice&#34;:&#34;0 0 []&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;outer&#34;,&#34;class&#34;:&#34;article135&#34;,&#34;label&#34;:&#34;edit by 135editor&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;class&#34;:&#34;_135editor&#34;,&#34;data-tools&#34;:&#34;135编辑器&#34;,&#34;data-id&#34;:&#34;us-3745001&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;class&#34;:&#34;article135&#34;,&#34;style&#34;:&#34;box-sizing: border-box; padding:0 5px;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;paragraph&#34;,&#34;class&#34;:&#34;_135editor&#34;,&#34;style&#34;:&#34;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;paragraph&#34;,&#34;class&#34;:&#34;_135editor&#34;,&#34;style&#34;:&#34;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;class&#34;:&#34;_135editor&#34;,&#34;data-role&#34;:&#34;paragraph&#34;,&#34;style&#34;:&#34;font-family:sans-serif;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;p&#34;,&#34;attributes&#34;:{},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;node&#34;,{&#34;tagName&#34;:&#34;span&#34;,&#34;attributes&#34;:{&#34;style&#34;:&#34;font-size: 15px; color: #3e3e3e; letter-spacing: normal; line-height: 1.6em; font-family:\&#34;Helvetica Neue\&#34;, Helvetica, \&#34;Hiragino Sans GB\&#34;, \&#34;Apple Color Emoji\&#34;, \&#34;Emoji Symbols Font\&#34;, \&#34;Segoe UI Symbol\&#34;, Arial, sans-serif;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;}]">大模型越来越强，企业IT也在AI上投入了不少预算采购平台、搭建Agent，希望提高效率、改善业务结果。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">但业务真正用起来，Agent还是会推荐错产品、遗漏客户信息，甚至给出前后矛盾的答案。员工需要反复核对、修改，业务团队也迟迟用不起来。<span textstyle="" style="font-weight: bold;">最终，钱花了、人力投入了，业务结果却没有明显改善。</span></span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">问题究竟出在哪里？</span></span></p><p style="text-align: center;line-height: 1.75em;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.4733194733194733" data-s="300,640" data-type="png" data-w="1443" style="width: 100%;" type="block" data-backw="568" data-backh="269" data-imgfileid="100154702" src="https://wechat2rss.xlab.app/img-proxy/?k=99a7a54d&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYaDibZsgPaWCgqVpvvz8ccVGl02DIYjAQib9dVIicml24VtxZe6hia48GK0oVl1ceia2FTczkGjs9hVXKH6iaEkLEzeiabxiaTSjfViavVY%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">10月29日下午，在dbaplus社群联合瓴羊的直播中，瓴羊产品运营昭悦与瓴羊产品经理知毅，从一次客户增购方案的准备经历聊起，拆解企业Agent落地中容易被忽略的一环：<span textstyle="" style="font-weight: bold;">如何把企业已有的数据、资料和经验，建设成AI能够理解、调用的业务知识，让投入真正体现在具体工作和业务效果上。</span></span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">昭悦在直播中分享了一个场景：为了准备客户回访，她把客户上一笔订单、产品资料和历史方案PPT交给Agent，希望TA推荐适合客户的新功能模块，并生成沟通材料。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">结果，Agent推荐的一个功能，客户早就买了；另一个功能，则属于另一款产品。<span textstyle="" style="font-weight: bold;">已经喂了不少资料，为什么还是答不准？</span></span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">上一笔订单，无法完整反映客户当前购买的全部功能；近期需求，可能藏在会议录音和客户沟通记录中；客户、产品、版本与功能之间的关系，也需要明确告诉Agent。人做方案时会自然补充这些背景，AI却未必拿得到。</span></span></p><p style="text-align: center;line-height: 1.75em;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.51484375" data-s="300,640" data-type="png" data-w="1280" style="width: 100%;" type="block" data-backw="568" data-backh="292" data-imgfileid="100154703" src="https://wechat2rss.xlab.app/img-proxy/?k=e5fa7179&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYaPhpM0oNibsJhGb2sQeLoHg66DcucaMJqPzWnqBGof8vTmz8LP0eiab3VRzuicjj3ic1WIeFCe2srYaGdJLibUibNlZY2JuSw0Sq5QI%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">让Agent理解业务，需要把完成任务所需的事实、依据和判断规则一起准备好。</span></span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">客户买过什么，是业务事实；客户最近关心什么，需要从沟通资料中提取；结合客户需求、已购功能和产品能力判断推荐方向，则涉及业务关系与岗位经验。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">这也是本场直播讨论的核心：企业如何围绕具体工作，建立一套可用、可信、能够持续维护的知识体系。</span></span></p><p style="text-align: center;line-height: 1.75em;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.5171875" data-s="300,640" data-type="png" data-w="1280" style="width:100%;" type="block" data-backw="568" data-backh="294" data-imgfileid="100154704" src="https://wechat2rss.xlab.app/img-proxy/?k=4dc844a2&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYa4NYXIfTXuhibEn0eK0vcn9as92Cy5b8h2Pia3hIcdo5zPOJia2W0pZKiarl6ibicibYmgpOCcLBPric9ia1X8ha0icUibZDc9PQVqsJ8odw%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">直播将建设过程归纳为四步：准备知识、生产知识、治理知识、用好知识。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">起点是明确业务场景：AI员工要接住哪项工作，做到什么程度，结果由谁检验。随后围绕岗位任务梳理数据、资料和业务规则，明确来源、口径与责任人。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">在知识准备环节，直播介绍了Dataphin的数据集能力，将文件存储系统与数据库关联起来，描述企业有哪些资料、资料在哪里，以及每个文件的相关信息。以合同PDF为例，文件存储提供原始地址，元数据表记录甲乙方、签约产品、项目名称、金额等信息，支持后续按业务场景进行分类、检索和管理。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">针对“为什么要提前提取，不能等Agent用到时再读”的问题，直播给出了三个理由：避免不同用户、不同任务反复解析同一份文件；结合业务术语、领域知识和提取规则保留有价值的信息；提前开展质量检查、人工校正，并关联原文位置。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">非结构化资料的处理，通过工作流组织起来。</span></span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">直播展示的工作流覆盖通用、文本、文档、图片、音频、视频、向量化七类近50个算子，可以通过可视化配置组合处理流程。直播里举了两个例子：一个是最常见的文档处理，另一个是汽车销售录音。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">比如合同解析工作流，一般包含以下步骤：解析Word、PDF文件，移除特殊字符，再通过大模型的多列输出提取所需信息。用户可以定义JSON，约束甲方、合同金额、签约产品名称、项目名称等输出字段。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">汽车销售录音采用另一套处理流程：先判断音频质量，对低质量音频进行增强；随后通过ASR提取文本，对客户隐私信息进行打码；最后根据业务要求，提取竞品信息或开展SOP质检。</span></span></p><p style="text-align: center;line-height: 1.75em;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.5328125" data-s="300,640" data-type="png" data-w="1280" style="width:100%;" type="block" data-backw="568" data-backh="303" data-imgfileid="100154705" src="https://wechat2rss.xlab.app/img-proxy/?k=a5a9db46&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FgiamgWvCHDYaZahgriczunkRPXltiaM3gd3nqQqE8XPk3m1XicAO8NzFHeV2Eu8VBbrNOdOocTv8x7Rru20LmiaLoqic1aWfN8ksZ2Qlcnar0s2bE%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">两个演示都围绕业务需要组织加工步骤：先明确希望从资料中获取什么，再配置对应的处理流程。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">知识加工还需要跟随业务节奏持续运行。直播介绍了三种工作流形态：</span></span></p><table style="width:573px;"><tbody><tr><td data-colwidth="118" width="216" valign="top" style="padding: 0px 7px;border-width: 1px;border-style: solid;border-color: rgb(214, 214, 214);"><p style="text-align: center;line-height: 1.75em;"><strong><span style="font-size: 14px;"><span leaf="">工作流形态</span></span></strong></p></td><td data-colwidth="174" width="216" valign="top" style="padding: 0px 7px;border-width: 1px;border-style: solid;border-color: rgb(214, 214, 214);"><p style="text-align: center;line-height: 1.75em;"><strong><span style="font-size: 14px;"><span leaf="">运行方式</span></span></strong></p></td><td data-colwidth="281" width="216" valign="top" style="padding: 0px 7px;border-width: 1px;border-style: solid;border-color: rgb(214, 214, 214);"><p style="text-align: center;line-height: 1.75em;"><strong><span style="font-size: 14px;"><span leaf="">应用举例</span></span></strong></p></td></tr><tr><td data-colwidth="118" width="216" valign="top" style="padding: 0px 7px;border-left: 1px solid rgb(214, 214, 214);border-right: 1px solid rgb(214, 214, 214);border-top: none;border-bottom: 1px solid rgb(214, 214, 214);"><p style="text-align: center;line-height: 1.75em;"><span style="font-size: 14px;"><span leaf="">离线工作流</span></span></p></td><td data-colwidth="174" width="216" valign="top" style="padding: 0px 7px;border-left: 1px solid rgb(214, 214, 214);border-right: 1px solid rgb(214, 214, 214);border-top: none;border-bottom: 1px solid rgb(214, 214, 214);"><p style="text-align: center;line-height: 1.75em;"><span style="font-size: 14px;"><span leaf="">定时批量运行</span></span></p></td><td data-colwidth="281" width="216" valign="top" style="padding: 0px 7px;border-left: 1px solid rgb(214, 214, 214);border-right: 1px solid rgb(214, 214, 214);border-top: none;border-bottom: 1px solid rgb(214, 214, 214);"><p style="text-align: center;line-height: 1.75em;"><span style="font-size: 14px;"><span leaf="">夜间处理销售录音，供主管第二天复盘</span></span></p></td></tr><tr><td data-colwidth="118" width="216" valign="top" style="padding: 0px 7px;border-left: 1px solid rgb(214, 214, 214);border-right: 1px solid rgb(214, 214, 214);border-top: none;border-bottom: 1px solid rgb(214, 214, 214);"><p style="text-align: center;line-height: 1.75em;"><span style="font-size: 14px;"><span leaf="">实时工作流</span></span></p></td><td data-colwidth="174" width="216" valign="top" style="padding: 0px 7px;border-left: 1px solid rgb(214, 214, 214);border-right: 1px solid rgb(214, 214, 214);border-top: none;border-bottom: 1px solid rgb(214, 214, 214);"><p style="text-align: center;line-height: 1.75em;"><span style="font-size: 14px;"><span leaf="">对接Kafka，由新数据触发</span></span></p></td><td data-colwidth="281" width="216" valign="top" style="padding: 0px 7px;border-left: 1px solid rgb(214, 214, 214);border-right: 1px solid rgb(214, 214, 214);border-top: none;border-bottom: 1px solid rgb(214, 214, 214);"><p style="text-align: center;line-height: 1.75em;"><span style="font-size: 14px;"><span leaf="">新录音产生后，自动分析客户需求、顾虑和竞品信息</span></span></p></td></tr><tr><td data-colwidth="118" width="216" valign="top" style="padding: 0px 7px;border-left: 1px solid rgb(214, 214, 214);border-right: 1px solid rgb(214, 214, 214);border-top: none;border-bottom: 1px solid rgb(214, 214, 214);"><p style="text-align: center;line-height: 1.75em;"><span style="font-size: 14px;"><span leaf="">在线工作流</span></span></p></td><td data-colwidth="174" width="216" valign="top" style="padding: 0px 7px;border-left: 1px solid rgb(214, 214, 214);border-right: 1px solid rgb(214, 214, 214);border-top: none;border-bottom: 1px solid rgb(214, 214, 214);"><p style="text-align: center;line-height: 1.75em;"><span style="font-size: 14px;"><span leaf="">通过API请求启动并返回结果</span></span></p></td><td data-colwidth="281" width="216" valign="top" style="padding: 0px 7px;border-left: 1px solid rgb(214, 214, 214);border-right: 1px solid rgb(214, 214, 214);border-top: none;border-bottom: 1px solid rgb(214, 214, 214);"><p style="text-align: center;line-height: 1.75em;"><span style="font-size: 14px;"><span leaf="">销售上传录音后，获取分析结果，为后续跟进做准备</span></span></p></td></tr></tbody></table><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">直播同时介绍，工作流可以使用Dataphin已有的发布、运维、告警等能力，将知识加工纳入持续运行的工程流程。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">内容提取之后，还要把业务对象之间的关系组织清楚。</span></span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">汽车销售场景中，客户需求在录音里，车型、配置在产品资料里。Agent要使用这些信息，需要了解它们之间的关联。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">直播通过汽车销售知识图谱，展示了汽车品牌、客户、购车需求、销售会话等实体及其关系。在“汽车品牌”实体中，则定义了品牌编码、品牌名称、品牌别名和简介等属性。</span></span></p><p style="text-align: center;line-height: 1.75em;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.518359375" data-s="300,640" data-type="png" data-w="2560" style="width: 100%;" type="block" data-backw="568" data-backh="294" data-imgfileid="100154706" src="https://wechat2rss.xlab.app/img-proxy/?k=1e192016&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYb3JxINcyibhsB2bowwFdgpxgZ02vI3icc2jsCaiasJfVzdl1s6coBZ578BUjibVRSw8T7ysnW1KgULfAnHm0j1UTpteH0wqjyVIvc%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">围绕图谱模型，Dataphin支持可视化的实体与关系管理、属性与约束配置，以及版本管理。直播还介绍，演示中的图谱模型通过大模型调用Dataphin提供的SKILL创建，Dataphin也提供了原生CLI接口。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">图谱数据的获取有两条路径：通过工作流中的“知识图谱解析”算子，从非结构化资料中提取业务对象和关系；通过数据集成中的“知识图谱写入”组件，将结构化业务数据写入图谱。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">针对同名、简称等歧义，直播展示了实体业务识别规则和人工审核页面：满足条件的数据自动写入，需要确认的结果保留为候选项，由业务人员审核。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">这也明确了AI与业务专家的分工：AI参与重复性的提取和匹配，业务专家处理需要判断的对象匹配与歧义问题。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">质量、血缘和权限，需要贯穿知识建设与调用。</span></span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">AI参与知识加工之后，如何保障处理结果可信可用？</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">直播从三个方面介绍了治理工作：</span></span></p><p data-role="list"><ul style="list-style-type: disc;margin:0px;padding:0 0 0 30px;list-style-position:outside;" class="list-paddingleft-1"><li><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">质量治理：</span>检查内容是否准确、完整、前后一致，发现链路中的异常问题。</span></span></p></li><li><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">血缘治理：</span>记录知识来源和加工过程，资料变化时查清影响，答案出现问题时追溯原因。</span></span></p></li><li><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">安全合规：</span>明确知识调用范围，做好敏感信息识别、授权和必要的脱敏。</span></span></p></li></ul></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">知识需要持续更新和维护，这些治理工作也需要与生产、服务衔接起来。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">加工好的知识，通过服务接口进入Agent的工作。</span></span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">直播介绍了两类使用方式。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">查找资料，可以使用数据集语义检索。用户在Dataphin数据服务中创建API，通过query参数传入查询信息，通过top_k参数限制返回结果数量。调用时，系统对输入问题进行向量化处理，执行语义相似度查询。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">查询关系，可以使用知识图谱查询。用户输入实体信息，查询相关实体及其关系。相关功能开放了OpenAPI和CLI，供Agent开发时集成使用。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">调用环节还需要配置身份。直播介绍了统一调用身份，以及传入Agent实际用户信息两种方式；后者按照用户权限返回数据，约束知识的使用范围。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">在瓴羊企业级 Agent 平台 AgentOne 中，可以将Dataphin创建的数据集或图谱API直接引用为外部知识库，减少文档、数据表等内容的重复导入和配置。企业自研或其他厂商的Agent，也可以调用Dataphin提供的知识服务。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">直播还介绍了本体逆向建模：从Dataphin中已经搭建的数据模型和主数据库表中提取语义关联，帮助企业更快地构建语义模型，减少从零开始梳理的工作。</span></span></span></p><p style="text-align: center;line-height: 1.75em;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.50546875" data-s="300,640" data-type="png" data-w="1280" style="width:100%;" type="block" data-backw="568" data-backh="287" data-imgfileid="100154707" src="https://wechat2rss.xlab.app/img-proxy/?k=7a74d626&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYa1hkeWq1vWrcGC0Et1YIBRFjvV2eDs6CDibzrBZhpheBdX1Sa8ib1Uhibmqucic0LtiaZibWYDvhEjPaevIiczo8KictrbMrrrQfXCbyo%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">回到增购方案场景，Agent可以查询客户、合同、项目、产品等对象关系，获取已购功能、回访记录等结构化事实，再结合会议纪要、产品文档和案例库，组织方案内容。直播最后展示了AgentOne中AI销售生成的解决方案PPT，以及核对方案资料来源的方式。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">落地路径，仍然要回到具体场景和预先确定的目标。</span></span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">直播结尾提醒，企业推进Agent容易走的一条弯路，是先扩大平台建设，再寻找业务应用，导致项目周期长、缺少真实调用验证，难以看到业务价值。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">因此，直播建议选择一个痛点清晰、数据可得、价值可量化、风险可控的场景做MVP，跑通接入、治理、知识生产和服务调用，达到预先设定的明确指标，再利用沉淀的模板逐步复制。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">在这一过程中，数据集、加工工作流、业务关系、治理规则和服务接口，也能成为后续场景继续复用的积累。</span></span></p><p style="text-align: center;line-height: 1.75em;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.50390625" data-s="300,640" data-type="png" data-w="1280" style="width: 100%;" type="block" data-backw="568" data-backh="286" data-imgfileid="100154708" src="https://wechat2rss.xlab.app/img-proxy/?k=d0e42765&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYZFQKHyg5icYKicx8CyW47wGKQYB3QbXLfFLeMwGz1OvBGFuLSqicnQLlN2QOlM8h4KbIPGhkpwn3k3lYRY2YEbK3ZqiaUiaWaP69ZU%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="text-align: center;line-height: 1.75em;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.5959595959595959" data-s="300,640" data-type="png" data-w="693" style="width:100%;" data-croporisrc="https://mmbiz.qpic.cn/sz_mmbiz_png/giamgWvCHDYblpibclqibyBicJCqfM4hIckaYZkGmA4Ceo3xrLxicgQWv9kKH74QslibMFaUJZIe7v552WO7Sjok2Tysa9sx9Attu1n0mCibjdxyl8/0?wx_fmt=png&amp;from=appmsg" data-cropselx1="0" data-cropselx2="568" data-cropsely1="0" data-cropsely2="306" data-backw="568" data-backh="339" data-imgfileid="100154716" src="https://wechat2rss.xlab.app/img-proxy/?k=bbe72b29&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYblpibclqibyBicJCqfM4hIckaYZkGmA4Ceo3xrLxicgQWv9kKH74QslibMFaUJZIe7v552WO7Sjok2Tysa9sx9Attu1n0mCibjdxyl8%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="text-align: center;line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span style="font-family: Calibri;font-size: 10.5pt;" data-pm-slice="0 0 []"><span leaf=""><span textstyle="" style="font-size: 15px;font-weight: bold;">扫码添加企微，领取资料↓</span></span></span></span></p><p style="text-align: center;line-height: 1.75em;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="1" data-s="300,640" data-type="png" data-w="396" style="width:219px;height:219px;" type="block" data-imgfileid="100154711" src="https://wechat2rss.xlab.app/img-proxy/?k=c26ff686&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYbB1dlHPwHt3QPFgu9o96WPswSPjhoGvM7W5HdNGLyzBLgdUEE9sYfAY0QSzD9en4dd9GOufFxGSnwawYMb1zlawHvpQXHicr5U%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p></div></div></div></div></div></div></div><p style="display: none;"><mp-style-type data-value="3"></mp-style-type></p>



<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=e7ca52c0&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzkzMjYzNjkzNw%3D%3D%26mid%3D2247638375%26idx%3D2%26sn%3D3cfedc6ea6461248519029e8f3d1b7a9">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Mon, 02 Nov 2026 07:15:00 +0800</pubDate>
    </item>
    <item>
      <title>黑客被运维整崩溃？！7分钟攻破国家级云平台，运维当了7小时重启仙人，黑客直接贴脸开大</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzkzMjYzNjkzNw==&amp;mid=2247638343&amp;idx=1&amp;sn=dc46bcd4b3f7799b11ec55a08b3a7066</link>
      <description>云服务商运维团队却始终没有发现，最后黑客索性直接登上管理控制台，反向教学……</description>
      <content:encoded><![CDATA[<p>原创 <span>整理自</span> <span>2026-10-30 07:15</span> <span style="display: inline-block;">广东</span></p>






  
  <p><img src="https://wechat2rss.xlab.app/img-proxy/?k=233a2e8b&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FgiamgWvCHDYbibOT4vWd18JibXBbia4UPQXGbkJe9XWbvItsajqGp5MlmzLIBM8C2uP9GjsUAbG5PfFO9xoORhXiaPMfPFRXaXPBJ1FHasglfwFw%2F0%3Fwx_fmt%3Djpeg"/></p>
  <p>云服务商运维团队却始终没有发现，最后黑客索性直接登上管理控制台，反向教学……</p>
  <p class="mp_profile_iframe_wrp" style="margin-bottom: 0px;" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-service_type="1" data-verify_status="2"></mp-common-profile></p><div data-role="outer" label="edit by 135editor" data-pm-slice="0 0 []"><div data-role="paragraph"><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;"><span leaf="">10月7日凌晨3点40分，日本软银集团旗下IDC Frontier运营的IDCF云平台东日本第1区域遭受勒索攻击，数百台企业虚拟机毫无征兆集体宕机。</span></span></p><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img" data-aistatus="1" data-backh="73" data-backw="226" data-imgfileid="100154494" data-ratio="0.3230088495575221" data-s="300,640" type="block" data-type="png" data-w="226" style="width:249px;height:80px;" src="https://wechat2rss.xlab.app/img-proxy/?k=a2d7acf8&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYaDwgqzyw7oJ3f9yiaEgwRV6ghibqPvnzshEBk4x3N6pw4Gm3gVpicrhPm0icb9u4xjwdTZn0OqYbsNaSsicFlicpttVjt9zCTAmCiacM%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">一场勒索软件攻击，在短短数分钟内席卷了整个可用区。<span textstyle="" style="font-weight: bold;">黑客在225个存储区根目录放下勒索通知，足足等待7个小时，云服务商运维团队却始终没有发现。</span>最后黑客索性直接登上管理控制台，用黑底红字的主页直接对运维人员贴脸开大。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">一、7分钟突破，7小时无效排查</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这场事故最令人意外的地方，是攻防双方处置节奏的强烈反差。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">客户的截图显示，黑客自称仅用时7分钟就攻陷了IDCF Cloud东日本一区的基础设施。</span></span></p><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.7066569129480614" data-s="300,640" data-type="png" data-w="1367" style="width:100%;" type="block" data-backw="578" data-backh="408" data-imgfileid="100154490" src="https://wechat2rss.xlab.app/img-proxy/?k=6b12be4d&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FgiamgWvCHDYZm5egtphPgqadrrS8SEkGypF4Q8LdDafibKEDyXJZy0jbufK8nbibfABPZ4GMKssyOT9iaicVTCxqombIgxtveW5Eu2yETCXSb9tA%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">按照黑客披露的时间线，<span textstyle="" style="font-weight: bold;">日本时间凌晨3点</span>已经完成入侵部署，在225个存储区的根目录下生成 RECOVER‑INFO.txt 勒索通知文件。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">3点40分</span>，底层存储加密完成，大量租户虚拟机批量宕机，客户业务陆续中断。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">4点25分</span>，运维团队才察觉到系统出现异常，但没有往安全入侵的方向排查，只是机械执行常规故障处置：一遍遍重启已经损坏的虚拟机，反复修改控制台账号密码，始终没有登录宿主机查看存储目录，自然没能发现根目录下的勒索信。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">8点34分之前</span>，第75号工单就已经报告“虚拟机无法启动”。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">故障信号其实早已出现，但这些告警没有触发安全应急响应，只是被当作普通故障处理，淹没在模板回复和批量关闭的工单中。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">黑客在7分钟内完成了对底层存储的加密，而运维却在接下来的7小时里，困在“重启虚拟机、修改密码”的循环中。</span></span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">二、黑客篡改控制台，对运维贴脸开大</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">在漫长等待之后，黑客迟迟等不到服务商开启谈判，<span textstyle="" style="font-weight: bold;">索性直接入侵篡改云管理控制台。控制台页面被换成黑色背景，红色加粗大标题写着：</span></span></span></p><div data-tools="135编辑器" data-id="5" data-color="rgb(198, 198, 199)" data-custom="rgb(198, 198, 199)" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;border: 0px none;z-index: 0;max-width: 100%;font-size: 16px;widows: 1;visibility: visible;"><div style="max-inline-size: 100%;margin: 2px auto;padding: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;max-width: 100%;font-size: 14px;line-height: 25px;border-width: 2px;border-style: dashed;border-color: #c6c6c7;visibility: visible;"><p style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;clear: both;min-height: 1em;cursor: text;max-width: 100%;vertical-align: inherit;line-height: 1.5em;visibility: visible;"><span style="caret-color: red;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">IDCF CLOUD INFRASTRUCTURE SEIZED</span></span></span></p><p style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;clear: both;min-height: 1em;cursor: text;max-width: 100%;vertical-align: inherit;line-height: 1.5em;visibility: visible;"><span style="caret-color: red;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">（IDCF 云基础设施已被我们接管）</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 14px;font-weight: 400;letter-spacing: normal;font-style: normal;color: #333333;text-decoration: none solid #333333;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">核心标语：YOUR CLOUD IS OURS.</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 14px;font-weight: 400;letter-spacing: normal;font-style: normal;color: #333333;text-decoration: none solid #333333;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">（你们的云，现在归我们了）</span></span></span></p></div></div><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.2123015873015873" data-s="300,640" data-type="png" data-w="1008" style="width:578px;height:123px;" type="block" data-croporisrc="https://mmbiz.qpic.cn/mmbiz_png/giamgWvCHDYZm5egtphPgqadrrS8SEkGypF4Q8LdDafibKEDyXJZy0jbufK8nbibfABPZ4GMKssyOT9iaicVTCxqombIgxtveW5Eu2yETCXSb9tA/0?wx_fmt=png&amp;from=appmsg" data-cropx1="359.7368421052632" data-cropx2="1367" data-cropy1="53.01385041551247" data-cropy2="266.9626038781164" data-backw="578" data-backh="408" data-imgfileid="100154490" src="https://wechat2rss.xlab.app/img-proxy/?k=7e413dde&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FgiamgWvCHDYaE9I1HA17HzWNFib1ro5wica0yyaicaIjXZ7OtiaDicmGcA2Zfz3icxW5O46J4kZD5tP4aySgayibUJrMykDxhibU1px3ZkDTnE8WsRsw%2F640%3Fwx_fmt%3Djpeg"/></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">黑客在篡改后的管理页面留下大段嘲讽文字，甚至附上了读取勒索信的明确操作指引：</span></span></p><div data-tools="135编辑器" data-id="5" data-color="rgb(198, 198, 199)" data-custom="rgb(198, 198, 199)" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;border: 0px none;z-index: 0;max-width: 100%;font-size: 16px;widows: 1;visibility: visible;"><div style="max-inline-size: 100%;margin: 2px auto;padding: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;max-width: 100%;font-size: 14px;line-height: 25px;border-width: 2px;border-style: dashed;border-color: #c6c6c7;visibility: visible;"><p style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;clear: both;min-height: 1em;cursor: text;max-width: 100%;vertical-align: inherit;line-height: 1.5em;visibility: visible;"><span style="caret-color: red;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">任选一台Joule集群ESXi宿主机，打开 SSH 或者 DCUI shell（你们今早刚改了密码，你们自己知道），查看 RECOVER‑INFO.txt。</span></span></span></p></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">攻击者在页面留言中复盘整个攻击过程，言语间满是戏谑：</span></span></p><div data-tools="135编辑器" data-id="5" data-color="rgb(198, 198, 199)" data-custom="rgb(198, 198, 199)" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;border: 0px none;z-index: 0;max-width: 100%;font-size: 16px;widows: 1;visibility: visible;"><div style="max-inline-size: 100%;margin: 2px auto;padding: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;max-width: 100%;font-size: 14px;line-height: 25px;border-width: 2px;border-style: dashed;border-color: #c6c6c7;visibility: visible;"><p style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;clear: both;min-height: 1em;cursor: text;max-width: 100%;vertical-align: inherit;line-height: 1.5em;visibility: visible;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">“2026.10.7，只用 7 分钟，我们就把东日本一区全部数据加密，拿下这套国家级云平台。但接下来整整 7 小时，你们运维居然找不到我们留下的勒索通知。”</span></span></p></div></div><div data-tools="135编辑器" data-id="5" data-color="rgb(198, 198, 199)" data-custom="rgb(198, 198, 199)" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;border: 0px none;z-index: 0;max-width: 100%;font-size: 16px;widows: 1;visibility: visible;"><div style="max-inline-size: 100%;margin: 2px auto;padding: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;max-width: 100%;font-size: 14px;line-height: 25px;border-width: 2px;border-style: dashed;border-color: #c6c6c7;visibility: visible;"><p style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;clear: both;min-height: 1em;cursor: text;max-width: 100%;vertical-align: inherit;line-height: 1.5em;visibility: visible;"><span style="caret-color: red;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">“我们本来不打算这么高调公开。没想到你们处置能力这么差。你们在 04:25 才察觉到异常，之后只会反复重置控制台密码。”</span></span></span></p></div></div><div data-tools="135编辑器" data-id="5" data-color="rgb(198, 198, 199)" data-custom="rgb(198, 198, 199)" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;border: 0px none;z-index: 0;max-width: 100%;font-size: 16px;widows: 1;visibility: visible;"><div style="max-inline-size: 100%;margin: 2px auto;padding: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;max-width: 100%;font-size: 14px;line-height: 25px;border-width: 2px;border-style: dashed;border-color: #c6c6c7;visibility: visible;"><p style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;clear: both;min-height: 1em;cursor: text;max-width: 100%;vertical-align: inherit;line-height: 1.5em;visibility: visible;"><span style="caret-color: red;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">“整整 7 小时，你们一直在 vCenter 里反复尝试重启已经死掉的虚拟机，这些机器根本不可能再启动。你们却一直没发现我们放在宿主机上的勒索文件。”</span></span></span></p></div></div><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.5314814814814814" data-s="300,640" data-type="png" data-w="1080" style="width:100%;" type="block" data-backw="578" data-backh="307" data-imgfileid="100154491" src="https://wechat2rss.xlab.app/img-proxy/?k=40332025&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FgiamgWvCHDYZy0g4icE7TDG1ZfI6z0QZMiau3VHr390TJg9BAgicfQibNvDd2aczC6JkLyZfIWr7zvfv9aDKarliarQGAYicFcYUMbA0IfxT9BGILc%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">黑客留下的勒索信并没有藏在什么加密深处，就放在每一个存储区最外层根目录。攻击者在留言里充满嘲讽：投放225份，就是为了确保你们不可能错过，但你们还是错过了。</span></span></p><div data-tools="135编辑器" data-id="5" data-color="rgb(198, 198, 199)" data-custom="rgb(198, 198, 199)" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;border: 0px none;z-index: 0;max-width: 100%;font-size: 16px;widows: 1;visibility: visible;"><div style="max-inline-size: 100%;margin: 2px auto;padding: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;max-width: 100%;font-size: 14px;line-height: 25px;border-width: 2px;border-style: dashed;border-color: #c6c6c7;visibility: visible;"><p style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;clear: both;min-height: 1em;cursor: text;max-width: 100%;vertical-align: inherit;line-height: 1.5em;visibility: visible;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">“你们一直在 vCenter 里给已经死掉的虚拟机反复按电源，强制重启那些永远不会再启动的机器，却看不见我们留在虚拟化层的消息。”</span></span></p></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">检测到入侵后，IDC Frontier隔离并关停东日本第1区域内受影响的系统，同时识别、封锁攻击入口，并对其余区域开展安全排查。除东日本1区外，其他区域的管理控制台暂停区域外访问，待安全核验完成后再恢复。<span textstyle="" style="font-weight: bold;">但底层存储已被加密、大量快照已被清除，平台备份体系的损失已经无法挽回。</span></span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">三、495家政企机构遇灾，平台备份体系已被破坏</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">本次勒索事件影响范围锁定在IDCF Cloud东日本一区，覆盖Tesla、Henry、Pascal、Joule共4个可用区。据IDC Frontier披露，总计495家政企机构的业务受到冲击，受影响主体包含地方政府、公共机构与各类企业。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">10月14日，IDC Frontier发布第五次公告，称本次攻击未发现客户数据被窃取外泄的证据，黑客行为以加密、销毁平台快照为主，不存在数据泄露。</span></span></p><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.3474065138721351" data-s="300,640" data-type="png" data-w="829" style="width:100%;" type="block" data-backw="578" data-backh="201" data-imgfileid="100154492" src="https://wechat2rss.xlab.app/img-proxy/?k=724e45b6&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FgiamgWvCHDYY9lAv3c5R2xslrd5NECBFcSDAHL3b4EKC1pcfrcqd9ibToz6gQRCuv2RgYtBicn16YHg7c9tjloibXrNTqFJrJdNkMiaibhDGAUaLQ%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">基础设施层面的破坏规模来自攻击者的单方陈述：攻击者声称<span textstyle="" style="font-weight: bold;">获取该区域 239 台虚拟化宿主机（ESXi）权限，对225个存储区（总计3.6PB主数据）实施加密，锁定16000块虚拟机磁盘，并清除554153份快照，连同41.5PB备份数据一并销毁</span>，平台原生快照备份体系近乎失效。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">事故处置阶段，IDC Frontier表示：该区域平台托管的数据基本无法解密恢复。客户重建业务，只能依靠部署在云平台外部、独立保管的离线备份，不少机构因缺少异地备份，业务陷入长时间停滞。目前官方仍在持续追查入侵入口与攻击路径。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">四、结语</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">回看IDCF Cloud这起事故，最扎心的不是黑客黑底红字的嘲讽，而是运维困在vCenter里反复重启虚拟机的那7个小时。多可用区不等于天然安全，再多上层防护也挡不住控制平面失守。作为运维，要守住的核心就三件事：<span textstyle="" style="font-weight: bold;">第一时间发现入侵、守住隔离的离线备份、具备脱离管理控制台的独立止损能力。</span>一旦这几条防线失效，再完善的云架构也无力回天。</span></span></p><div data-tools="135编辑器" data-id="85988" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="max-width:100% !important;margin:0 auto;padding: 0;border:none;display:inline-block;width:100%;box-sizing:border-box;" data-width="100%"><p style="margin:0;padding:0;font-size:18px;letter-spacing:-2px;display: inline-block;box-sizing:border-box;"><span style="font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span style="color: #138bde;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: #138bde;opacity: 0.7;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: #138bde;opacity: 0.5;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: #138bde;opacity: 0.3;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span></strong></span></p><div style="margin-left: 10px;color: #138bde;display: inline-block;"><p data-brushtype="text" style="font-size:16px;color:inherit;margin-top:0;margin-bottom:0;"><span style="font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">参考链接</span></strong></span></p></div></div></div><p data-role="list"><ul style="list-style-type: disc;margin:0px;padding:0 0 0 30px;list-style-position:outside;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="letter-spacing: normal;font-size: 12px;color: #7f7f7f;"><span leaf=""><a href="https://www.idcf.jp/news/topics/20261007002" target="_blank">https://www.idcf.jp/news/topics/20261007002</a> </span></span></p></li></ul><ul style="list-style-type: disc;margin:0px;padding:0 0 0 30px;list-style-position:outside;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="letter-spacing: normal;font-size: 12px;color: #7f7f7f;"><span leaf=""><a href="https://www.bleepingcomputer.com/news/security/ransomware-attack-disrupts-japans-idcf-cloud-used-by-govt-clients/" target="_blank">https://www.bleepingcomputer.com/news/security/ransomware-attack-disrupts-japans-idcf-cloud-used-by-govt-clients/</a></span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 12px;color: #7f7f7f;"><span leaf=""><a href="https://www.anquanke.com/post/id/316231" target="_blank">https://www.anquanke.com/post/id/316231</a></span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 12px;color: #7f7f7f;"><span leaf=""><a href="https://www.idcf.jp/news/topics/20261014001" target="_blank">https://www.idcf.jp/news/topics/20261014001</a></span></span></p></li></ul></p></div><div data-role="paragraph" style="font-family:sans-serif;"><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">整理丨dbaplus社群</span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span style="color: #888888;font-size: 14px;letter-spacing: 0.5px;text-align: justify;caret-color: #ff0000;text-decoration-thickness: initial;display: inline !important;font-family:Helvetica, Arial, sans-serif;"><span leaf="">*仅为提供参考和学习交流，不代表dbaplus社群立场！</span></span><span leaf="">dbaplus社群欢迎广大技术人员投稿，投稿邮箱：</span></span><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">editor@dbaplus.cn</span></span></p><p class="mp_profile_iframe_wrp" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-service_type="1" data-verify_status="2"></mp-common-profile></p><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.07777777777777778" data-s="300,640" data-w="1080" type="block" data-imgfileid="100130225" src="https://wechat2rss.xlab.app/img-proxy/?k=f32823a4&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FufWcjcomw8Zf2jiaBBH3vdgfP4A2rem5YEAHYH074dc4GibhojA5B3lLZrXLDRciaVnficveaHcAUCiaIPoDsTkAduA%2F640%3Fwx_fmt%3Dpng"/></p></div></div><p style="display: none;"><mp-style-type data-value="3"></mp-style-type></p>



<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=42b202d4&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzkzMjYzNjkzNw%3D%3D%26mid%3D2247638343%26idx%3D1%26sn%3Ddc46bcd4b3f7799b11ec55a08b3a7066">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Fri, 30 Oct 2026 07:15:00 +0800</pubDate>
    </item>
    <item>
      <title>直播预告丨Data for AI：面向企业级Agent的知识建设</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzkzMjYzNjkzNw==&amp;mid=2247638321&amp;idx=1&amp;sn=da713c944587b33d807dad5154c5d6c1</link>
      <description>Agent上线了效率没上来？知识建设从哪入手才能看到业务价值？</description>
      <content:encoded><![CDATA[<p><span>dbaplus社群</span> <span>2026-10-29 07:15</span> <span style="display: inline-block;">广东</span></p>






  
  <p><img src="https://wechat2rss.xlab.app/img-proxy/?k=b6f3edcf&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYYLAcn1lFwdrKMuudZSFX6UphqwUZ6IY9lgmtiaibiaOPx1tibewXnodlOIuD2nOia83g9mGlibS76RBg6EJ02ASwiaqpNrKNxSk1tmgo%2F0%3Fwx_fmt%3Djpeg"/></p>
  <p>Agent上线了效率没上来？知识建设从哪入手才能看到业务价值？</p>
  <div data-role="outer" label="edit by 135editor" data-pm-slice="0 0 []"><div data-role="paragraph"><p class="channels_iframe_wrp" nodeleaf=""><mp-common-videosnap class="js_uneditable custom_select_card channels_live_iframe" data-pluginname="mpvideosnap" data-headimgurl="https://wx.qlogo.cn/finderhead/yCWgT0gnfDFdppkCgia7zCWWEO0Wwvg4Evld2AKh8Fg4/0" data-username="v2_060000231003b20faec8c6ea8a19cad0c906ee36b077561ac77b50bace8983cb38b3293ad1bf@finder" data-nickname="dbaplus社群" data-desc="将在10月29日 14:30 直播" data-type="live" data-intro="Data for AI" data-noticeid="finderlivenotice-v2_060000231003b20faec8c6ea8a19cad0c906ee36b077561ac77b50bace8983cb38b3293ad1bf@finder-1793158189024964-1796624859" data-status="0"></mp-common-videosnap></p><p><span style="color: #3e3e3e;font-size: 15px;caret-color: red;"><span leaf="">企业已经搭建了不少Agent，为什么组织效率仍未明显提升？喂了大量数据、文档和业务经验，为什么AI依然“不懂业务”？</span></span></p><p><span data-pm-slice="0 0 []" style="caret-color: red;font-size: 15px;color: rgb(19, 139, 237);letter-spacing: 0.544px;float: none;font-family: system-ui, -apple-system, BlinkMacSystemFont, Arial, sans-serif;display: inline !important;"><strong><span leaf="">10月29日（周四）14:30，阿里云智能集团瓴羊产品经理史朝阳、产品运营宁丽明将带来《Data for AI：面向企业级Agent的知识建设》主题分享。</span></strong></span></p><p><span style="caret-color: red;color: #3e3e3e;font-size: 15px;"><span leaf="">两位嘉宾将围绕“准备知识、生产知识、治理知识、用好知识”四个环节，结合合同解析、销售录音分析、方案生成等演示，讲清如何将企业的数据、资料和业务经验，建设成Agent可理解、可调用的知识，并分享如何从具体场景起步，逐步沉淀知识、复用经验的实践方法。让Agent真正懂业务，成为企业生产力。</span></span></p><p><span style="caret-color: red;color: #3e3e3e;font-size: 15px;"><span leaf="">此外，直播间还有白皮书及POC免费领取福利，欢迎预约观看。</span></span></p></div><div data-tools="135编辑器" data-id="39" style="border: 0px none;box-sizing:border-box;" data-color="#138bde" data-custom="#138bde"><div style="max-width: 100%;margin: 0.8em 0px 0.5em;overflow: hidden;text-align: left;"><p data-brushtype="text" placeholder="请输入标题" style="height: 36px;display: inline-block;color: #ffffff;font-size: 16px;padding: 0px 10px;line-height: 36px;vertical-align: top;background-color: #138bde;box-sizing: border-box !important;"><span style="font-family: Helvetica, Arial, sans-serif;"><strong><strong style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;color: rgb(255, 255, 255);font-size: 16px;letter-spacing: 0.544px;text-align: left;background-color: rgb(19, 139, 222);text-decoration-thickness: initial;visibility: visible;font-family: Helvetica, Arial, sans-serif;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;visibility: visible;"><span leaf="">活动信息</span></span></strong></strong></span></p></div></div><div data-role="list"><p data-role="list"><ul style="list-style-type: disc;margin:0px;padding:0 0 0 30px;list-style-position:outside;" class="list-paddingleft-1"><li><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;clear: both;min-height: 1em;line-height: 1.75em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;text-align: left;"><strong style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;font-size: 15px;color: rgb(62, 62, 62);visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);margin: 0px;padding: 0px;outline: 0px;max-width: 100%;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="">主题：</span></span></span></span></strong><span style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;font-size: 15px;color: rgb(62, 62, 62);visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);margin: 0px;padding: 0px;outline: 0px;max-width: 100%;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="">Data for AI：面向企业级Agent的知识建设</span></span></span></span></p></li><li><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;clear: both;min-height: 1em;line-height: 1.75em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;text-align: left;"><strong style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;font-size: 15px;color: rgb(62, 62, 62);visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);margin: 0px;padding: 0px;outline: 0px;max-width: 100%;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="">讲师：</span></span></span></span></strong><span style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;font-size: 15px;color: rgb(62, 62, 62);visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);margin: 0px;padding: 0px;outline: 0px;max-width: 100%;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="">阿里云智能集团瓴羊 产品经理 史朝阳</span></span></span></span></p><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;clear: both;min-height: 1em;line-height: 1.75em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;text-align: left;"><span style="background-color: transparent;color: rgb(62, 62, 62);font-size: 15px;letter-spacing: 0.034em;"><span leaf="">         阿里云智能集团瓴羊 产品运营 宁丽明</span></span></p></li></ul></p><p data-role="list"><ul style="list-style-type: disc;margin:0px;padding:0 0 0 30px;list-style-position:outside;" class="list-paddingleft-1"><li><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;clear: both;min-height: 1em;line-height: 1.75em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;text-align: left;"><strong style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;font-size: 15px;color: rgb(62, 62, 62);visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);margin: 0px;padding: 0px;outline: 0px;max-width: 100%;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="">时间：</span></span></span></span></strong><span style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;font-size: 15px;color: rgb(62, 62, 62);visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);margin: 0px;padding: 0px;outline: 0px;max-width: 100%;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="">10月29日（周四）14:30</span></span></span></span></p></li><li><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;clear: both;min-height: 1em;line-height: 1.75em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;text-align: left;"><strong style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;font-size: 15px;color: rgb(62, 62, 62);visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);margin: 0px;padding: 0px;outline: 0px;max-width: 100%;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="">地点：</span></span></span></span></strong><span style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;font-size: 15px;color: rgb(62, 62, 62);visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);margin: 0px;padding: 0px;outline: 0px;max-width: 100%;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="">dbaplus视频号</span></span></span></span></p></li></ul></p></div><div data-tools="135编辑器" data-id="39" style="border: 0px none;box-sizing:border-box;" data-color="#138bde" data-custom="#138bde"><div style="max-width: 100%;margin: 0.8em 0px 0.5em;overflow: hidden;text-align: left;"><p data-brushtype="text" placeholder="请输入标题" style="height: 36px;display: inline-block;color: #ffffff;font-size: 16px;padding: 0px 10px;line-height: 36px;vertical-align: top;background-color: #138bde;box-sizing: border-box !important;"><span style="font-family: Helvetica, Arial, sans-serif;"><strong><strong style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;color: rgb(255, 255, 255);font-size: 16px;letter-spacing: 0.544px;text-align: left;background-color: rgb(19, 139, 222);text-decoration-thickness: initial;visibility: visible;font-family: Helvetica, Arial, sans-serif;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;visibility: visible;"><span leaf="">直播地址</span></span></strong></strong></span></p></div></div><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img" data-aistatus="1" data-imgfileid="100154624" data-ratio="2.8333333333333335" data-s="300,640" type="block" data-type="jpeg" data-w="1200" src="https://wechat2rss.xlab.app/img-proxy/?k=aed5597c&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FgiamgWvCHDYbHhSTTknibqtTXKxtlune5HMe0swVTiaRkH3VkYWsibZK4MxhNTzOr691ucQsoyhppzUoW4aic1xW7V0iaIibbLzXSUWwf45vwqQap0%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></p><div data-tools="135编辑器" data-id="85988" data-color="#138bde" data-custom="#138bde" style=""><div style="margin: 0px auto;padding: 0px;border: none;display: inline-block;width: 100%;max-width: 100% !important;box-sizing:border-box;" data-width="100%"><p style="margin: 0px;padding: 0px;font-size: 18px;letter-spacing: -2px;display: inline-block;box-sizing: border-box;font-family:sans-serif;"><span style="font-family: Helvetica, Arial, sans-serif;"><strong><span style="color: rgb(19, 139, 222);font-family: Helvetica, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: rgb(19, 139, 222);opacity: 0.7;font-family: Helvetica, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: rgb(19, 139, 222);opacity: 0.5;font-family: Helvetica, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: rgb(19, 139, 222);opacity: 0.3;font-family: Helvetica, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span></strong></span></p><div style="margin-left: 10px;color: #138bde;display: inline-block;"><p data-brushtype="text" style="font-size: 16px;color: inherit;margin-top: 0px;margin-bottom: 0px;"><span style="font-family: Helvetica, Arial, sans-serif;"><strong><span leaf="">更多直播干货</span></strong></span></p></div></div></div><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="1" data-s="300,640" data-type="jpeg" data-w="800" style="width:209px;height:209px;vertical-align:baseline;box-sizing:border-box;" type="block" data-backw="578" data-backh="578" data-imgfileid="100149038" src="https://wechat2rss.xlab.app/img-proxy/?k=4f850d42&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FvCTfE5pGMr86eayCeS50wom7heXGgLnRuWob7aWQle6hbMFicJyJZu9DahKYCA8NKMPuzhdb2oqlpnUYOicEUSkQ%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></p><p style="text-align:center;"><strong data-pm-slice="0 0 []" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgba(0, 0, 0, 0.9);font-size: 17px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align: center;text-indent: 0px;text-transform: none;white-space: normal;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: #ffffff;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;letter-spacing: 0.578px;font-family:mp-quote, system-ui, -apple-system, BlinkMacSystemFont, Arial, sans-serif;"><span data-pm-slice="1 1 [&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;paragraph&#34;,&#34;class&#34;:&#34;_135editor&#34;,&#34;style&#34;:&#34;font-family:sans-serif;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;},&#34;para&#34;,{&#34;tagName&#34;:&#34;p&#34;,&#34;attributes&#34;:{&#34;style&#34;:&#34;margin-bottom: 0px; margin-top: 0px; text-align: center;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;},&#34;node&#34;,{&#34;tagName&#34;:&#34;strong&#34;,&#34;attributes&#34;:{&#34;data-pm-slice&#34;:&#34;0 0 []&#34;,&#34;style&#34;:&#34;-webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; outline: 0px; max-width: 100%; font-size: 17px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; color: rgba(0, 0, 0, 0.9); font-family: mp-quote, system-ui, -apple-system, BlinkMacSystemFont, Arial, sans-serif; letter-spacing: 0.578px; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;}]" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf=""><span textstyle="" style="font-size: 15px;color: rgb(255, 0, 0);">添加助手获取PPT、加入直播群</span></span></span></strong></p><p class="channels_iframe_wrp" nodeleaf=""><mp-common-videosnap class="js_uneditable custom_select_card channels_live_iframe" data-pluginname="mpvideosnap" data-headimgurl="https://wx.qlogo.cn/finderhead/yCWgT0gnfDFdppkCgia7zCWWEO0Wwvg4Evld2AKh8Fg4/0" data-username="v2_060000231003b20faec8c6ea8a19cad0c906ee36b077561ac77b50bace8983cb38b3293ad1bf@finder" data-nickname="dbaplus社群" data-desc="将在10月29日 14:30 直播" data-type="live" data-intro="Data for AI" data-noticeid="finderlivenotice-v2_060000231003b20faec8c6ea8a19cad0c906ee36b077561ac77b50bace8983cb38b3293ad1bf@finder-1793158189024964-1796624859" data-status="0"></mp-common-videosnap></p></div><p style="display: none;"><mp-style-type data-value="3"></mp-style-type></p>



<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=7fc8bff0&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzkzMjYzNjkzNw%3D%3D%26mid%3D2247638321%26idx%3D1%26sn%3Dda713c944587b33d807dad5154c5d6c1">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Thu, 29 Oct 2026 07:15:00 +0800</pubDate>
    </item>
    <item>
      <title>告别AI黑盒：Prompt、Tool Call、Trace、Token全链路可观测实战</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzkzMjYzNjkzNw==&amp;mid=2247638321&amp;idx=2&amp;sn=8d162a8c7adf0fc1172417ae70d7e186</link>
      <description>你的AI系统，为何会时好时坏？</description>
      <content:encoded><![CDATA[<p><span>Knock</span> <span>2026-10-29 07:15</span> <span style="display: inline-block;">广东</span></p>




  <p>以下文章来源于：ThinkingAgent</p>
  <strong>ThinkingAgent</strong>
  <p>分享AI Native时代最新技术和落地实践。</p>



  
  <p><img src="https://wechat2rss.xlab.app/img-proxy/?k=aeaeb0ad&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYZLbKudqfKFlzKMkNXQJ7TpNAjZkyticC2v4JU9FxRad7No18ib1BZYJnlAv5AJ9Vm7KDJp7bu6IGuYDtXiaibeexQrhp734jEDjUw%2F0%3Fwx_fmt%3Djpeg"/></p>
  <p>你的AI系统，为何会时好时坏？</p>
  <p class="mp_profile_iframe_wrp" style="margin-bottom: 0px;" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-service_type="1" data-verify_status="2"></mp-common-profile></p><div data-role="outer" label="edit by 135editor" data-pm-slice="0 0 []"><div data-role="paragraph"><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">你的 AI 系统上线了，用户反馈「有时候好用，有时候不好用」。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">你想排查问题，却发现：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Prompt 是什么？不知道，没记录</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">调了哪些工具？不知道，没日志</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">完整调用链路？不知道，黑盒</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Token 花了多少钱？月底账单才知道</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">这不是个例。这是 2026 年大多数 AI 系统的现状。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">传统软件有成熟的监控体系（APM、日志、指标、链路追踪），但 AI 系统——特别是基于 LLM 的系统——有其独特的复杂性：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">不确定性：</span>同样的输入，可能产生不同的输出</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">多步骤：</span>一个用户请求可能触发 10+ 次 LLM 调用</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">工具链：</span>Agent 会调用外部 API、数据库、搜索引擎</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">成本不透明：</span>Token 消耗、API 调用费用难以预估</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">这就是为什么我们需要 AI 可观测性（AI Observability）。</span></span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">一、什么是 AI 可观测性？</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">AI 可观测性不是简单的日志记录。它是<span textstyle="" style="font-weight: bold;">理解 AI 系统内部状态和行为的完整能力</span>。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">类比传统软件：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">传统 APM：监控 HTTP 请求 → 数据库查询 → 响应</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">AI 可观测性：监控用户输入 → Prompt → LLM 调用 → Tool Call → 多轮推理 → 最终输出</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">AI 可观测性的 4 个核心维度：</span></span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="markdown"><code><span leaf=""><span class="code-snippet__bullet">1.</span> Prompt 追踪：记录和追踪所有 Prompt（包括动态生成的）</span></code><br/><code><span leaf=""><span class="code-snippet__bullet">2.</span> Tool Call 追踪：监控 Agent 调用的所有外部工具</span></code><br/><code><span leaf=""><span class="code-snippet__bullet">3.</span> Trace 链路追踪：完整的调用链路，从输入到输出</span></code><br/><code><span leaf=""><span class="code-snippet__bullet">4.</span> Token 追踪：Token 消耗、成本、延迟的实时监控</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这 4 个维度缺一不可。缺任何一个，你的 AI 系统就是一个「昂贵的黑盒」。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">二、维度 1：Prompt 追踪——你的 AI 在「想」什么？</span></strong></span></p></div></div></div></div><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img" data-aistatus="1" data-backh="330" data-backw="578" data-imgfileid="100154107" data-ratio="0.5712962962962963" data-s="300,640" type="block" data-type="png" data-w="1080" style="width:100%;" src="https://wechat2rss.xlab.app/img-proxy/?k=90bdd4ef&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYYBp8QP1lBvctToZ3FqjVTHo3xBej65xJAM7beC2C4We43kDU1Y2sGwoKvTPZk0o79bEYMtxU8QcfTsySx1gGtJ632QjZMfky0%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">1、为什么 Prompt 追踪如此重要？</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">一个典型的 AI 应用，一次用户请求可能生成多个 Prompt：</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="javascript"><code><span leaf="">用户输入：<span class="code-snippet__string">&#34;帮我写一封邮件&#34;</span></span></code><br/><code><span leaf="">  ↓</span></code><br/><code><span leaf=""><span class="code-snippet__title">Prompt</span> <span class="code-snippet__number">1</span>: 意图识别（判断用户想做什么）</span></code><br/><code><span leaf="">  ↓</span></code><br/><code><span leaf=""><span class="code-snippet__title">Prompt</span> <span class="code-snippet__number">2</span>: 上下文检索（从知识库找相关信息）</span></code><br/><code><span leaf="">  ↓</span></code><br/><code><span leaf=""><span class="code-snippet__title">Prompt</span> <span class="code-snippet__number">3</span>: 邮件生成（根据意图和上下文生成邮件）</span></code><br/><code><span leaf="">  ↓</span></code><br/><code><span leaf=""><span class="code-snippet__title">Prompt</span> <span class="code-snippet__number">4</span>: 质量检查（检查邮件是否符合要求）</span></code><br/><code><span leaf="">  ↓</span></code><br/><code><span leaf="">最终输出：一封完整的邮件</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">如果最终输出的邮件有问题，你如何定位是哪个 Prompt 出了问题？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">没有 Prompt 追踪，你只能猜测。有了 Prompt 追踪，你可以精确定位。</span></span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">2、Prompt 追踪的核心要素</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">每个 Prompt 应该记录：</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="apache"><code><span leaf=""><span class="code-snippet__attribute">prompt_trace</span>:</span></code><br/><code><span leaf="">  <span class="code-snippet__attribute">id</span>: <span class="code-snippet__string">&#34;prompt_abc123&#34;</span>           # 唯一标识</span></code><br/><code><span leaf="">  <span class="code-snippet__attribute">timestamp</span>: <span class="code-snippet__string">&#34;2026-06-18T10:23:45Z&#34;</span></span></code><br/><code><span leaf="">  <span class="code-snippet__attribute">parent_id</span>: <span class="code-snippet__string">&#34;trace_xyz789&#34;</span>     # 所属的 Trace ID</span></code><br/><code></code><br/><code><span leaf="">  <span class="code-snippet__comment"># Prompt 内容</span></span></code><br/><code><span leaf="">  <span class="code-snippet__attribute">system_prompt</span>: <span class="code-snippet__string">&#34;你是一个专业的邮件助手...&#34;</span></span></code><br/><code><span leaf="">  <span class="code-snippet__attribute">user_prompt</span>: <span class="code-snippet__string">&#34;用户原始输入&#34;</span></span></code><br/><code><span leaf="">  <span class="code-snippet__attribute">full_prompt</span>: <span class="code-snippet__string">&#34;最终发送给 LLM 的完整 Prompt&#34;</span></span></code><br/><code></code><br/><code><span leaf="">  <span class="code-snippet__comment"># 模型调用</span></span></code><br/><code><span leaf="">  <span class="code-snippet__attribute">model</span>: <span class="code-snippet__string">&#34;gpt-5.5&#34;</span></span></code><br/><code><span leaf="">  <span class="code-snippet__attribute">temperature</span>: <span class="code-snippet__number">0</span>.<span class="code-snippet__number">7</span></span></code><br/><code><span leaf="">  <span class="code-snippet__attribute">max_tokens</span>: <span class="code-snippet__number">2000</span></span></code><br/><code></code><br/><code><span leaf="">  <span class="code-snippet__comment"># LLM 响应</span></span></code><br/><code><span leaf="">  <span class="code-snippet__attribute">response</span>: <span class="code-snippet__string">&#34;LLM 的完整输出&#34;</span></span></code><br/><code><span leaf="">  <span class="code-snippet__attribute">finish_reason</span>: <span class="code-snippet__string">&#34;stop&#34;</span>  # 或 <span class="code-snippet__string">&#34;length&#34;</span>、<span class="code-snippet__string">&#34;content_filter&#34;</span></span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf="">  <span class="code-snippet__comment"># 性能指标</span></span></code><br/><code><span leaf="">  <span class="code-snippet__attribute">latency_ms</span>: <span class="code-snippet__number">1234</span></span></code><br/><code><span leaf="">  <span class="code-snippet__attribute">tokens_input</span>: <span class="code-snippet__number">850</span></span></code><br/><code><span leaf="">  <span class="code-snippet__attribute">tokens_output</span>: <span class="code-snippet__number">420</span></span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf="">  <span class="code-snippet__comment"># 上下文</span></span></code><br/><code><span leaf="">  <span class="code-snippet__attribute">metadata</span>:</span></code><br/><code><span leaf="">    <span class="code-snippet__attribute">user_id</span>: <span class="code-snippet__string">&#34;user_12345&#34;</span></span></code><br/><code><span leaf="">    <span class="code-snippet__attribute">session_id</span>: <span class="code-snippet__string">&#34;session_67890&#34;</span></span></code><br/><code><span leaf="">    <span class="code-snippet__attribute">feature_flag</span>: <span class="code-snippet__string">&#34;new_email_template_v2&#34;</span></span></code><br/></pre></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">3、实战：用 Langfuse 实现 Prompt 追踪</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Langfuse 是目前最流行的开源 AI 可观测性平台。下面是一个完整的示例：</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="python"><code><span leaf=""><span class="code-snippet__keyword">from</span> langfuse <span class="code-snippet__keyword">import</span> Langfuse</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">from</span> openai <span class="code-snippet__keyword">import</span> OpenAI</span></code><br/><code><span leaf=""><span class="code-snippet__comment"># 初始化</span></span></code><br/><code><span leaf="">langfuse = Langfuse(</span></code><br/><code><span leaf="">    public_key=<span class="code-snippet__string">&#34;pk-lf-...&#34;</span>,</span></code><br/><code><span leaf="">    secret_key=<span class="code-snippet__string">&#34;sk-lf-...&#34;</span>,</span></code><br/><code><span leaf="">    host=<span class="code-snippet__string">&#34;<a href="https://cloud.langfuse.com" target="_blank">https://cloud.langfuse.com</a>&#34;</span></span></code><br/><code><span leaf="">)</span></code><br/><code><span leaf="">openai = OpenAI()</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">def</span> <span class="code-snippet__title">generate_email</span>(<span class="code-snippet__params">user_input: </span><span class="code-snippet__params"><span class="code-snippet__built_in">str</span></span><span class="code-snippet__params">, user_id: </span><span class="code-snippet__params"><span class="code-snippet__built_in">str</span></span>):</span></code><br/><code><span leaf="">    <span class="code-snippet__comment"># 创建 Trace</span></span></code><br/><code><span leaf="">    trace = langfuse.trace(</span></code><br/><code><span leaf="">        name=<span class="code-snippet__string">&#34;email_generation&#34;</span>,</span></code><br/><code><span leaf="">        user_id=user_id,</span></code><br/><code><span leaf="">        metadata={<span class="code-snippet__string">&#34;source&#34;</span>: <span class="code-snippet__string">&#34;web&#34;</span>}</span></code><br/><code><span leaf="">    )</span></code><br/><code><span leaf="">    <span class="code-snippet__comment"># 追踪 Prompt 1: 意图识别</span></span></code><br/><code><span leaf="">    span1 = trace.span(name=<span class="code-snippet__string">&#34;intent_detection&#34;</span>)</span></code><br/><code><span leaf="">    intent_prompt = <span class="code-snippet__string">f&#34;判断用户意图：</span><span class="code-snippet__string"><span class="code-snippet__subst">{user_input}</span></span><span class="code-snippet__string">&#34;</span></span></code><br/><code><span leaf="">    response1 = openai.chat.completions.create(</span></code><br/><code><span leaf="">        model=<span class="code-snippet__string">&#34;gpt-5.5&#34;</span>,</span></code><br/><code><span leaf="">        messages=[{<span class="code-snippet__string">&#34;role&#34;</span>: <span class="code-snippet__string">&#34;user&#34;</span>, <span class="code-snippet__string">&#34;content&#34;</span>: intent_prompt}]</span></code><br/><code><span leaf="">    )</span></code><br/><code><span leaf="">    span1.end(</span></code><br/><code><span leaf="">        output=response1.choices[<span class="code-snippet__number">0</span>].message.content,</span></code><br/><code><span leaf="">        metadata={</span></code><br/><code><span leaf="">            <span class="code-snippet__string">&#34;tokens_input&#34;</span>: response1.usage.prompt_tokens,</span></code><br/><code><span leaf="">            <span class="code-snippet__string">&#34;tokens_output&#34;</span>: response1.usage.completion_tokens</span></code><br/><code><span leaf="">        }</span></code><br/><code><span leaf="">    )</span></code><br/><code><span leaf="">    intent = response1.choices[<span class="code-snippet__number">0</span>].message.content</span></code><br/><code><span leaf="">    <span class="code-snippet__comment"># 追踪 Prompt 2: 邮件生成</span></span></code><br/><code><span leaf="">    span2 = trace.span(name=<span class="code-snippet__string">&#34;email_drafting&#34;</span>)</span></code><br/><code><span leaf="">    email_prompt = <span class="code-snippet__string">f&#34;根据意图 &amp;</span></span></code><br/><code><span leaf="">#x27</span></code><br/><code><span leaf="">;<span class="code-snippet__subst">{intent}</span>&amp;</span></code><br/><code><span leaf="">#x27</span></code><br/><code><span leaf="">; 生成邮件&#34;</span></code><br/><code><span leaf="">    response2 = openai.chat.completions.create(</span></code><br/><code><span leaf="">        model=<span class="code-snippet__string">&#34;gpt-5.5&#34;</span>,</span></code><br/><code><span leaf="">        messages=[{<span class="code-snippet__string">&#34;role&#34;</span>: <span class="code-snippet__string">&#34;user&#34;</span>, <span class="code-snippet__string">&#34;content&#34;</span>: email_prompt}]</span></code><br/><code><span leaf="">    )</span></code><br/><code><span leaf="">    span2.end(</span></code><br/><code><span leaf="">        output=response2.choices[<span class="code-snippet__number">0</span>].message.content,</span></code><br/><code><span leaf="">        metadata={</span></code><br/><code><span leaf="">            <span class="code-snippet__string">&#34;tokens_input&#34;</span>: response2.usage.prompt_tokens,</span></code><br/><code><span leaf="">            <span class="code-snippet__string">&#34;tokens_output&#34;</span>: response2.usage.completion_tokens</span></code><br/><code><span leaf="">        }</span></code><br/><code><span leaf="">    )</span></code><br/><code><span leaf="">    email = response2.choices[<span class="code-snippet__number">0</span>].message.content</span></code><br/><code><span leaf="">    <span class="code-snippet__comment"># 记录最终输出</span></span></code><br/><code><span leaf="">    trace.update(</span></code><br/><code><span leaf="">        output=email,</span></code><br/><code><span leaf="">        metadata={<span class="code-snippet__string">&#34;total_spans&#34;</span>: <span class="code-snippet__number">2</span>}</span></code><br/><code><span leaf="">    )</span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">return</span> email</span></code><br/></pre></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">4、Prompt 追踪的最佳实践</span></strong></span></p></div></div></div><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">记录完整 Prompt：</span>不要只记录用户输入，要记录最终发送给 LLM 的完整 Prompt（包括 system prompt、few-shot examples）</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">版本管理：</span>Prompt 模板要有版本号，方便追踪哪个版本效果好</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">A/B 测试追踪：</span>在 metadata 中记录实验分组，方便后续分析</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">敏感信息脱敏：</span>用户输入可能包含个人信息，记得脱敏后再记录</span></span></p></li></ul><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">三、维度 2：Tool Call 追踪——你的 Agent 在「做」什么？</span></strong></span></p></div></div></div></div><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.5712962962962963" data-s="300,640" data-type="png" data-w="1080" style="width:100%;" type="block" data-backw="578" data-backh="330" data-imgfileid="100154110" src="https://wechat2rss.xlab.app/img-proxy/?k=f79fd6af&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYY3VsnA0czrNTOiakksMbZBwgtIl0jhC1ZS5AuljGsTHbNzhsiaFDOBVpfPSauoHjrAETMIaw5NIzahryJZlzFSFzibXaiaTvrRvnI%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">1、Agent 的工具调用链</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">2026 年的 AI Agent 不再是简单的「问答机器」。它们会：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">搜索互联网获取实时信息</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">调用 API 查询数据库</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">执行代码进行计算</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">操作浏览器完成复杂任务</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">一个 Agent 任务可能调用 5-20 个工具。如果没有追踪，你根本不知道它在做什么。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">2、Tool Call 追踪的核心要素</span></strong></span></p></div></div></div><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="bash"><code><span leaf="">tool_call_trace:</span></code><br/><code><span leaf="">  <span class="code-snippet__built_in">id</span>: <span class="code-snippet__string">&#34;tool_call_def456&#34;</span></span></code><br/><code><span leaf="">  timestamp: <span class="code-snippet__string">&#34;2026-06-18T10:23:46Z&#34;</span></span></code><br/><code><span leaf="">  parent_id: <span class="code-snippet__string">&#34;span_abc123&#34;</span>      <span class="code-snippet__comment"># 所属的 Span</span></span></code><br/><code></code><br/><code><span leaf="">  <span class="code-snippet__comment"># 工具信息</span></span></code><br/><code><span leaf="">  tool_name: <span class="code-snippet__string">&#34;web_search&#34;</span></span></code><br/><code><span leaf="">  tool_version: <span class="code-snippet__string">&#34;2.1.0&#34;</span></span></code><br/><code></code><br/><code><span leaf="">  <span class="code-snippet__comment"># 调用参数</span></span></code><br/><code><span leaf="">  input:</span></code><br/><code><span leaf="">    query: <span class="code-snippet__string">&#34;2026年AI市场规模&#34;</span></span></code><br/><code><span leaf="">    num_results: 5</span></code><br/><code><span leaf="">    date_range: <span class="code-snippet__string">&#34;last_month&#34;</span></span></code><br/><code></code><br/><code><span leaf="">  <span class="code-snippet__comment"># 工具响应</span></span></code><br/><code><span leaf="">  output:</span></code><br/><code><span leaf="">    success: <span class="code-snippet__literal">true</span></span></code><br/><code><span leaf="">    results: [</span></code><br/><code><span leaf="">      {<span class="code-snippet__string">&#34;title&#34;</span>: <span class="code-snippet__string">&#34;...&#34;</span>, <span class="code-snippet__string">&#34;url&#34;</span>: <span class="code-snippet__string">&#34;...&#34;</span>, <span class="code-snippet__string">&#34;snippet&#34;</span>: <span class="code-snippet__string">&#34;...&#34;</span>},</span></code><br/><code><span leaf="">      <span class="code-snippet__comment"># ... 更多结果</span></span></code><br/><code><span leaf="">    ]</span></code><br/><code><span leaf="">    result_count: 5</span></code><br/><code></code><br/><code><span leaf="">  <span class="code-snippet__comment"># 性能指标</span></span></code><br/><code><span leaf="">  latency_ms: 890</span></code><br/><code><span leaf="">  retries: 0</span></code><br/><code></code><br/><code><span leaf="">  <span class="code-snippet__comment"># 错误信息（如果有）</span></span></code><br/><code><span leaf="">  error: null</span></code><br/><code></code><br/><code><span leaf="">  <span class="code-snippet__comment"># 上下文</span></span></code><br/><code><span leaf="">  metadata:</span></code><br/><code><span leaf="">    cache_hit: <span class="code-snippet__literal">false</span></span></code><br/><code><span leaf="">    rate_limited: <span class="code-snippet__literal">false</span></span></code><br/></pre></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">3、实战：追踪 Agent 的工具调用</span></strong></span></p></div></div></div><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="python"><code><span leaf=""><span class="code-snippet__keyword">from</span> langfuse <span class="code-snippet__keyword">import</span> Langfuse</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">from</span> typing <span class="code-snippet__keyword">import</span> <span class="code-snippet__type">Callable</span>, <span class="code-snippet__type">Any</span></span></code><br/><code><span leaf="">langfuse = Langfuse()</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">def</span> <span class="code-snippet__title">tracked_tool_call</span>(<span class="code-snippet__params">trace, tool_name: </span><span class="code-snippet__params"><span class="code-snippet__built_in">str</span></span><span class="code-snippet__params">, func: </span><span class="code-snippet__params"><span class="code-snippet__type">Callable</span></span><span class="code-snippet__params">, **kwargs</span>):</span></code><br/><code><span leaf="">    <span class="code-snippet__string">&#34;&#34;&#34;装饰器：自动追踪工具调用&#34;&#34;&#34;</span></span></code><br/><code><span leaf="">    <span class="code-snippet__comment"># 创建 Span</span></span></code><br/><code><span leaf="">    span = trace.span(</span></code><br/><code><span leaf="">        name=<span class="code-snippet__string">f&#34;tool_call:</span><span class="code-snippet__string"><span class="code-snippet__subst">{tool_name}</span></span><span class="code-snippet__string">&#34;</span>,</span></code><br/><code><span leaf="">        <span class="code-snippet__built_in">input</span>=kwargs</span></code><br/><code><span leaf="">    )</span></code><br/><code></code><br/><code><span leaf="">    <span class="code-snippet__keyword">try</span>:</span></code><br/><code><span leaf="">        <span class="code-snippet__comment"># 执行工具</span></span></code><br/><code><span leaf="">        result = func(**kwargs)</span></code><br/><code><span leaf="">        <span class="code-snippet__comment"># 记录成功</span></span></code><br/><code><span leaf="">        span.end(</span></code><br/><code><span leaf="">            output=result,</span></code><br/><code><span leaf="">            metadata={<span class="code-snippet__string">&#34;success&#34;</span>: <span class="code-snippet__literal">True</span>}</span></code><br/><code><span leaf="">        )</span></code><br/><code></code><br/><code><span leaf="">        <span class="code-snippet__keyword">return</span> result</span></code><br/><code></code><br/><code><span leaf="">    <span class="code-snippet__keyword">except</span> Exception <span class="code-snippet__keyword">as</span> e:</span></code><br/><code><span leaf="">        <span class="code-snippet__comment"># 记录失败</span></span></code><br/><code><span leaf="">        span.end(</span></code><br/><code><span leaf="">            output=<span class="code-snippet__literal">None</span>,</span></code><br/><code><span leaf="">            metadata={</span></code><br/><code><span leaf="">                <span class="code-snippet__string">&#34;success&#34;</span>: <span class="code-snippet__literal">False</span>,</span></code><br/><code><span leaf="">                <span class="code-snippet__string">&#34;error_type&#34;</span>: <span class="code-snippet__built_in">type</span>(e).__name__,</span></code><br/><code><span leaf="">                <span class="code-snippet__string">&#34;error_message&#34;</span>: <span class="code-snippet__built_in">str</span>(e)</span></code><br/><code><span leaf="">            }</span></code><br/><code><span leaf="">        )</span></code><br/><code><span leaf="">        <span class="code-snippet__keyword">raise</span></span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf=""><span class="code-snippet__comment"># 使用示例</span></span></code><br/><code><span leaf=""><span class="code-snippet__keyword">def</span> <span class="code-snippet__title">search_web</span>(<span class="code-snippet__params">query: </span><span class="code-snippet__params"><span class="code-snippet__built_in">str</span></span><span class="code-snippet__params">, num_results: </span><span class="code-snippet__params"><span class="code-snippet__built_in">int</span></span><span class="code-snippet__params"> = </span><span class="code-snippet__params"><span class="code-snippet__number">5</span></span>):</span></code><br/><code><span leaf="">    <span class="code-snippet__comment"># 实际的搜索逻辑</span></span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">return</span> {<span class="code-snippet__string">&#34;results&#34;</span>: [...], <span class="code-snippet__string">&#34;count&#34;</span>: num_results}</span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf=""><span class="code-snippet__comment"># 在 Agent 中调用</span></span></code><br/><code><span leaf="">trace = langfuse.trace(name=<span class="code-snippet__string">&#34;research_agent&#34;</span>)</span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf="">results = tracked_tool_call(</span></code><br/><code><span leaf="">    trace,</span></code><br/><code><span leaf="">    <span class="code-snippet__string">&#34;web_search&#34;</span>,</span></code><br/><code><span leaf="">    search_web,</span></code><br/><code><span leaf="">    query=<span class="code-snippet__string">&#34;AI market size 2026&#34;</span>,</span></code><br/><code><span leaf="">    num_results=<span class="code-snippet__number">5</span></span></code><br/><code><span leaf="">)</span></code><br/></pre></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">4、Tool Call 追踪的关键指标</span></strong></span></p></div></div></div><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">成功率：</span>工具调用的成功率应该 &gt; 99%</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">延迟分布：</span>P50、P95、P99 延迟，识别慢工具</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">错误类型分布：</span>哪些工具最容易出错？</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">调用频率：</span>哪些工具被调用最多？是否有优化空间？</span></span></p></li></ul><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">5、工具调用的常见陷阱</span></strong></span></p></div></div></div><table style="border-collapse:collapse;margin:1em 0;font-size:14px;min-width:173px;"><tbody><tr><th data-colwidth="123" style="background:#f5f5f5;padding:8px 14px;text-align:center;font-weight:bold;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">陷阱</span></span></p></th><th style="background:#f5f5f5;padding:8px 14px;text-align:center;font-weight:bold;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">表现</span></span></p></th><th style="background:#f5f5f5;padding:8px 14px;text-align:center;font-weight:bold;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">解决方案</span></span></p></th></tr><tr><td data-colwidth="123" style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">工具超时</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">Agent 卡在某个工具调用</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">设置超时 + 重试机制</span></span></p></td></tr><tr><td data-colwidth="123" style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">工具幻觉</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">Agent 调用不存在的工具</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">工具注册表 + 严格校验</span></span></p></td></tr><tr><td data-colwidth="123" style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">工具滥用</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">简单任务调用过多工具</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">优化工具选择逻辑</span></span></p></td></tr><tr><td data-colwidth="123" style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">工具依赖</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">工具 A 失败导致工具 B 也失败</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">记录依赖关系 + 级联错误处理</span></span></p></td></tr></tbody></table><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">四、维度 3：Trace 链路追踪——完整的「故事线」</span></strong></span></p></div></div></div></div><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.5712962962962963" data-s="300,640" data-type="png" data-w="1080" style="width:100%;" type="block" data-backw="578" data-backh="330" data-imgfileid="100154113" src="https://wechat2rss.xlab.app/img-proxy/?k=dd4a0fd2&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYa7iclJzKHX3r4icqW6cwDyfkibMxQ0tMn0ibXg4HbqAx7Vqs6bcSaOs2wjCp0BrotdxlIF2jSGV32EpdPZVXcrbC5CMcf5esRX3u8%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">1、什么是 Trace？</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Trace 是<span textstyle="" style="font-weight: bold;">一次完整用户请求的全部调用链路。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">类比：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">传统软件：一个 HTTP 请求 → 多个微服务调用 → 数据库查询 → 响应</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">AI 系统：一个用户输入 → 多个 Prompt → 多次 LLM 调用 → 多个 Tool Call → 最终输出</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">Trace 让你看到完整的「故事线」，而不是零散的片段。</span></span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">2、Trace 的层级结构</span></strong></span></p></div></div></div><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="sql"><code><span leaf="">Trace: 用户请求 &#34;帮我分析这个 CSV 文件&#34;</span></code><br/><code><span leaf="">├── Span <span class="code-snippet__number">1</span>: 意图识别</span></code><br/><code><span leaf="">│   ├── LLM <span class="code-snippet__keyword">Call</span>: GPT<span class="code-snippet__number">-5.5</span> (<span class="code-snippet__number">234</span>ms, <span class="code-snippet__number">850</span> tokens)</span></code><br/><code><span leaf="">│   └── Output: &#34;用户想分析 CSV 数据&#34;</span></code><br/><code><span leaf="">├── Span <span class="code-snippet__number">2</span>: 文件读取</span></code><br/><code><span leaf="">│   ├── Tool <span class="code-snippet__keyword">Call</span>: file_reader (<span class="code-snippet__number">45</span>ms)</span></code><br/><code><span leaf="">│   └── Output: CSV 内容 (<span class="code-snippet__number">1000</span> 行)</span></code><br/><code><span leaf="">├── Span <span class="code-snippet__number">3</span>: 数据分析</span></code><br/><code><span leaf="">│   ├── LLM <span class="code-snippet__keyword">Call</span>: GPT<span class="code-snippet__number">-5.5</span> (<span class="code-snippet__number">1.2</span>s, <span class="code-snippet__number">2100</span> tokens)</span></code><br/><code><span leaf="">│   ├── Tool <span class="code-snippet__keyword">Call</span>: python_executor (<span class="code-snippet__number">890</span>ms)</span></code><br/><code><span leaf="">│   └── Output: 统计结果 <span class="code-snippet__operator">+</span> 图表</span></code><br/><code><span leaf="">├── Span <span class="code-snippet__number">4</span>: 报告生成</span></code><br/><code><span leaf="">│   ├── LLM <span class="code-snippet__keyword">Call</span>: GPT<span class="code-snippet__number">-5.5</span> (<span class="code-snippet__number">1.8</span>s, <span class="code-snippet__number">3200</span> tokens)</span></code><br/><code><span leaf="">│   └── Output: 完整分析报告</span></code><br/><code><span leaf="">└── Span <span class="code-snippet__number">5</span>: 结果格式化</span></code><br/><code><span leaf="">    ├── LLM <span class="code-snippet__keyword">Call</span>: GPT<span class="code-snippet__number">-5.5</span> (<span class="code-snippet__number">456</span>ms, <span class="code-snippet__number">1200</span> tokens)</span></code><br/><code><span leaf="">    └── Output: 最终响应</span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf="">总计：<span class="code-snippet__number">4</span> 次 LLM 调用，<span class="code-snippet__number">2</span> 次工具调用，总延迟 <span class="code-snippet__number">4.6</span>s，总 Token <span class="code-snippet__number">7350</span></span></code><br/></pre></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">3、Trace 的核心价值</span></strong></span></p></div></div></div><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">问题定位：</span>用户说「响应太慢」，Trace 告诉你慢在哪个环节</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">性能优化：</span>发现哪个 Span 耗时最长，针对性优化</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">成本分析：</span>每次请求花了多少 Token，哪些 Prompt 最贵</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">质量评估：</span>对比成功和失败的 Trace，找出差异</span></span></p></li></ul><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">4、实战：构建完整的 Trace</span></strong></span></p></div></div></div><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="python"><code><span leaf=""><span class="code-snippet__keyword">from</span> langfuse <span class="code-snippet__keyword">import</span> Langfuse</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">import</span> time</span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf="">langfuse = Langfuse()</span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf=""><span class="code-snippet__keyword">def</span> <span class="code-snippet__title">analyze_csv</span>(<span class="code-snippet__params">user_input: </span><span class="code-snippet__params"><span class="code-snippet__built_in">str</span></span><span class="code-snippet__params">, file_path: </span><span class="code-snippet__params"><span class="code-snippet__built_in">str</span></span><span class="code-snippet__params">, user_id: </span><span class="code-snippet__params"><span class="code-snippet__built_in">str</span></span>):</span></code><br/><code></code><br/><code><span leaf="">    <span class="code-snippet__comment"># 创建 Trace</span></span></code><br/><code><span leaf="">    trace = langfuse.trace(</span></code><br/><code><span leaf="">        name=<span class="code-snippet__string">&#34;csv_analysis&#34;</span>,</span></code><br/><code><span leaf="">        user_id=user_id,</span></code><br/><code><span leaf="">        metadata={</span></code><br/><code><span leaf="">            <span class="code-snippet__string">&#34;input&#34;</span>: user_input,</span></code><br/><code><span leaf="">            <span class="code-snippet__string">&#34;file_path&#34;</span>: file_path</span></code><br/><code><span leaf="">        }</span></code><br/><code><span leaf="">    )</span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf="">        start_time = time.time()</span></code><br/><code></code><br/><code><span leaf="">    <span class="code-snippet__comment"># Span 1: 意图识别</span></span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">with</span> trace.span(name=<span class="code-snippet__string">&#34;intent_detection&#34;</span>) <span class="code-snippet__keyword">as</span> span1:</span></code><br/><code><span leaf="">        intent = detect_intent(user_input)</span></code><br/><code><span leaf="">        span1.update(output=intent)</span></code><br/><code></code><br/><code><span leaf="">    <span class="code-snippet__comment"># Span 2: 文件读取</span></span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">with</span> trace.span(name=<span class="code-snippet__string">&#34;file_reading&#34;</span>) <span class="code-snippet__keyword">as</span> span2:</span></code><br/><code><span leaf="">        csv_data = read_csv_file(file_path)</span></code><br/><code><span leaf="">        span2.update(</span></code><br/><code><span leaf="">            output={<span class="code-snippet__string">&#34;rows&#34;</span>: <span class="code-snippet__built_in">len</span>(csv_data), <span class="code-snippet__string">&#34;columns&#34;</span>: <span class="code-snippet__built_in">len</span>(csv_data.columns)},</span></code><br/><code><span leaf="">            metadata={<span class="code-snippet__string">&#34;file_size_mb&#34;</span>: get_file_size(file_path)}</span></code><br/><code><span leaf="">        )</span></code><br/><code></code><br/><code><span leaf="">    <span class="code-snippet__comment"># Span 3: 数据分析</span></span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">with</span> trace.span(name=<span class="code-snippet__string">&#34;data_analysis&#34;</span>) <span class="code-snippet__keyword">as</span> span3:</span></code><br/><code><span leaf="">        analysis_prompt = <span class="code-snippet__string">f&#34;分析以下数据：\n</span><span class="code-snippet__string"><span class="code-snippet__subst">{csv_data.head()}</span></span><span class="code-snippet__string">&#34;</span></span></code><br/><code><span leaf="">        analysis = call_llm(analysis_prompt)</span></code><br/><code></code><br/><code><span leaf="">        <span class="code-snippet__comment"># 子 Span: 代码执行</span></span></code><br/><code><span leaf="">        <span class="code-snippet__keyword">with</span> span3.span(name=<span class="code-snippet__string">&#34;code_execution&#34;</span>) <span class="code-snippet__keyword">as</span> sub_span:</span></code><br/><code><span leaf="">            code = extract_code(analysis)</span></code><br/><code><span leaf="">            result = execute_python(code)</span></code><br/><code><span leaf="">            sub_span.update(output=result)</span></code><br/><code><span leaf="">        span3.update(output=analysis)</span></code><br/><code></code><br/><code><span leaf="">    <span class="code-snippet__comment"># Span 4: 报告生成</span></span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">with</span> trace.span(name=<span class="code-snippet__string">&#34;report_generation&#34;</span>) <span class="code-snippet__keyword">as</span> span4:</span></code><br/><code><span leaf="">        report = generate_report(analysis, result)</span></code><br/><code><span leaf="">        span4.update(output=report)</span></code><br/><code></code><br/><code><span leaf="">    <span class="code-snippet__comment"># Span 5: 结果格式化</span></span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">with</span> trace.span(name=<span class="code-snippet__string">&#34;formatting&#34;</span>) <span class="code-snippet__keyword">as</span> span5:</span></code><br/><code><span leaf="">        final_output = format_response(report)</span></code><br/><code><span leaf="">        span5.update(output=final_output)</span></code><br/><code></code><br/><code><span leaf="">    <span class="code-snippet__comment"># 更新 Trace</span></span></code><br/><code><span leaf="">    total_time = time.time() - start_time</span></code><br/><code><span leaf="">    trace.update(</span></code><br/><code><span leaf="">        output=final_output,</span></code><br/><code><span leaf="">        metadata={</span></code><br/><code><span leaf="">            <span class="code-snippet__string">&#34;total_latency_ms&#34;</span>: <span class="code-snippet__built_in">int</span>(total_time * <span class="code-snippet__number">1000</span>),</span></code><br/><code><span leaf="">            <span class="code-snippet__string">&#34;total_spans&#34;</span>: <span class="code-snippet__number">5</span>,</span></code><br/><code><span leaf="">            <span class="code-snippet__string">&#34;total_llm_calls&#34;</span>: <span class="code-snippet__number">4</span></span></code><br/><code><span leaf="">        }</span></code><br/><code><span leaf="">    )</span></code><br/><code></code><br/><code><span leaf="">    <span class="code-snippet__keyword">return</span> final_output</span></code><br/></pre></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">5、Trace 分析的高级技巧</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">1）对比分析</span></span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="bash"><code><span leaf=""><span class="code-snippet__comment"># 对比成功和失败的 Trace</span></span></code><br/><code><span leaf="">successful_traces = langfuse.fetch_traces(</span></code><br/><code><span leaf="">    name=<span class="code-snippet__string">&#34;csv_analysis&#34;</span>,</span></code><br/><code><span leaf="">    metadata={<span class="code-snippet__string">&#34;status&#34;</span>: <span class="code-snippet__string">&#34;success&#34;</span>},</span></code><br/><code><span leaf="">    <span class="code-snippet__built_in">limit</span>=100</span></code><br/><code><span leaf="">)</span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf="">failed_traces = langfuse.fetch_traces(</span></code><br/><code><span leaf="">    name=<span class="code-snippet__string">&#34;csv_analysis&#34;</span>,</span></code><br/><code><span leaf="">    metadata={<span class="code-snippet__string">&#34;status&#34;</span>: <span class="code-snippet__string">&#34;failed&#34;</span>},</span></code><br/><code><span leaf="">    <span class="code-snippet__built_in">limit</span>=100</span></code><br/><code><span leaf="">)</span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf=""><span class="code-snippet__comment"># 分析差异</span></span></code><br/><code><span leaf=""><span class="code-snippet__comment"># 成功的 Trace 平均 3 次 LLM 调用</span></span></code><br/><code><span leaf=""><span class="code-snippet__comment"># 失败的 Trace 平均 7 次 LLM 调用（可能在重试）</span></span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">2）性能瓶颈识别</span></span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="python"><code><span leaf=""><span class="code-snippet__comment"># 找出最慢的 Span</span></span></code><br/><code><span leaf="">traces = langfuse.fetch_traces(name=<span class="code-snippet__string">&#34;csv_analysis&#34;</span>, limit=<span class="code-snippet__number">1000</span>)</span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf="">span_latencies = {}</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">for</span> trace <span class="code-snippet__keyword">in</span> traces:</span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">for</span> span <span class="code-snippet__keyword">in</span> trace.spans:</span></code><br/><code><span leaf="">        <span class="code-snippet__keyword">if</span> span.name <span class="code-snippet__keyword">not</span> <span class="code-snippet__keyword">in</span> span_latencies:</span></code><br/><code><span leaf="">            span_latencies[span.name] = []</span></code><br/><code><span leaf="">        span_latencies[span.name].append(span.latency_ms)</span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf=""><span class="code-snippet__comment"># 计算每个 Span 的平均延迟</span></span></code><br/><code><span leaf=""><span class="code-snippet__keyword">for</span> span_name, latencies <span class="code-snippet__keyword">in</span> span_latencies.items():</span></code><br/><code><span leaf="">    avg = <span class="code-snippet__built_in">sum</span>(latencies) / <span class="code-snippet__built_in">len</span>(latencies)</span></code><br/><code><span leaf="">    p95 = <span class="code-snippet__built_in">sorted</span>(latencies)[<span class="code-snippet__built_in">int</span>(<span class="code-snippet__built_in">len</span>(latencies) * <span class="code-snippet__number">0.95</span>)]</span></code><br/><code><span leaf="">    <span class="code-snippet__built_in">print</span>(<span class="code-snippet__string">f&#34;</span><span class="code-snippet__string"><span class="code-snippet__subst">{span_name}</span></span><span class="code-snippet__string">: avg=</span><span class="code-snippet__string"><span class="code-snippet__subst">{avg}</span></span><span class="code-snippet__string">ms, p95=</span><span class="code-snippet__string"><span class="code-snippet__subst">{p95}</span></span><span class="code-snippet__string">ms&#34;</span>)</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">3）成本归因</span></span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="python"><code><span leaf=""><span class="code-snippet__comment"># 计算每个 Span 的 Token 消耗和成本</span></span></code><br/><code><span leaf="">trace = langfuse.fetch_trace(trace_id=<span class="code-snippet__string">&#34;xxx&#34;</span>)</span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf="">total_cost = <span class="code-snippet__number">0</span></span></code><br/><code><span leaf=""><span class="code-snippet__keyword">for</span> span <span class="code-snippet__keyword">in</span> trace.spans:</span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">if</span> span.<span class="code-snippet__built_in">type</span> == <span class="code-snippet__string">&#34;llm&#34;</span>:</span></code><br/><code><span leaf="">        tokens = span.metadata.get(<span class="code-snippet__string">&#34;tokens_input&#34;</span>, <span class="code-snippet__number">0</span>) + span.metadata.get(<span class="code-snippet__string">&#34;tokens_output&#34;</span>, <span class="code-snippet__number">0</span>)</span></code><br/><code><span leaf="">        cost = calculate_cost(span.model, tokens)</span></code><br/><code><span leaf="">        total_cost += cost</span></code><br/><code><span leaf="">        <span class="code-snippet__built_in">print</span>(<span class="code-snippet__string">f&#34;</span><span class="code-snippet__string"><span class="code-snippet__subst">{span.name}</span></span><span class="code-snippet__string">: </span><span class="code-snippet__string"><span class="code-snippet__subst">{tokens}</span></span><span class="code-snippet__string"> tokens, $</span><span class="code-snippet__string"><span class="code-snippet__subst">{cost:</span></span><span class="code-snippet__string"><span class="code-snippet__subst"><span class="code-snippet__number">.4</span></span></span><span class="code-snippet__string"><span class="code-snippet__subst">f}</span></span><span class="code-snippet__string">&#34;</span>)</span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf=""><span class="code-snippet__built_in">print</span>(<span class="code-snippet__string">f&#34;Total cost: $</span><span class="code-snippet__string"><span class="code-snippet__subst">{total_cost:</span></span><span class="code-snippet__string"><span class="code-snippet__subst"><span class="code-snippet__number">.4</span></span></span><span class="code-snippet__string"><span class="code-snippet__subst">f}</span></span><span class="code-snippet__string">&#34;</span>)</span></code><br/></pre></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">五、维度 4：Token 追踪——你的 AI 花了多少钱？</span></strong></span></p></div></div></div></div><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.5712962962962963" data-s="300,640" data-type="png" data-w="1080" type="block" data-imgfileid="100154115" src="https://wechat2rss.xlab.app/img-proxy/?k=248118d4&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FgiamgWvCHDYYibZgpJYE3R2pF4E5r0w3cxiaudwic0Gx1ibeUYlqJ5IibrA7pGJ4oQsFOmY4hzHpqHibOIsLG6VmoXIIUr3akVwrrnAUicoH3fmdQj4%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">1、为什么 Token 追踪如此重要？</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">2026 年的 LLM 价格：</span></span></p><table style="width:100%;border-collapse:collapse;margin:1em 0;font-size:14px;"><tbody><tr><th style="background:#f5f5f5;padding:8px 14px;text-align:center;font-weight:bold;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">模型</span></span></p></th><th style="background:#f5f5f5;padding:8px 14px;text-align:center;font-weight:bold;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">输入价格 ($/1M tokens)</span></span></p></th><th style="background:#f5f5f5;padding:8px 14px;text-align:center;font-weight:bold;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">输出价格 ($/1M tokens)</span></span></p></th></tr><tr><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">GPT-5.5</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">$15</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">$60</span></span></p></td></tr><tr><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">Claude Opus 4</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">$15</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">$75</span></span></p></td></tr><tr><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">Gemini 2.5 Ultra</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">$12.50</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">$50</span></span></p></td></tr><tr><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">DeepSeek-V4</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">$0.55</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">$2.19</span></span></p></td></tr></tbody></table><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">一个复杂 Agent 任务可能消耗 10,000+ tokens，成本 $0.5-$1。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">如果你的系统每天处理 10,000 个请求：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">低成本模型：$50-$100/天</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">高成本模型：$5,000-$10,000/天</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">没有 Token 追踪，你只能在月底收到账单时才知道花了多少钱。有了 Token 追踪，你可以实时监控、预警、优化。</span></span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">2、Token 追踪的核心指标</span></strong></span></p></div></div></div><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="apache"><code><span leaf=""><span class="code-snippet__attribute">token_metrics</span>:</span></code><br/><code><span leaf="">  <span class="code-snippet__comment"># 实时指标</span></span></code><br/><code><span leaf="">  <span class="code-snippet__attribute">tokens_per_minute</span>: <span class="code-snippet__number">125000</span></span></code><br/><code><span leaf="">  <span class="code-snippet__attribute">cost_per_minute</span>: $<span class="code-snippet__number">8</span>.<span class="code-snippet__number">50</span></span></code><br/><code></code><br/><code><span leaf="">  <span class="code-snippet__comment"># 按用户/会话/功能分组</span></span></code><br/><code><span leaf="">  <span class="code-snippet__attribute">tokens_by_user</span>:</span></code><br/><code><span leaf="">    <span class="code-snippet__attribute">user_123</span>: <span class="code-snippet__number">45000</span> tokens ($<span class="code-snippet__number">2</span>.<span class="code-snippet__number">70</span>)</span></code><br/><code><span leaf="">    <span class="code-snippet__attribute">user_456</span>: <span class="code-snippet__number">38000</span> tokens ($<span class="code-snippet__number">2</span>.<span class="code-snippet__number">28</span>)</span></code><br/><code><span leaf="">  <span class="code-snippet__attribute">tokens_by_feature</span>:</span></code><br/><code><span leaf="">    <span class="code-snippet__attribute">email_generation</span>: <span class="code-snippet__number">85000</span> tokens ($<span class="code-snippet__number">5</span>.<span class="code-snippet__number">10</span>)</span></code><br/><code><span leaf="">    <span class="code-snippet__attribute">csv_analysis</span>: <span class="code-snippet__number">125000</span> tokens ($<span class="code-snippet__number">7</span>.<span class="code-snippet__number">50</span>)</span></code><br/><code><span leaf="">    <span class="code-snippet__attribute">chat</span>: <span class="code-snippet__number">40000</span> tokens ($<span class="code-snippet__number">2</span>.<span class="code-snippet__number">40</span>)</span></code><br/><code></code><br/><code><span leaf="">  <span class="code-snippet__comment"># 趋势分析</span></span></code><br/><code><span leaf="">  <span class="code-snippet__attribute">daily_tokens</span>:</span></code><br/><code><span leaf="">    <span class="code-snippet__attribute">2026</span>-<span class="code-snippet__number">06</span>-<span class="code-snippet__number">16</span>: <span class="code-snippet__number">2</span>.<span class="code-snippet__number">5</span>M tokens ($<span class="code-snippet__number">150</span>)</span></code><br/><code><span leaf="">    <span class="code-snippet__attribute">2026</span>-<span class="code-snippet__number">06</span>-<span class="code-snippet__number">17</span>: <span class="code-snippet__number">2</span>.<span class="code-snippet__number">8</span>M tokens ($<span class="code-snippet__number">168</span>)</span></code><br/><code><span leaf="">    <span class="code-snippet__attribute">2026</span>-<span class="code-snippet__number">06</span>-<span class="code-snippet__number">18</span>: <span class="code-snippet__number">3</span>.<span class="code-snippet__number">1</span>M tokens ($<span class="code-snippet__number">186</span>)  # +<span class="code-snippet__number">10</span>% 增长</span></code><br/><code></code><br/><code><span leaf="">  <span class="code-snippet__comment"># 预算控制</span></span></code><br/><code><span leaf="">  <span class="code-snippet__attribute">monthly_budget</span>: $<span class="code-snippet__number">5000</span></span></code><br/><code><span leaf="">  <span class="code-snippet__attribute">monthly_spent</span>: $<span class="code-snippet__number">3200</span></span></code><br/><code><span leaf="">  <span class="code-snippet__attribute">monthly_remaining</span>: $<span class="code-snippet__number">1800</span></span></code><br/><code><span leaf="">  <span class="code-snippet__attribute">projected_end_of_month</span>: $<span class="code-snippet__number">4800</span>  # 基于当前趋势</span></code><br/></pre></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">3、实战：构建 Token 追踪系统</span></strong></span></p></div></div></div><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="python"><code><span leaf=""><span class="code-snippet__keyword">from</span> langfuse <span class="code-snippet__keyword">import</span> Langfuse</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">from</span> dataclasses <span class="code-snippet__keyword">import</span> dataclass</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">from</span> typing <span class="code-snippet__keyword">import</span> <span class="code-snippet__type">Dict</span></span></code><br/><code><span leaf=""><span class="code-snippet__keyword">import</span> json</span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf="">langfuse = Langfuse()</span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf=""><span class="code-snippet__meta">@dataclass</span></span></code><br/><code><span leaf=""><span class="code-snippet__keyword">class</span> <span class="code-snippet__title">TokenUsage</span>:</span></code><br/><code><span leaf="">    model: <span class="code-snippet__built_in">str</span></span></code><br/><code><span leaf="">    input_tokens: <span class="code-snippet__built_in">int</span></span></code><br/><code><span leaf="">    output_tokens: <span class="code-snippet__built_in">int</span></span></code><br/><code><span leaf="">    cost: <span class="code-snippet__built_in">float</span></span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf=""><span class="code-snippet__keyword">class</span> <span class="code-snippet__title">TokenTracker</span>:</span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">def</span> <span class="code-snippet__title">__init__</span>(<span class="code-snippet__params">self</span>):</span></code><br/><code><span leaf="">        <span class="code-snippet__variable">self</span>.usage_by_user: <span class="code-snippet__type">Dict</span>[<span class="code-snippet__built_in">str</span>, TokenUsage] = {}</span></code><br/><code><span leaf="">        <span class="code-snippet__variable">self</span>.usage_by_feature: <span class="code-snippet__type">Dict</span>[<span class="code-snippet__built_in">str</span>, TokenUsage] = {}</span></code><br/><code><span leaf="">        <span class="code-snippet__variable">self</span>.daily_usage: <span class="code-snippet__type">Dict</span>[<span class="code-snippet__built_in">str</span>, TokenUsage] = {}</span></code><br/><code></code><br/><code><span leaf="">    <span class="code-snippet__keyword">def</span> <span class="code-snippet__title">record_usage</span>(<span class="code-snippet__params">self, user_id: </span><span class="code-snippet__params"><span class="code-snippet__built_in">str</span></span><span class="code-snippet__params">, feature: </span><span class="code-snippet__params"><span class="code-snippet__built_in">str</span></span><span class="code-snippet__params">, model: </span><span class="code-snippet__params"><span class="code-snippet__built_in">str</span></span><span class="code-snippet__params">, </span></span></code><br/><code><span leaf="">                     input_tokens: <span class="code-snippet__built_in">int</span>, output_tokens: <span class="code-snippet__built_in">int</span>):</span></code><br/><code><span leaf="">        <span class="code-snippet__string">&#34;&#34;&#34;记录 Token 使用&#34;&#34;&#34;</span></span></code><br/><code><span leaf="">        cost = <span class="code-snippet__variable">self</span>._calculate_cost(model, input_tokens, output_tokens)</span></code><br/><code></code><br/><code><span leaf="">        usage = TokenUsage(</span></code><br/><code><span leaf="">            model=model,</span></code><br/><code><span leaf="">            input_tokens=input_tokens,</span></code><br/><code><span leaf="">            output_tokens=output_tokens,</span></code><br/><code><span leaf="">            cost=cost</span></code><br/><code><span leaf="">        )</span></code><br/><code></code><br/><code><span leaf="">        <span class="code-snippet__comment"># 按用户聚合</span></span></code><br/><code><span leaf="">        <span class="code-snippet__keyword">if</span> user_id <span class="code-snippet__keyword">not</span> <span class="code-snippet__keyword">in</span> <span class="code-snippet__variable">self</span>.usage_by_user:</span></code><br/><code><span leaf="">            <span class="code-snippet__variable">self</span>.usage_by_user[user_id] = TokenUsage(model, <span class="code-snippet__number">0</span>, <span class="code-snippet__number">0</span>, <span class="code-snippet__number">0</span>)</span></code><br/><code><span leaf="">        <span class="code-snippet__variable">self</span>.usage_by_user[user_id].input_tokens += input_tokens</span></code><br/><code><span leaf="">        <span class="code-snippet__variable">self</span>.usage_by_user[user_id].output_tokens += output_tokens</span></code><br/><code><span leaf="">        <span class="code-snippet__variable">self</span>.usage_by_user[user_id].cost += cost</span></code><br/><code></code><br/><code><span leaf="">        <span class="code-snippet__comment"># 按功能聚合</span></span></code><br/><code><span leaf="">        <span class="code-snippet__keyword">if</span> feature <span class="code-snippet__keyword">not</span> <span class="code-snippet__keyword">in</span> <span class="code-snippet__variable">self</span>.usage_by_feature:</span></code><br/><code><span leaf="">            <span class="code-snippet__variable">self</span>.usage_by_feature[feature] = TokenUsage(model, <span class="code-snippet__number">0</span>, <span class="code-snippet__number">0</span>, <span class="code-snippet__number">0</span>)</span></code><br/><code><span leaf="">        <span class="code-snippet__variable">self</span>.usage_by_feature[feature].input_tokens += input_tokens</span></code><br/><code><span leaf="">        <span class="code-snippet__variable">self</span>.usage_by_feature[feature].output_tokens += output_tokens</span></code><br/><code><span leaf="">        <span class="code-snippet__variable">self</span>.usage_by_feature[feature].cost += cost</span></code><br/><code></code><br/><code><span leaf="">        <span class="code-snippet__comment"># 按天聚合</span></span></code><br/><code><span leaf="">        today = datetime.now().strftime(<span class="code-snippet__string">&#34;%Y-%m-%d&#34;</span>)</span></code><br/><code><span leaf="">        <span class="code-snippet__keyword">if</span> today <span class="code-snippet__keyword">not</span> <span class="code-snippet__keyword">in</span> <span class="code-snippet__variable">self</span>.daily_usage:</span></code><br/><code><span leaf="">            <span class="code-snippet__variable">self</span>.daily_usage[today] = TokenUsage(model, <span class="code-snippet__number">0</span>, <span class="code-snippet__number">0</span>, <span class="code-snippet__number">0</span>)</span></code><br/><code><span leaf="">        <span class="code-snippet__variable">self</span>.daily_usage[today].input_tokens += input_tokens</span></code><br/><code><span leaf="">        <span class="code-snippet__variable">self</span>.daily_usage[today].output_tokens += output_tokens</span></code><br/><code><span leaf="">        <span class="code-snippet__variable">self</span>.daily_usage[today].cost += cost</span></code><br/><code></code><br/><code><span leaf="">        <span class="code-snippet__comment"># 发送到 Langfuse</span></span></code><br/><code><span leaf="">        langfuse.score(</span></code><br/><code><span leaf="">            name=<span class="code-snippet__string">&#34;token_cost&#34;</span>,</span></code><br/><code><span leaf="">            value=cost,</span></code><br/><code><span leaf="">            metadata={</span></code><br/><code><span leaf="">                <span class="code-snippet__string">&#34;user_id&#34;</span>: user_id,</span></code><br/><code><span leaf="">                <span class="code-snippet__string">&#34;feature&#34;</span>: feature,</span></code><br/><code><span leaf="">                <span class="code-snippet__string">&#34;model&#34;</span>: model</span></code><br/><code><span leaf="">            }</span></code><br/><code><span leaf="">        )</span></code><br/><code></code><br/><code><span leaf="">    <span class="code-snippet__keyword">def</span> <span class="code-snippet__title">_calculate_cost</span>(<span class="code-snippet__params">self, model: </span><span class="code-snippet__params"><span class="code-snippet__built_in">str</span></span><span class="code-snippet__params">, input_tokens: </span><span class="code-snippet__params"><span class="code-snippet__built_in">int</span></span><span class="code-snippet__params">, output_tokens: </span><span class="code-snippet__params"><span class="code-snippet__built_in">int</span></span>) -&gt; <span class="code-snippet__built_in">float</span>:</span></code><br/><code><span leaf="">        <span class="code-snippet__string">&#34;&#34;&#34;计算成本&#34;&#34;&#34;</span></span></code><br/><code><span leaf="">        pricing = {</span></code><br/><code><span leaf="">            <span class="code-snippet__string">&#34;gpt-5.5&#34;</span>: {<span class="code-snippet__string">&#34;input&#34;</span>: <span class="code-snippet__number">15</span>, <span class="code-snippet__string">&#34;output&#34;</span>: <span class="code-snippet__number">60</span>},      <span class="code-snippet__comment"># $/1M tokens</span></span></code><br/><code><span leaf="">            <span class="code-snippet__string">&#34;claude-opus-4&#34;</span>: {<span class="code-snippet__string">&#34;input&#34;</span>: <span class="code-snippet__number">15</span>, <span class="code-snippet__string">&#34;output&#34;</span>: <span class="code-snippet__number">75</span>},</span></code><br/><code><span leaf="">            <span class="code-snippet__string">&#34;gemini-2.5-ultra&#34;</span>: {<span class="code-snippet__string">&#34;input&#34;</span>: <span class="code-snippet__number">12.5</span>, <span class="code-snippet__string">&#34;output&#34;</span>: <span class="code-snippet__number">50</span>},</span></code><br/><code><span leaf="">            <span class="code-snippet__string">&#34;deepseek-v4&#34;</span>: {<span class="code-snippet__string">&#34;input&#34;</span>: <span class="code-snippet__number">0.55</span>, <span class="code-snippet__string">&#34;output&#34;</span>: <span class="code-snippet__number">2.19</span>},</span></code><br/><code><span leaf="">        }</span></code><br/><code><span leaf="">        <span class="code-snippet__keyword">if</span> model <span class="code-snippet__keyword">not</span> <span class="code-snippet__keyword">in</span> pricing:</span></code><br/><code><span leaf="">            <span class="code-snippet__keyword">return</span> <span class="code-snippet__number">0</span></span></code><br/><code></code><br/><code><span leaf="">        input_cost = (input_tokens / <span class="code-snippet__number">1_000_000</span>) * pricing[model][<span class="code-snippet__string">&#34;input&#34;</span>]</span></code><br/><code><span leaf="">        output_cost = (output_tokens / <span class="code-snippet__number">1_000_000</span>) * pricing[model][<span class="code-snippet__string">&#34;output&#34;</span>]</span></code><br/><code></code><br/><code><span leaf="">        <span class="code-snippet__keyword">return</span> input_cost + output_cost</span></code><br/><code></code><br/><code><span leaf="">    <span class="code-snippet__keyword">def</span> <span class="code-snippet__title">get_daily_report</span>(<span class="code-snippet__params">self</span>):</span></code><br/><code><span leaf="">        <span class="code-snippet__string">&#34;&#34;&#34;生成每日报告&#34;&#34;&#34;</span></span></code><br/><code><span leaf="">        today = datetime.now().strftime(<span class="code-snippet__string">&#34;%Y-%m-%d&#34;</span>)</span></code><br/><code><span leaf="">        usage = <span class="code-snippet__variable">self</span>.daily_usage.get(today, TokenUsage(<span class="code-snippet__string">&#34;&#34;</span>, <span class="code-snippet__number">0</span>, <span class="code-snippet__number">0</span>, <span class="code-snippet__number">0</span>))</span></code><br/><code></code><br/><code><span leaf="">        <span class="code-snippet__keyword">return</span> {</span></code><br/><code><span leaf="">            <span class="code-snippet__string">&#34;date&#34;</span>: today,</span></code><br/><code><span leaf="">            <span class="code-snippet__string">&#34;total_tokens&#34;</span>: usage.input_tokens + usage.output_tokens,</span></code><br/><code><span leaf="">            <span class="code-snippet__string">&#34;total_cost&#34;</span>: usage.cost,</span></code><br/><code><span leaf="">            <span class="code-snippet__string">&#34;by_feature&#34;</span>: {</span></code><br/><code><span leaf="">                feature: {</span></code><br/><code><span leaf="">                    <span class="code-snippet__string">&#34;tokens&#34;</span>: u.input_tokens + u.output_tokens,</span></code><br/><code><span leaf="">                    <span class="code-snippet__string">&#34;cost&#34;</span>: u.cost</span></code><br/><code><span leaf="">                }</span></code><br/><code><span leaf="">                <span class="code-snippet__keyword">for</span> feature, u <span class="code-snippet__keyword">in</span> <span class="code-snippet__variable">self</span>.usage_by_feature.items()</span></code><br/><code><span leaf="">            }</span></code><br/><code><span leaf="">        }</span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf=""><span class="code-snippet__comment"># 使用示例</span></span></code><br/><code><span leaf="">tracker = TokenTracker()</span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf=""><span class="code-snippet__comment"># 在每次 LLM 调用后记录</span></span></code><br/><code><span leaf="">tracker.record_usage(</span></code><br/><code><span leaf="">    user_id=<span class="code-snippet__string">&#34;user_123&#34;</span>,</span></code><br/><code><span leaf="">    feature=<span class="code-snippet__string">&#34;email_generation&#34;</span>,</span></code><br/><code><span leaf="">    model=<span class="code-snippet__string">&#34;gpt-5.5&#34;</span>,</span></code><br/><code><span leaf="">    input_tokens=<span class="code-snippet__number">850</span>,</span></code><br/><code><span leaf="">    output_tokens=<span class="code-snippet__number">420</span></span></code><br/><code><span leaf="">)</span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf=""><span class="code-snippet__comment"># 查看报告</span></span></code><br/><code><span leaf="">report = tracker.get_daily_report()</span></code><br/><code><span leaf=""><span class="code-snippet__built_in">print</span>(json.dumps(report, indent=<span class="code-snippet__number">2</span>))</span></code><br/></pre></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">4、Token 优化策略</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">1）模型选择优化</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">不是所有任务都需要最贵的模型：</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="python"><code><span leaf=""><span class="code-snippet__keyword">def</span> <span class="code-snippet__title">select_model</span>(<span class="code-snippet__params">task_complexity: </span><span class="code-snippet__params"><span class="code-snippet__built_in">str</span></span>) -&gt; <span class="code-snippet__built_in">str</span>:</span></code><br/><code><span leaf="">    <span class="code-snippet__string">&#34;&#34;&#34;根据任务复杂度选择模型&#34;&#34;&#34;</span></span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">if</span> task_complexity == <span class="code-snippet__string">&#34;high&#34;</span>:</span></code><br/><code><span leaf="">        <span class="code-snippet__keyword">return</span> <span class="code-snippet__string">&#34;gpt-5.5&#34;</span>      <span class="code-snippet__comment"># $15/$60</span></span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">elif</span> task_complexity == <span class="code-snippet__string">&#34;medium&#34;</span>:</span></code><br/><code><span leaf="">        <span class="code-snippet__keyword">return</span> <span class="code-snippet__string">&#34;gemini-2.5-flash&#34;</span>  <span class="code-snippet__comment"># $0.30/$1.20</span></span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">else</span>:</span></code><br/><code><span leaf="">        <span class="code-snippet__keyword">return</span> <span class="code-snippet__string">&#34;deepseek-v4&#34;</span>  <span class="code-snippet__comment"># $0.55/$2.19</span></span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">2）Prompt 缓存</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">相同的 Prompt 前缀可以缓存，避免重复计算：</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="ini"><code><span leaf=""><span class="code-snippet__comment"># 优化前：每次都发送完整的 system prompt</span></span></code><br/><code><span leaf=""><span class="code-snippet__attr">prompt1</span> = system_prompt + user_input1  <span class="code-snippet__comment"># 2000 tokens</span></span></code><br/><code><span leaf=""><span class="code-snippet__attr">prompt2</span> = system_prompt + user_input2  <span class="code-snippet__comment"># 2000 tokens</span></span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf=""><span class="code-snippet__comment"># 优化后：使用 Prompt 缓存</span></span></code><br/><code><span leaf=""><span class="code-snippet__comment"># system_prompt 只需计算一次，后续调用享受 50% 折扣</span></span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">3）输出长度控制</span></span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="ini"><code><span leaf=""><span class="code-snippet__comment"># 优化前：不限制输出长度</span></span></code><br/><code><span leaf=""><span class="code-snippet__attr">response</span> = call_llm(prompt)  <span class="code-snippet__comment"># 可能输出 2000 tokens</span></span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf=""><span class="code-snippet__comment"># 优化后：根据任务设置 max_tokens</span></span></code><br/><code><span leaf=""><span class="code-snippet__attr">response</span> = call_llm(prompt, max_tokens=<span class="code-snippet__number">500</span>)  <span class="code-snippet__comment"># 最多 500 tokens</span></span></code><br/></pre></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">六、完整的 AI 可观测性架构</span></strong></span></p></div></div></div></div><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.5712962962962963" data-s="300,640" data-type="png" data-w="1080" type="block" data-imgfileid="100154118" src="https://wechat2rss.xlab.app/img-proxy/?k=ce44d2da&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FgiamgWvCHDYbjagKUbs5LbZ35QgVosg7WjV2MnvP8C7nOMMJ2MIruxxBFJl1LQdtqm9EoeDlooxVnsdypvap7pyxlTqLd4ldTicaBgGfoJPg0%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">1、4 个维度的整合</span></strong></span></p></div></div></div><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="css"><code><span leaf="">用户请求</span></code><br/><code><span leaf="">  ↓</span></code><br/><code><span leaf=""><span class="code-snippet__selector-attr">[Trace 链路追踪]</span> ← 贯穿整个流程</span></code><br/><code><span leaf="">  ↓</span></code><br/><code><span leaf=""><span class="code-snippet__selector-attr">[Span 1: Prompt 追踪]</span></span></code><br/><code><span leaf="">  - 记录完整 Prompt</span></code><br/><code><span leaf="">  - 追踪 LLM 调用</span></code><br/><code><span leaf="">  ↓</span></code><br/><code><span leaf=""><span class="code-snippet__selector-attr">[Span 2: Tool Call 追踪]</span></span></code><br/><code><span leaf="">  - 记录工具调用</span></code><br/><code><span leaf="">  - 追踪执行结果</span></code><br/><code><span leaf="">  ↓</span></code><br/><code><span leaf=""><span class="code-snippet__selector-attr">[Span 3: Prompt 追踪]</span></span></code><br/><code><span leaf="">  - 记录后续 Prompt</span></code><br/><code><span leaf="">  ↓</span></code><br/><code><span leaf=""><span class="code-snippet__selector-attr">[Token 追踪]</span> ← 聚合所有 <span class="code-snippet__selector-tag">Span</span> 的 Token 消耗</span></code><br/><code><span leaf="">  ↓</span></code><br/><code><span leaf="">最终响应</span></code><br/></pre></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">2、技术栈选择</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">开源方案：</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">1）Langfuse（推荐）</span></span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">开源 + 云托管</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">支持 Prompt、Tool Call、Trace、Token 全维度</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">易于集成，Python/JS SDK 完善</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">适合中小团队</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">2）OpenTelemetry + 自定义</span></span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">完全开源，高度可定制</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">需要自己搭建存储和可视化</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">适合有基础设施团队的大公司</span></span></p></li></ul><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">3、生产环境部署清单</span></strong></span></p></div></div></div><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="makefile"><code><span leaf=""><span class="code-snippet__comment"># 1. 基础设施</span></span></code><br/><code><span leaf=""><span class="code-snippet__section">observability_stack:</span></span></code><br/><code><span leaf="">  - langfuse: v2.0+          <span class="code-snippet__comment"># 核心追踪平台</span></span></code><br/><code><span leaf="">  - postgresql: 15+          <span class="code-snippet__comment"># 元数据存储</span></span></code><br/><code><span leaf="">  - clickhouse: 23+          <span class="code-snippet__comment"># 时序数据存储</span></span></code><br/><code><span leaf="">  - redis: 7+                <span class="code-snippet__comment"># 缓存</span></span></code><br/><code><span leaf="">  - grafana: 10+             <span class="code-snippet__comment"># 可视化（可选）</span></span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf=""><span class="code-snippet__comment"># 2. 集成点</span></span></code><br/><code><span leaf=""><span class="code-snippet__section">integration_points:</span></span></code><br/><code><span leaf="">  - llm_provider: OpenAI/Anthropic/自建网关</span></code><br/><code><span leaf="">  - agent_framework: LangChain/LlamaIndex/自建</span></code><br/><code><span leaf="">  - tool_registry: MCP Server</span></code><br/><code><span leaf="">  - alerting: Slack/PagerDuty/Email</span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf=""><span class="code-snippet__comment"># 3. 监控告警</span></span></code><br/><code><span leaf=""><span class="code-snippet__section">alerts:</span></span></code><br/><code><span leaf="">  - name: <span class="code-snippet__string">&#34;高延迟告警&#34;</span></span></code><br/><code><span leaf="">    condition: <span class="code-snippet__string">&#34;p95_latency &gt; 5000ms&#34;</span></span></code><br/><code><span leaf="">    action: <span class="code-snippet__string">&#34;notify_slack&#34;</span></span></code><br/><code><span leaf="">  - name: <span class="code-snippet__string">&#34;高错误率告警&#34;</span></span></code><br/><code><span leaf="">    condition: <span class="code-snippet__string">&#34;error_rate &gt; 5%&#34;</span></span></code><br/><code><span leaf="">    action: <span class="code-snippet__string">&#34;notify_pagerduty&#34;</span></span></code><br/><code><span leaf="">  - name: <span class="code-snippet__string">&#34;成本超支告警&#34;</span></span></code><br/><code><span leaf="">    condition: <span class="code-snippet__string">&#34;daily_cost &gt; budget * 0.8&#34;</span></span></code><br/><code><span leaf="">    action: <span class="code-snippet__string">&#34;notify_email&#34;</span></span></code><br/><code><span leaf="">  - name: <span class="code-snippet__string">&#34;Token 异常告警&#34;</span></span></code><br/><code><span leaf="">    condition: <span class="code-snippet__string">&#34;tokens_per_request &gt; 10000&#34;</span></span></code><br/><code><span leaf="">    action: <span class="code-snippet__string">&#34;notify_slack&#34;</span></span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf=""><span class="code-snippet__comment"># 4. 数据保留</span></span></code><br/><code><span leaf=""><span class="code-snippet__section">retention:</span></span></code><br/><code><span leaf="">  traces: 90 days</span></code><br/><code><span leaf="">  metrics: 1 year</span></code><br/><code><span leaf="">  logs: 30 days</span></code><br/></pre></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">七、实战案例：一个完整的可观测性改造</span></strong></span></p></div></div></div></div><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.5712962962962963" data-s="300,640" data-type="png" data-w="1080" style="width:100%;" type="block" data-backw="578" data-backh="330" data-imgfileid="100154121" src="https://wechat2rss.xlab.app/img-proxy/?k=c042fcb5&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYZGEdWOdFk7tTjfOpqwGXuo9OIprhc7CX3lr7slQwh84rFLhgSYRThvcXl5ocOFvu6aTx1rQnIqHLN9AJwsURxKOxm7vJvT0Y8%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">1、背景</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">一个电商客服 AI 系统，用户反馈「有时候回答很慢，有时候回答错误」。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">2、改造前的问题</span></strong></span></p></div></div></div><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">没有 Prompt 追踪：不知道发给 LLM 的是什么</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">没有 Tool Call 追踪：不知道 Agent 调了哪些工具</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">没有 Trace：不知道完整调用链路</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">没有 Token 追踪：不知道花了多少钱</span></span></p></li></ul><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">3、改造方案</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">Step 1: 接入 Langfuse</span></span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="python"><code><span leaf=""><span class="code-snippet__keyword">from</span> langfuse <span class="code-snippet__keyword">import</span> Langfuse</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">from</span> langfuse.callback <span class="code-snippet__keyword">import</span> CallbackHandler</span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf="">langfuse = Langfuse()</span></code><br/><code><span leaf="">handler = CallbackHandler()</span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf=""><span class="code-snippet__comment"># 在 LangChain 中集成</span></span></code><br/><code><span leaf="">chain.invoke(<span class="code-snippet__built_in">input</span>, config={<span class="code-snippet__string">&#34;callbacks&#34;</span>: [handler]})</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">Step 2: 添加自定义追踪</span></span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="makefile"><code><span leaf=""><span class="code-snippet__comment"># 追踪关键业务指标</span></span></code><br/><code><span leaf="">trace = langfuse.trace(</span></code><br/><code><span leaf="">    name=<span class="code-snippet__string">&#34;customer_service&#34;</span>,</span></code><br/><code><span leaf="">    metadata={</span></code><br/><code><span leaf="">        <span class="code-snippet__string">&#34;customer_id&#34;</span>: customer_id,</span></code><br/><code><span leaf="">        <span class="code-snippet__string">&#34;product_category&#34;</span>: category,</span></code><br/><code><span leaf="">        <span class="code-snippet__string">&#34;issue_type&#34;</span>: issue_type</span></code><br/><code><span leaf="">    }</span></code><br/><code><span leaf="">)</span></code><br/><code><span leaf=""><br/></span></code><br/><code><span leaf=""><span class="code-snippet__comment"># 记录用户满意度</span></span></code><br/><code><span leaf="">trace.score(</span></code><br/><code><span leaf="">    name=<span class="code-snippet__string">&#34;user_satisfaction&#34;</span>,</span></code><br/><code><span leaf="">    value=4.5,  <span class="code-snippet__comment"># 1-5 分</span></span></code><br/><code><span leaf="">    comment=<span class="code-snippet__string">&#34;用户评价&#34;</span></span></code><br/><code><span leaf="">)</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">Step 3: 构建监控仪表盘</span></span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="makefile"><code><span leaf=""><span class="code-snippet__comment"># 关键指标</span></span></code><br/><code><span leaf="">dashboard_metrics = {</span></code><br/><code><span leaf="">    <span class="code-snippet__string">&#34;请求量&#34;</span>: <span class="code-snippet__string">&#34;count(traces) by hour&#34;</span>,</span></code><br/><code><span leaf="">    <span class="code-snippet__string">&#34;平均延迟&#34;</span>: <span class="code-snippet__string">&#34;avg(latency_ms)&#34;</span>,</span></code><br/><code><span leaf="">    <span class="code-snippet__string">&#34;P95 延迟&#34;</span>: <span class="code-snippet__string">&#34;percentile(latency_ms, 95)&#34;</span>,</span></code><br/><code><span leaf="">    <span class="code-snippet__string">&#34;错误率&#34;</span>: <span class="code-snippet__string">&#34;count(error_traces) / count(traces)&#34;</span>,</span></code><br/><code><span leaf="">    <span class="code-snippet__string">&#34;日均成本&#34;</span>: <span class="code-snippet__string">&#34;sum(token_cost) by day&#34;</span>,</span></code><br/><code><span leaf="">    <span class="code-snippet__string">&#34;用户满意度&#34;</span>: <span class="code-snippet__string">&#34;avg(user_satisfaction_score)&#34;</span></span></code><br/><code><span leaf="">}</span></code><br/></pre></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">4、改造后的成果</span></strong></span></p></div></div></div><table style="width:100%;border-collapse:collapse;margin:1em 0;font-size:14px;"><tbody><tr><th style="background:#f5f5f5;padding:8px 14px;text-align:center;font-weight:bold;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">指标</span></span></p></th><th style="background:#f5f5f5;padding:8px 14px;text-align:center;font-weight:bold;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">改造前</span></span></p></th><th style="background:#f5f5f5;padding:8px 14px;text-align:center;font-weight:bold;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">改造后</span></span></p></th><th style="background:#f5f5f5;padding:8px 14px;text-align:center;font-weight:bold;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">改进</span></span></p></th></tr><tr><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">问题定位时间</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">2-4 小时</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">5-10 分钟</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">95% ↓</span></span></p></td></tr><tr><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">P95 延迟</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">8.5s</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">3.2s</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">62% ↓</span></span></p></td></tr><tr><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">日均成本</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">$450</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">$280</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">38% ↓</span></span></p></td></tr><tr><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">用户满意度</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">3.2/5</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">4.3/5</span></span></p></td><td style="padding:8px 14px;border:1px solid #EEE;text-align:center;"><p><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">34% ↑</span></span></p></td></tr></tbody></table><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">关键发现：</span></span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">慢响应的原因：</span>某个 Tool Call（查询订单系统）P95 延迟 4.2s，优化后降至 0.8s</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">错误回答的原因：</span>Prompt 模板中的 few-shot examples 过时，更新后准确率提升 25%</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">成本优化的机会：</span>30% 的请求可以用更便宜的模型处理，切换后成本降低 40%</span></span></p></li></ul><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">八、最佳实践：AI 可观测性的 10 条原则</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.5712962962962963" data-w="1080" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);margin: 0px;padding: 0px;outline: 0px;color: rgba(0, 0, 0, 0.9);font-family: &#34;PingFang SC NEW&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: 0.544px;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;user-select: auto;" src="https://wechat2rss.xlab.app/img-proxy/?k=a863d7d4&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FsgapT9kohVDictvTMjf8EI3zIjvWzTahNzkkLmFvbicktMPlKHwpqicEnTzD2bWORicHwsCjVT9ibJvibBYGdYLldzfd7qZbzhmTic42VHBBIcyiaso%2F640%3Ffrom%3Dappmsg%26tp%3Dwxpic%26wxfrom%3D5%26wx_lazy%3D1%26watermark%3D1%23imgIndex%3D6"/></span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">1、从第一天就接入可观测性</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">不要等到上线后才补。可观测性应该是开发流程的一部分，而不是事后补救。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">2、追踪一切，但要有重点</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">追踪所有 LLM 调用和 Tool Call，但重点关注：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">高成本的功能</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">高延迟的环节</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">高错误率的路径</span></span></p></li></ul><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">3、结构化你的 Trace</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">使用清晰的命名规范：</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="makefile"><code><span leaf=""><span class="code-snippet__section">trace_name: feature_action</span></span></code><br/><code><span leaf=""><span class="code-snippet__section">span_name: step_type</span></span></code><br/><code><span leaf="">例：</span></code><br/><code><span leaf="">  trace: csv_analysis</span></code><br/><code><span leaf="">  span: intent_detection:llm</span></code><br/><code><span leaf="">  span: file_reading:tool</span></code><br/><code><span leaf="">  span: data_analysis:llm+tool</span></code><br/></pre></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">4、记录足够的上下文</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">每个 Span 都应该记录：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">输入和输出</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">模型和参数</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Token 消耗</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">延迟</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">错误信息（如果有）</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">业务上下文（用户 ID、会话 ID、功能版本）</span></span></p></li></ul><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">5、设置合理的告警</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">不要告警太多（告警疲劳），也不要告警太少（漏掉问题）：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">延迟：P95 &gt; 5s</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">错误率：&gt; 5%</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">成本：超过预算 80%</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Token：单次请求 &gt; 10,000 tokens</span></span></p></li></ul><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">6、定期回顾 Trace</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">每周花时间回顾：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">最慢的 10 个 Trace</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">最贵的 10 个 Trace</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">失败的 Trace</span></span></p></li></ul><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">7、建立成本意识</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">让团队了解成本：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">每个功能的日均成本</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">每个用户的平均成本</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">每次 LLM 调用的平均成本</span></span></p></li></ul><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">8、持续优化 Prompt</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">基于 Trace 数据优化 Prompt：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">缩短不必要的 Prompt</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">优化 few-shot examples</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">调整 temperature 等参数</span></span></p></li></ul><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">9、版本管理</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">追踪所有变更：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Prompt 模板版本</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">模型版本</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">工具版本</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">代码版本</span></span></p></li></ul><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">10、安全与隐私</span></strong></span></p></div></div></div><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">脱敏敏感信息</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">控制数据访问权限</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">遵守数据保留政策</span></span></p></li></ul><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">九、总结：从黑盒到透明</span></strong></span></p></div></div></div></div><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.5712962962962963" data-s="300,640" data-type="png" data-w="1080" type="block" data-imgfileid="100154123" src="https://wechat2rss.xlab.app/img-proxy/?k=274f9dd5&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYaUnhSj72b1MfJmjKgn4qakMJWxt9eYV48zqOsj0nIcp2iaCDaREOYXWfQYCQOIkVzeQ17Q5CSjWxCvvQdY0ehicmVJgfsYD5864%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">AI 可观测性不是可选项，而是<span textstyle="" style="font-weight: bold;">必选项</span>。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">没有可观测性的 AI 系统：</span></span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">问题定位靠猜</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">性能优化靠感觉</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">成本控制靠月底账单</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">质量改进靠用户反馈</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">有可观测性的 AI 系统：</span></span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">问题定位靠数据（5 分钟找到根因）</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">性能优化靠分析（精准识别瓶颈）</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">成本控制靠实时监控（随时预警）</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">质量改进靠 A/B 测试（数据驱动决策）</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">记住这 4 个维度：</span></span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">Prompt 追踪：</span>你的 AI 在「想」什么</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">Tool Call 追踪：</span>你的 Agent 在「做」什么</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">Trace 链路追踪：</span>完整的「故事线」</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">Token 追踪：</span>你的 AI 花了多少钱</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">从今天开始，让你的 AI 系统从黑盒变成透明。</span></span></p><div data-tools="135编辑器" data-id="85988" data-color="#138bde" data-custom="#138bde" style=""><div style="margin: 0px auto;padding: 0px;border: none;display: inline-block;width: 100%;max-width: 100% !important;box-sizing:border-box;" data-width="100%"><p style="margin: 0px;padding: 0px;font-size: 18px;letter-spacing: -2px;display: inline-block;box-sizing: border-box;font-family:sans-serif;"><span style="font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span style="color: #138bde;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: #138bde;opacity: 0.7;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: #138bde;opacity: 0.5;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: #138bde;opacity: 0.3;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span></strong></span></p><div style="margin-left: 10px;color: #138bde;display: inline-block;"><p data-brushtype="text" style="font-size: 16px;color: inherit;margin-top: 0px;margin-bottom: 0px;"><span style="font-family:Helvetica Neue, Helvetica, Hiragino Sans GB, Apple Color Emoji, Emoji Symbols Font, Segoe UI Symbol, Arial, sans-serif;"><strong><span leaf="">参考资料</span></strong></span></p></div></div></div><p data-role="list"><ul style="list-style-type: disc;margin:0px;padding:0 0 0 30px;list-style-position:outside;" class="list-paddingleft-2"><li><p style="line-height:1.75;"><span style="font-size: 12px;color: #7f7f7f;"><span leaf="">Langfuse 官方文档（<a href="https://langfuse.com/docs）" target="_blank">https://langfuse.com/docs）</a></span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 12px;color: #7f7f7f;"><span leaf="">LangSmith 官方文档（<a href="https://docs.smith.langchain.com）" target="_blank">https://docs.smith.langchain.com）</a></span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 12px;color: #7f7f7f;"><span leaf="">OpenTelemetry for LLMs（<a href="https://opentelemetry.io/blog/2024/genai）" target="_blank">https://opentelemetry.io/blog/2024/genai）</a></span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 12px;color: #7f7f7f;"><span leaf="">AI Trust OS: Continuous Governance for Autonomous AI（<a href="https://arxiv.org/abs/2604.04749）(2026.04)" target="_blank">https://arxiv.org/abs/2604.04749）(2026.04)</a></span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 12px;color: #7f7f7f;"><span leaf="">Governance-Aware Agent Telemetry（<a href="https://arxiv.org/abs/2604.05119）(2026.04)" target="_blank">https://arxiv.org/abs/2604.05119）(2026.04)</a></span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 12px;color: #7f7f7f;"><span leaf="">From Confident Closing to Silent Failure（<a href="https://arxiv.org/abs/2606.09863）(2026.06)" target="_blank">https://arxiv.org/abs/2606.09863）(2026.06)</a></span></span></p></li></ul></p></div><div data-role="paragraph" style="font-family:sans-serif;"><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">作者丨Knock</span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;text-align: left;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">来源丨公众号：ThinkingAgent（ID：ThinkingAgent）</span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">dbaplus社群欢迎广大技术人员投稿，投稿邮箱：</span></span><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">editor@dbaplus.cn</span></span></p><p class="mp_profile_iframe_wrp" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-service_type="1" data-verify_status="2"></mp-common-profile></p><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img" data-aistatus="1" data-imgfileid="100130225" data-ratio="0.07777777777777778" data-s="300,640" type="block" data-w="1080" src="https://wechat2rss.xlab.app/img-proxy/?k=f32823a4&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FufWcjcomw8Zf2jiaBBH3vdgfP4A2rem5YEAHYH074dc4GibhojA5B3lLZrXLDRciaVnficveaHcAUCiaIPoDsTkAduA%2F640%3Fwx_fmt%3Dpng"/></p></div></div><p style="display: none;"><mp-style-type data-value="3"></mp-style-type></p>



<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=8c52f4f1&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzkzMjYzNjkzNw%3D%3D%26mid%3D2247638321%26idx%3D2%26sn%3D8d162a8c7adf0fc1172417ae70d7e186">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Thu, 29 Oct 2026 07:15:00 +0800</pubDate>
    </item>
    <item>
      <title>从SYN到FIN：一个TCP连接的完整过程是怎样的？</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzkzMjYzNjkzNw==&amp;mid=2247638291&amp;idx=1&amp;sn=ff78e879ca585cb892c696f689dd4ecc</link>
      <description>很多人学TCP，是从“三次握手”开始背的，但这是本末倒置。</description>
      <content:encoded><![CDATA[<p><span>dbaplus社群</span> <span>2026-10-28 07:15</span> <span style="display: inline-block;">广东</span></p>






  
  <p><img src="https://wechat2rss.xlab.app/img-proxy/?k=61657704&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYZP2oqOvTIeTicaJ1nNt6iapsFmu3f1o9sjXI1hZxYw1fsM6FfVic1FTdoTJu7NCfRhdlk3Jt7zKDnrlb6pt2nlqa6VuuTapvvznQ%2F0%3Fwx_fmt%3Djpeg"/></p>
  <p>很多人学TCP，是从“三次握手”开始背的，但这是本末倒置。</p>
  <p class="custom_select_card_wrp mp_profile_iframe_wrp" style="margin-bottom: 0px;" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-service_type="1" data-verify_status="2"></mp-common-profile></p><div data-role="outer" label="edit by 135editor" data-pm-slice="0 0 []"><div data-role="paragraph"><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">你有没有遇到过这种情况：接口偶发超时，查了半天日志，最后发现是 TCP 重传在搞鬼？或者线上服务器 CLOSE_WAIT 堆积到几万，服务假死却找不到原因？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">TCP 是每个程序员的 &#34;老熟人&#34;，但大多数人对它的理解停留在 &#34;三次握手、四次挥手&#34; 的八股层面。真正到了线上排障、性能调优的时候，才发现自己对这个 &#34;最熟悉的陌生人&#34; 知之甚少。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这篇文章，我想带着你跟着一个 TCP 连接从生到死走一遍，把那些零散的知识点串成一条完整的故事线。文末附 Wireshark 抓包实战，看完你不仅能应付面试，更能解决实际问题。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">一、全局认知：TCP 到底在哪一层？</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">TCP 工作在<span textstyle="" style="font-weight: bold"> OSI 模型的第 4 层 —— 传输层</span>，在 TCP/IP 四层模型中同样位于传输层（第三层）。它的上面是应用层（HTTP、Redis、MySQL 等），下面是网络层（IP 协议）。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.27569444444444446" data-type="jpeg" data-w="1440" data-imgfileid="100154230" src="https://wechat2rss.xlab.app/img-proxy/?k=20466f11&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FgiamgWvCHDYbn1TkicC4zQVjgYyDiado4ibibrv2jWSFXyiasTXH4lHoCpZwVAjcvSE4tSuBP1Gp0hY8RkdNXyz2icg0D0iaiamsiahEv0W7RIXE71Ojs%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;"><span><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px; color: rgb(127, 127, 127)">图1 TCP的在协议栈的位置</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">网络层负责把数据包从 A 机器送到 B 机器，但它是<span textstyle="" style="font-weight: bold">不可靠</span>的 —— 包可能丢、可能乱序、可能重复。TCP 就是在 IP 之上，为应用层提供了一层 &#34;可靠交付&#34; 的抽象。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">一句话定义 TCP：<span textstyle="" style="font-weight: bold">面向连接的、可靠的、基于字节流的、全双工的传输层协议。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这四个关键词，每一个都对应着一套复杂的机制，我们后面会逐一拆解。</span></span></p><div data-role="paragraph" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="color: #7f7f7f;font-size: 15px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">面试视角：面试官问 &#34;TCP 和 UDP 的区别&#34;，不要只背 &#34;TCP 可靠、UDP 不可靠&#34;。本质区别是：TCP 在不可靠的 IP 层之上，通过序列号、确认、重传、窗口等机制，模拟出了一条 &#34;可靠的管道&#34;；而 UDP 只是对 IP 包做了薄薄的一层封装（加了端口和校验和），几乎不提供任何额外保证。</span></span></p></div></div></div></div><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">二、TCP 的核心功能：它到底解决了什么问题？</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">很多人学 TCP，是从 &#34;三次握手&#34; 开始背的，但这是本末倒置。握手只是手段，TCP 的核心目标是以下四件事：</span></span></p><table style="border-collapse: collapse;font-size: 15px;margin: 1.4em auto;max-width: 100%;table-layout: fixed;text-align: left;width: 654px;color: rgb(25, 27, 31);font-family: -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Microsoft YaHei&#34;, &#34;Source Han Sans SC&#34;, &#34;Noto Sans CJK SC&#34;, &#34;WenQuanYi Micro Hei&#34;, &#34;MiSans L3&#34;, &#34;Segoe UI&#34;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;"><tbody><tr><th style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;background: rgb(235, 236, 237);color: rgb(25, 27, 31);font-weight: 500;"><p><span leaf=""><span textstyle="" style="font-size: 15px; color: rgb(62, 62, 62)">功能</span></span></p></th><th style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;background: rgb(235, 236, 237);color: rgb(25, 27, 31);font-weight: 500;"><p><span leaf=""><span textstyle="" style="font-size: 15px; color: rgb(62, 62, 62)">解决的问题</span></span></p></th><th style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;background: rgb(235, 236, 237);color: rgb(25, 27, 31);font-weight: 500;"><p><span leaf=""><span textstyle="" style="font-size: 15px; color: rgb(62, 62, 62)">关键机制</span></span></p></th></tr><tr><td style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;"><p><span leaf=""><span textstyle="" style="font-size: 15px; color: rgb(62, 62, 62)">可靠交付</span></span></p></td><td style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;"><p><span leaf=""><span textstyle="" style="font-size: 15px; color: rgb(62, 62, 62)">丢包</span></span></p></td><td style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;"><p><span leaf=""><span textstyle="" style="font-size: 15px; color: rgb(62, 62, 62)">序列号 + ACK + 超时重传+快速重传</span></span></p></td></tr><tr><td style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;"><p><span leaf=""><span textstyle="" style="font-size: 15px; color: rgb(62, 62, 62)">有序性</span></span></p></td><td style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;"><p><span leaf=""><span textstyle="" style="font-size: 15px; color: rgb(62, 62, 62)">数据包可能乱序到达</span></span></p></td><td style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;"><p><span leaf=""><span textstyle="" style="font-size: 15px; color: rgb(62, 62, 62)">序列号排序 + 接收缓冲区重组</span></span></p></td></tr><tr><td style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;"><p><span leaf=""><span textstyle="" style="font-size: 15px; color: rgb(62, 62, 62)">流量控制</span></span></p></td><td style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;"><p><span leaf=""><span textstyle="" style="font-size: 15px; color: rgb(62, 62, 62)">发送方发太快，接收方处理不过来</span></span></p></td><td style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;"><p><span leaf=""><span textstyle="" style="font-size: 15px; color: rgb(62, 62, 62)">滑动窗口（rwnd）</span></span></p></td></tr><tr><td style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;"><p><span leaf=""><span textstyle="" style="font-size: 15px; color: rgb(62, 62, 62)">拥塞控制</span></span></p></td><td style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;"><p><span leaf=""><span textstyle="" style="font-size: 15px; color: rgb(62, 62, 62)">发送方发太快，网络处理不过来</span></span></p></td><td style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;"><p><span leaf=""><span textstyle="" style="font-size: 15px; color: rgb(62, 62, 62)">拥塞窗口（cwnd）+ 慢启动 / 拥塞避免 / 快恢复</span></span></p></td></tr></tbody></table><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">最后两个的区别：<span textstyle="" style="font-weight: bold">流量控制是端到端的（怕接收方扛不住），拥塞控制是全局的（怕网络扛不住）</span>。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">三、连接建立：三次握手</span></strong></span></p></div></div></div></div><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">1、为什么需要 &#34;握手&#34;？</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">TCP 是面向连接的协议。&#34;面向连接&#34; 不是说物理上有一条专线，而是说通信双方在传输数据之前，需要<span textstyle="" style="font-weight: bold">协商一系列参数</span>：初始序列号（ISN）、窗口大小、MSS（最大段长度）、是否支持 SACK 等。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">三次握手，本质上就是双方交换这些初始信息的过程。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">2、三次握手的完整过程</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.7736943907156673" data-type="jpeg" data-w="1034" data-imgfileid="100154232" src="https://wechat2rss.xlab.app/img-proxy/?k=38b9f697&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYbETtzSd8zAahBHmIXC7d3nLIZMMibXaxUZLpnBjzvzZ1Ge7iaKrJBUHCeSPzeCcq75XeDkYuvs90h9kJBgwqFmm4zQLBK1we9ic8%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;"><span><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px; color: rgb(127, 127, 127)">图2 TCP建连-三次握手</span></span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">第一次：客户端发送 SYN=1, seq=x，进入 SYN_SENT 状态</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">第二次：服务器回复 SYN=1, ACK=1, seq=y, ack=x+1，进入 SYN_RCVD 状态</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">第三次：客户端发送 ACK=1, seq=x+1, ack=y+1，双方进入 ESTABLISHED 状态</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这里有个细节：SYN 包和 FIN 包都要消耗一个序列号，所以确认号是 +1。普通数据包的确认号则是 &#34;期望收到的下一个字节的序号&#34;。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">3、为什么是三次，不是两次？</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">核心原因有两个：</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">1）防止已失效的连接请求到达服务器。</span>如果客户端发了一个 SYN，因为网络延迟迟迟没到，客户端超时重发了一个新的 SYN 并建立了连接。之后那个 &#34;老 SYN&#34; 终于到了服务器，如果是两次握手，服务器就会建立一条多余的连接。三次握手中，客户端收到服务器对老 SYN 的确认后，发现这个 seq 不对，会回复一个 RST 拒绝。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">2）双方都需要确认对方的发送和接收能力正常。</span>三次握手是 &#34;双方各发一个 SYN、各收一个 ACK&#34; 的最小次数：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">客户端发 SYN → 服务器知道客户端能发</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">服务器回 SYN+ACK → 客户端知道服务器能发能收</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">客户端回 ACK → 服务器知道客户端能收</span></span></p></li></ul><div data-role="paragraph" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="color: #7f7f7f;font-size: 15px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">工程视角：三次握手的第三步（客户端的 ACK）是可以携带数据的。但在实际实现中，大多数客户端不会这么做，因为此时还不知道服务器的接收窗口等参数。另外，HTTP/2 的连接前言（preface）就是在第三次 ACK 之后立刻发送的。</span></span></p></div></div></div></div><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">4、SYN 洪水攻击与半连接队列</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">服务器收到 SYN 后，会把这条连接放入<span textstyle="" style="font-weight: bold">半连接队列（SYN Queue）</span>，并分配资源。如果攻击者大量发送 SYN 但不回复第三次 ACK，半连接队列就会被占满，正常请求无法建立连接。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">防御手段：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">SYN Cookies：服务器不分配资源，而是把连接信息编码到 seq 中发回，客户端回复 ACK 时再验证重建</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">调大 tcp_max_syn_backlog</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">开启 tcp_syncookies（Linux 默认在压力大时自动启用）</span></span></p></li></ul><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">四、数据传输：可靠交付与速率控制</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">连接建立之后，就进入了 TCP 最核心的部分：如何在不可靠的网络上实现可靠传输。</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">可靠性线：序列号、确认、重传 —— 怎么保证数据不丢、不乱</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">速率控制线：流量控制、拥塞控制 —— 怎么决定一次能发多快</span></span></p></li></ul><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">1、序列号与确认号：可靠的基石</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">TCP 把数据看成一串<span textstyle="" style="font-weight: bold">无结构的字节流</span>，每个字节都有一个编号。初始序列号（ISN）在握手时随机生成（不是从 0 开始，这是为了防止序列号冲突和安全问题）。</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">序列号（seq）：本报文段所发送数据的第一个字节的编号</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">确认号（ack）：期望收到对方下一个报文段的第一个字节的编号，意味着 &#34;这个编号之前的所有字节我都收到了&#34;</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这就是<span textstyle="" style="font-weight: bold">累计确认（Cumulative Acknowledgment）</span>机制。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.38819444444444445" data-type="jpeg" data-w="1440" data-imgfileid="100154234" src="https://wechat2rss.xlab.app/img-proxy/?k=3ad7d999&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYadJv8Fe7ud6aSGARVyjQ05RKh1s439Z0jCNDwOCByWM2uM50G1LTrq7ZS9wWJ8h05w1ibS8kQTxLJ4Meibiaz7hNNmdhRl5yAovA%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;"><span><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px; color: rgb(127, 127, 127)">图3 累计确认</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">举个例子：客户端发送了 seq=100，携带 20 字节数据。服务器回复 ack=120，意思是 &#34;100-119 我都收到了，下次从 120 开始发&#34;。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">2、超时重传：丢包了怎么办？</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">如果发送方发了数据，但迟迟没收到 ACK，就需要重传。但等多久才算 &#34;超时&#34;？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这就是 <span textstyle="" style="font-weight: bold">RTO（Retransmission TimeOut，重传超时时间）</span> 的计算问题。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">RTO 不是固定值，而是根据网络的 <span textstyle="" style="font-weight: bold">RTT（Round-Trip Time，往返时间）</span> 动态计算的。经典的 Jacobson 算法：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">SRTT ← (1 - α) × SRTT + α × RTT_sample (α 通常取 1/8)</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">RTTVAR ← (1 - β) × RTTVAR + β × |SRTT - RTT_sample| (β 通常取 1/4)</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">RTO = SRTT + 4 × RTTVAR</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">简单说：<span textstyle="" style="font-weight: bold">平滑的平均往返时间 + 4 倍的波动值。</span>网络越不稳定（RTT 波动大），RTO 就越大，避免不必要的重传。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">一旦超时重传，TCP 会执行一个激进的操作：<span textstyle="" style="font-weight: bold">把慢启动阈值 ssthresh 设为当前窗口的一半，然后 cwnd 降为 1，重新开始慢启动。</span>这就是 &#34;超时重传惩罚很重&#34; 的原因。</span></span></p><div data-role="paragraph" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="color: #7f7f7f;font-size: 15px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">工程视角：你可以用 ss -ti 命令查看每条 TCP 连接的 RTT、RTO、cwnd 等参数，这在排查 &#34;为什么我的连接这么慢&#34; 时非常有用。 ss -ti dst 10.0.0.1</span></span></p></div></div></div></div><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">3、快速重传：不用等超时</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">超时重传有个问题：RTO 通常至少几百毫秒，等超时再重传，延迟太高了。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">所以 TCP 还有<span textstyle="" style="font-weight: bold">快速重传（Fast Retransmit）</span>机制：如果发送方收到 <span textstyle="" style="font-weight: bold">3 个重复的 ACK</span>（即总共收到 4 个相同的 ack），就认为这个报文段丢了，<span textstyle="" style="font-weight: bold">不等超时直接重传。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">为什么是 3 个？因为 1-2 个重复 ACK 可能只是报文段乱序，3 个以上基本可以确定是丢包了。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">快速重传之后，不会像超时重传那样把 cwnd 降到 1，而是进入<span textstyle="" style="font-weight: bold">快恢复（Fast Recovery）</span>：cwnd 设为 ssthresh + 3（每个重复 ACK 代表一个包离开了网络），然后线性增长。具体我们在拥塞控制部分讲。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">4、滑动窗口：从 &#34;停等&#34; 到流水线</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">前面讲的确认和重传，解决的是 &#34;丢了怎么办&#34;。如果每发一个包就等一个 ACK，那效率太低了（这叫 &#34;停等协议&#34;）。TCP 用<span textstyle="" style="font-weight: bold">滑动窗口</span>实现流水线传输：发送方可以连续发送多个报文段而不必逐个等待确认，只要这些报文段都在窗口范围内。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.25507246376811593" data-type="jpeg" data-w="1035" data-imgfileid="100154236" src="https://wechat2rss.xlab.app/img-proxy/?k=e98d994a&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYatpJZM6jLN8WMXm9E0aB4uzZBLtFfKLtyobZvNUdVXlcicrzWrQqbA6VR9Wdyb4zHXSQ25SZperEAoYUvdCicvmtWNSDjMUfQH8%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;"><span><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px; color: rgb(127, 127, 127)">图4 滑动窗口</span></span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">收到新的 ACK → 窗口左边界右移（滑动）</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">接收方处理了数据 → 窗口右边界右移（窗口扩大）</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">窗口越大，同一时间在途的数据越多，吞吐量越高</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这里要明确一点：<span textstyle="" style="font-weight: bold">滑动窗口机制本身是可靠传输的效率优化</span>，它让 &#34;可靠交付&#34; 不再以 &#34;极低效率&#34; 为代价。但窗口到底能开多大？这不是滑动窗口自己决定的，而是由下面两个机制共同约束。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">5、流量控制：rwnd 防止淹没接收方</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">接收方在每个 ACK 中通过 Window 字段告诉发送方 &#34;我的接收缓冲区还剩多少空间&#34;，这就是<span textstyle="" style="font-weight: bold"> rwnd（接收窗口）</span>。发送方的发送窗口不能超过 rwnd。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">流量控制：端到端的速率匹配，防止发送方发太快导致接收方缓冲区溢出、数据被丢弃。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">当接收方处理不过来时，会把 rwnd 设为 0，发送方就停止发送。这就是<span textstyle="" style="font-weight: bold">零窗口探测（Zero Window Probe）</span>：发送方会定期发一个字节的探测包，看接收方窗口是否恢复。</span></span></p><div data-role="paragraph" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="color: #7f7f7f;font-size: 15px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">经典坑：糊涂窗口综合征（Silly Window Syndrome） 接收方每次只释放一点点缓冲区（比如 1 字节），发送方就发 1 字节的数据，导致网络上充斥着大量小包，效率极低。</span></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.32708333333333334" data-type="jpeg" data-w="1440" data-imgfileid="100154238" src="https://wechat2rss.xlab.app/img-proxy/?k=7292bf62&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYYJVEpKb9dMw9SiaVoLjlicG9nfiae1LJNJ88EqgiczRdzegiaEshwLVhTLQibzpO5jMMA5VPV577Pypgojkia3iaAjKjmwJ3txuDAicpicE%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;"><span><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px; color: rgb(127, 127, 127)">图5 糊涂窗口综合征</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">解决方法：接收方不要急于通知小窗口（等缓冲区够大了再通知），发送方用 Nagle 算法合并小包。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">6、拥塞控制：cwnd 防止淹没网络</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">流量控制是怕接收方扛不住，拥塞控制是怕<span textstyle="" style="font-weight: bold">网络</span>扛不住。这是 TCP 最精妙、也最复杂的部分。拥塞控制通过<span textstyle="" style="font-weight: bold"> cwnd（拥塞窗口）</span> 来控制发送速率，核心是四个算法：</span></span></p><p style="line-height:1.75;"><strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">1）慢启动（Slow Start）</span></span></strong></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">连接刚建立时，cwnd 从 1 个 MSS 开始，每收到一个 ACK，cwnd 加 1。结果就是<span textstyle="" style="font-weight: bold">每经过一个 RTT，cwnd 翻倍</span>（指数增长）。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">&#34;慢启动&#34; 其实一点也不慢，它是指数增长的。名字的由来是相对于之前没有拥塞控制时一上来就发满窗口而言的。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">当 cwnd 增长到<span textstyle="" style="font-weight: bold"> ssthresh（慢启动阈值）</span> 时，切换到拥塞避免。</span></span></p><p style="line-height:1.75;"><strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">2）拥塞避免（Congestion Avoidance）</span></span></strong></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">进入拥塞避免后，每经过一个 RTT，cwnd 只加 1（线性增长），而不是翻倍。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这就是 <span textstyle="" style="font-weight: bold">AIMD（Additive Increase, Multiplicative Decrease）</span> 算法：加性增、乘性减。出问题时大幅降窗口，没问题时慢慢加，最终让所有连接公平地共享带宽。</span></span></p><p style="line-height:1.75;"><strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">3）快重传（Fast Retransmit）</span></span></strong></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">前面讲过，收到 3 个重复 ACK 就重传，不等超时。</span></span></p><p style="line-height:1.75;"><strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">4）快恢复（Fast Recovery）</span></span></strong></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">快重传之后，不把 cwnd 降到 1 重新慢启动，而是：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">ssthresh = cwnd / 2</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">cwnd = ssthresh + 3</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">每收到一个重复 ACK，cwnd 加 1</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">收到新 ACK 后，cwnd = ssthresh，进入拥塞避免</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">整个拥塞控制的 cwnd 变化曲线大概长这样：</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.45344506517690875" data-type="jpeg" data-w="1074" data-imgfileid="100154240" src="https://wechat2rss.xlab.app/img-proxy/?k=f650cfc6&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYYyIDgFp3UkbamrJB3tO6WkDOSogkLsr80kZTiaYqHncoqP3dGV8l78MmHva42eelIR40dZfiaibcfKAXpymVWDQm1ibKicQ2575W7g%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;"><span><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px; color: rgb(127, 127, 127)">图6 拥塞控制的 cwnd 变化曲线</span></span></span></p><div data-role="paragraph" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="color: #7f7f7f;font-size: 15px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold">工程视角：</span>Linux 内核默认使用 <span textstyle="" style="font-weight: bold">CUBIC </span>拥塞控制算法（RFC 8312），而不是经典的 Reno。CUBIC 的窗口增长函数是三次曲线，在高带宽、长延迟的网络中表现更好。你可以用 sysctl net.ipv4.tcp_congestion_control 查看当前算法。</span></span></p></div></div></div></div><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">7、三者协作：一个公式收束</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">最后把可靠性线和速率控制线收束到一起：</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">实际发送窗口 = min(rwnd, cwnd)</span></span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">滑动窗口机制：提供了 &#34;可以连续发多少&#34; 的框架，是可靠传输的效率保障</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">rwnd（流量控制）：接收方说 &#34;我缓冲区还能收多少&#34;—— 端到端速率匹配</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">cwnd（拥塞控制）：网络状况说 &#34;你现在能发多少&#34;—— 全局速率匹配</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">取两者较小值，既不淹没接收方，也不淹没网络</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">所以准确地说：<span textstyle="" style="font-weight: bold">可靠传输（序列号 / 确认 / 重传）、流量控制、拥塞控制是 TCP 的三个并列核心功能</span>，它们通过滑动窗口机制协同工作，共同实现了 &#34;既可靠又高效&#34; 的数据传输。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">五、连接关闭：四次挥手与 TIME_WAIT 之谜</span></strong></span></p></div></div></div></div><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">1、为什么是四次？</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">数据传完了，要断开连接。因为 TCP 是全双工的，两个方向需要分别关闭，所以需要四次挥手：</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.7022332506203474" data-type="jpeg" data-w="1209" data-imgfileid="100154242" src="https://wechat2rss.xlab.app/img-proxy/?k=3cb768b7&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYb1OvvNjG4Hnh54eYCazzCf9GQObfL4rkfBiaAQWMUlfVV2vcwxfUiaGgNrZRYvomKj6ahQbvdH1WOENEkWSf0eETib6FQ4OjlTiaY%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;"><span><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px; color: rgb(127, 127, 127)">图7 TCP断连-四次挥手</span></span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">客户端发 FIN → 进入 FIN_WAIT_1</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">服务器回 ACK → 客户端进入 FIN_WAIT_2，服务器进入 CLOSE_WAIT</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">服务器发 FIN → 服务器进入 LAST_ACK</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">客户端回 ACK → 客户端进入 TIME_WAIT，服务器收到后进入 CLOSED</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">客户端等待 <span textstyle="" style="font-weight: bold">2MSL</span> 后进入 CLOSED</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">为什么中间的 ACK 和 FIN 不能合并成一次（像三次握手那样）？因为服务器收到客户端的 FIN 时，<span textstyle="" style="font-weight: bold">可能还有数据没发完</span>，所以只能先回 ACK，等数据发完了再发 FIN。这就是四次的由来。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">2、TIME_WAIT：为什么要等 2MSL？</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这是 TCP 中最著名的 &#34;为什么&#34;。客户端发完最后一个 ACK 后，不是直接关闭，而是要等待 <span textstyle="" style="font-weight: bold">2MSL（Maximum Segment Lifetime，报文最大生存时间）</span>。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">两个原因：</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">1）保证最后一个 ACK 能到达服务器。</span>如果这个 ACK 丢了，服务器会超时重发 FIN，客户端还有机会重发 ACK。如果客户端直接关闭了，服务器收不到 ACK 就会一直重传 FIN。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">2）让旧连接的报文在网络中消失。</span>防止上一次连接的残留报文被新连接（四元组相同）误收。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">MSL 在 RFC 中建议是 2 分钟，Linux 实际实现中通常是 30 秒（TCP_TIMEWAIT_LEN），所以 TIME_WAIT 大约持续 1 分钟。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">3、线上排障：CLOSE_WAIT 堆积</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">如果你的服务器上 CLOSE_WAIT 状态的连接大量堆积，说明<span textstyle="" style="font-weight: bold">服务器没有调用 close () 关闭连接。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">常见原因：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">应用层代码 bug，异常分支没关连接</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">连接池泄漏</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">对方关闭了连接，但你的程序还在等数据</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">排查命令：</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="shell"><code><span leaf=""><span class="code-snippet__meta prompt_">#</span> 查看各状态连接数 ss -ant | awk <span class="code-snippet__string">&#39;{print $1}&#39;</span> | <span class="code-snippet__built_in">sort</span> | <span class="code-snippet__built_in">uniq</span> -C  <span class="code-snippet__comment"># 查看 CLOSE_WAIT 连接的进程 ss -antp state close-wait</span> </span></code></pre></p><div data-role="paragraph" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="color: #7f7f7f;font-size: 15px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold">工程视角：</span>TIME_WAIT 过多通常不是问题（Linux 有 tcp_tw_reuse 等参数可以优化），但 CLOSE_WAIT 过多一定是应用层 bug。这两个不要搞混。</span></span></p></div></div></div></div><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">六、TCP 有限状态机：11 种状态全景</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">前面我们分别讲了三次握手和四次挥手，但如果你把它们拼在一起，会发现 TCP 连接的整个生命周期可以用一个<span textstyle="" style="font-weight: bold">有限状态机（Finite State Machine, FSM）</span>来精确描述。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">1、一张图记住状态机</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.5430555555555555" data-type="jpeg" data-w="1440" data-imgfileid="100154244" src="https://wechat2rss.xlab.app/img-proxy/?k=4285b3ec&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FgiamgWvCHDYbGQf6Cgw8hC4MU06O5UlGpjfzm3zh3XwUjxeoJEBbZYSOcibnfplfg0JYyWcwsYLZhzEzo79F3Lg654pNLvHiaY96Yk7h8BrLok%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;"><span><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px; color: rgb(127, 127, 127)">图8 状态机</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">核心就三个阶段：<span textstyle="" style="font-weight: bold">建立 → 传输 → 关闭</span>，每个阶段有几个中间状态。理解了 &#34;为什么需要这个中间状态&#34;（比如 TIME_WAIT 是为了等最后一个 ACK 和旧报文消失），就不需要死记硬背了。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">2、工程视角：用状态机排查线上问题</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">理解状态机最大的价值是<span textstyle="" style="font-weight: bold">排障</span>。状态机能让你从 &#34;记步骤&#34; 升级到 &#34;看全局&#34;—— 线上排障时，netstat/ss 看到一个异常状态，你立刻就能知道连接卡在了哪个环节、可能是什么原因。下面是几个经典场景：</span></span></p><p style="line-height:1.75;"><strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">场景一：CLOSE_WAIT 大量堆积</span></span></strong></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="bash"><code><span leaf="">ss -ant | awk <span class="code-snippet__string">&#39;{print $1}&#39;</span> | <span class="code-snippet__built_in">sort</span> | <span class="code-snippet__built_in">uniq</span> -C</span></code></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">如果 CLOSE_WAIT 有几千甚至几万个，<span textstyle="" style="font-weight: bold">100% 是应用层 bug</span>。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">状态机告诉我们：CLOSE_WAIT 的下一步是 LAST_ACK，触发条件是 &#34;应用层调用 close ()&#34;。连接卡在 CLOSE_WAIT，说明对方已经发了 FIN（对方关闭了连接），但你的程序收到 FIN 后没有调用 close()。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">常见原因：异常分支没关连接、连接池泄漏、线程阻塞在 read 上没机会执行 close。</span></span></p><p style="line-height:1.75;"><strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">场景二：SYN_RECV 大量堆积</span></span></strong></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">SYN_RCVD 状态的连接在半连接队列中。如果这个状态暴增，说明<span textstyle="" style="font-weight: bold">客户端只发了 SYN 但不回第三次 ACK</span>，这就是 SYN 洪水攻击的特征。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">排查：</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="shell"><code><span leaf=""><span class="code-snippet__meta prompt_">#</span> 查看半连接队列当前长度 ss -lnt | grep :80 <span class="code-snippet__comment"># Send-Q 列就是当前 SYN_RECV 数量，Recv-Q 是全连接队列 backlog</span></span></code></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">防御：开启 tcp_syncookies、调大 tcp_max_syn_backlog。</span></span></p><p style="line-height:1.75;"><strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">场景三：FIN_WAIT_2 大量堆积</span></span></strong></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">FIN_WAIT_2 是主动关闭方等对方 FIN 的状态。如果大量连接卡在这里，说明<span textstyle="" style="font-weight: bold">你发了 FIN，对方收到了并回了 ACK，但对方迟迟不发 FIN。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这通常意味着对方的应用层还在 CLOSE_WAIT（对方也有 bug），或者对方直接宕机了没来得及发 FIN。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Linux 有 tcp_fin_timeout 参数控制 FIN_WAIT_2 的超时，默认 60 秒，超时后内核会自动回收。</span></span></p><p style="line-height:1.75;"><strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">场景四：TIME_WAIT 过多</span></span></strong></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">TIME_WAIT 是正常状态，高并发短连接服务器上出现几万个 TIME_WAIT 是常见的，不一定是问题。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">但如果 TIME_WAIT 多到耗尽端口（客户端连接新服务器时没有可用端口），可以优化：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">net.ipv4.tcp_tw_reuse = 1：允许将 TIME_WAIT 的端口用于新的出站连接</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">net.ipv4.ip_local_port_range：调大可用端口范围</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">应用层用长连接替代短连接（根本解法）</span></span></p></li></ul><div data-role="paragraph" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="color: #7f7f7f;font-size: 15px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold">注意：</span>tcp_tw_recycle 已经在 Linux 4.12 中被移除了，不要再用这个参数。</span></span></p></div></div></div></div><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">七、包解析（Wireshark 实战）</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">说了这么多理论，不如抓一次包来得直观。下面我们用 tcpdump 抓包，再用 Wireshark 分析一次完整的 HTTP 请求。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">1、抓包命令</span></strong></span></p></div></div></div><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="bash"><code><span leaf=""><span class="code-snippet__comment"># 抓取 80 端口的 TCP 包，保存到文件 </span></span></code><br/><code><span leaf=""><span class="code-snippet__built_in">sudo</span> tcpdump -i any -s 0 -w http_capture.pcap <span class="code-snippet__string">&#39;tcp port 80&#39;</span>  </span></code><br/><code><span leaf=""><span class="code-snippet__comment"># 或者实时查看简要信息 </span></span></code><br/><code><span leaf=""><span class="code-snippet__built_in">sudo</span> tcpdump -i any -nn <span class="code-snippet__string">&#39;tcp port 80&#39;</span></span></code><br/></pre></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">2、TCP 首部字段解读</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">一个标准的 TCP 首部（20 字节，不含选项）：</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.4076388888888889" data-type="jpeg" data-w="1440" data-imgfileid="100154246" src="https://wechat2rss.xlab.app/img-proxy/?k=2ebb06af&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYaIoLScXgH9rBvUwAb8XxJOmEice9O9LWk3cNXj3VDNsdtxy6ktLf4REib1QFV5ejicibHHuNuf6ibHEQHqzsK7dIPd0mnTh3tGdtEA%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;"><span><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px; color: rgb(127, 127, 127)">图9 TCP 字段解读</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">6 个标志位</span>是抓包分析的重点：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">SYN：同步序列号，建立连接时置 1</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">ACK：确认号有效，连接建立后通常都置 1</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">FIN：发送方数据发完，请求关闭连接</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">RST：复位连接，异常情况使用</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">PSH：推送，接收方应立即交给应用层</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">URG：紧急指针有效</span></span></p></li></ul><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">3、完整抓包序列分析</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">一次 curl HTTP://example.com 的抓包大概长这样：</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.45069444444444445" data-type="jpeg" data-w="1440" data-imgfileid="100154248" src="https://wechat2rss.xlab.app/img-proxy/?k=1a00402e&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FgiamgWvCHDYb9G5r7xZeWtO0QBmOiaEMgQDdYNJPkibCVKzqp8tYI7FazgCYSQDVn9J2JeHFhk0l43vmHaT7o6ibXtS5hh2qLCqqNnplxsnkjGU%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;"><span><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px; color: rgb(127, 127, 127)">图10 抓包解析</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">观察序列号的变化：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">第 1 包 SYN，seq=0（Wireshark 显示的是相对序列号，实际 ISN 是随机值）</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">第 2 包 SYN+ACK，ack=1（SYN 消耗一个序列号）</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">第 4 包发了 77 字节数据，seq=1</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">第 5 包 ack=78（1+77，确认了所有数据）</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">第 9 包 FIN，seq=78</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">第 10 包 ack=79（FIN 也消耗一个序列号）</span></span></p></li></ul><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">4、实用 Wireshark 过滤技巧</span></strong></span></p></div></div></div><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="python"><code><span leaf=""><span class="code-snippet__comment"># 只看握手和挥手包 </span></span></code><br/><code><span leaf="">tcp.flags.syn == <span class="code-snippet__number">1</span> <span class="code-snippet__keyword">or</span> tcp.flags.fin == <span class="code-snippet__number">1</span>  </span></code><br/><code><span leaf=""><span class="code-snippet__comment"># 找重传包（排查网络质量） </span></span></code><br/><code><span leaf="">tcp.analysis.retransmission  </span></code><br/><code><span leaf=""><span class="code-snippet__comment"># 找零窗口（排查接收方处理能力） </span></span></code><br/><code><span leaf="">tcp.analysis.zero_window  </span></code><br/><code><span leaf=""><span class="code-snippet__comment"># 跟踪一条 TCP 流（看完整的请求响应）</span></span></code><br/><code><span leaf=""> 右键 → Follow → TCP Stream</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">教一个实用技巧：<span textstyle="" style="font-weight: bold">用 tcp.flags.syn==1 过滤握手包，用 tcp.analysis.retransmission 找重传</span></span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">八、复盘总结</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">TCP 是一个设计极其精妙的协议。从 1981 年 RFC 793 诞生至今，四十多年过去了，它依然是互联网的基石。看似简单的 &#34;序列号 + 确认 + 重传 + 窗口&#34;，背后是对 &#34;如何在不可靠网络上构建可靠服务&#34; 这个问题的深刻回答。</span></span></p><div data-role="paragraph" data-pm-slice="0 0 []"><div data-tools="135编辑器" data-id="85988" data-color="#138bde" data-custom="#138bde" style=""><div style="margin: 0px auto;padding: 0px;border: none;display: inline-block;width: 100%;max-width: 100% !important;box-sizing:border-box;" data-width="100%"><p style="margin: 0px;padding: 0px;font-size: 18px;letter-spacing: -2px;display: inline-block;box-sizing: border-box;font-family:sans-serif;"><span style="font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span style="color: #138bde;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: #138bde;opacity: 0.7;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: #138bde;opacity: 0.5;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: #138bde;opacity: 0.3;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span></strong></span></p><div style="margin-left: 10px;color: #138bde;display: inline-block;"><p data-brushtype="text" style="font-size: 16px;color: inherit;margin-top: 0px;margin-bottom: 0px;"><span style="font-family:Helvetica Neue, Helvetica, Hiragino Sans GB, Apple Color Emoji, Emoji Symbols Font, Segoe UI Symbol, Arial, sans-serif;"><strong><span leaf="">参考资料</span></strong></span></p></div></div></div><p data-role="list"><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p><span style="font-size: 12px;color: #7f7f7f;"><span leaf="">RFC 793（TCP 基础规范）</span></span></p></li><li><p><span style="font-size: 12px;color: #7f7f7f;"><span leaf="">RFC 5681（拥塞控制）</span></span></p></li><li><p><span style="font-size: 12px;color: #7f7f7f;"><span leaf="">RFC 8312（CUBIC）</span></span></p></li><li><p><span style="font-size: 12px;color: #7f7f7f;"><span leaf="">《TCP/IP 详解 卷 1》</span></span></p></li></ul></p></div></div><div data-role="paragraph" style="font-family:sans-serif;"><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">作者丨知乎用户琳</span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;text-align: left;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">来源丨网址：<a href="https://zhuanlan.zhihu.com/p/2075189264237838600?share_code=1m79xxjYIs8Gi&amp;utm_psn=2083502236529865818" target="_blank">https://zhuanlan.zhihu.com/p/2075189264237838600?share_code=1m79xxjYIs8Gi&amp;utm_psn=2083502236529865818</a></span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">dbaplus社群欢迎广大技术人员投稿，投稿邮箱：</span></span><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">editor@dbaplus.cn</span></span></p><p class="custom_select_card_wrp mp_profile_iframe_wrp" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-service_type="1" data-verify_status="2"></mp-common-profile></p><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.07777777777777778" data-s="300,640" data-w="1080" type="block" data-imgfileid="100130225" src="https://wechat2rss.xlab.app/img-proxy/?k=f32823a4&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FufWcjcomw8Zf2jiaBBH3vdgfP4A2rem5YEAHYH074dc4GibhojA5B3lLZrXLDRciaVnficveaHcAUCiaIPoDsTkAduA%2F640%3Fwx_fmt%3Dpng"/></p></div></div><p style="display: none;"><mp-style-type data-value="3"></mp-style-type></p>



<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=db7e1294&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzkzMjYzNjkzNw%3D%3D%26mid%3D2247638291%26idx%3D1%26sn%3Dff78e879ca585cb892c696f689dd4ecc">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Wed, 28 Oct 2026 07:15:00 +0800</pubDate>
    </item>
    <item>
      <title>AI原生数据库落地核心系统：多模协同、语义检索与性能验证</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzkzMjYzNjkzNw==&amp;mid=2247638290&amp;idx=1&amp;sn=17845a2525fb06d84897938012a4c708</link>
      <description>海量数据联合产学研伙伴探讨未来数据库升级路径，并发布海量数据库“向标联合”“多模协同”两项能力升级。</description>
      <content:encoded><![CDATA[<p><span>海量数据</span> <span>2026-10-27 07:15</span> <span style="display: inline-block;">广东</span></p>






  
  <p><img src="https://wechat2rss.xlab.app/img-proxy/?k=ee656701&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYaicl8INwWwPcTqsoPtOycb59mUghYImaK21YAmD3sbluMZQUkorfvOQvndWrmHTrNxw3zQN1jabhVjmIQvvHmetmkeGibkPzejY%2F0%3Fwx_fmt%3Djpeg"/></p>
  <p>海量数据联合产学研伙伴探讨未来数据库升级路径，并发布海量数据库“向标联合”“多模协同”两项能力升级。</p>
  <div data-role="outer" label="edit by 135editor" data-tplid="295085" data-pm-slice="0 0 []"><div data-tools="135编辑器" data-id="us-3745001"><div style="box-sizing: border-box;padding:0 5px;"><div data-role="paragraph" style=""><div data-role="paragraph" style=""><div data-tools="135编辑器" data-id="us-4110356"><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="" data-pm-slice="1 1 [&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;outer&#34;,&#34;label&#34;:&#34;edit by 135editor&#34;,&#34;data-tplid&#34;:&#34;295085&#34;,&#34;data-pm-slice&#34;:&#34;0 0 []&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-tools&#34;:&#34;135编辑器&#34;,&#34;data-id&#34;:&#34;us-3745001&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;style&#34;:&#34;box-sizing: border-box;padding:0 5px;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;paragraph&#34;,&#34;style&#34;:&#34;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;paragraph&#34;,&#34;style&#34;:&#34;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;paragraph&#34;,&#34;style&#34;:&#34;font-family:sans-serif;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;p&#34;,&#34;attributes&#34;:{&#34;style&#34;:&#34;line-height: 1.75em;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;node&#34;,{&#34;tagName&#34;:&#34;span&#34;,&#34;attributes&#34;:{&#34;style&#34;:&#34;font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: \&#34;Helvetica Neue\&#34;, Helvetica, \&#34;Hiragino Sans GB\&#34;, \&#34;Apple Color Emoji\&#34;, \&#34;Emoji Symbols Font\&#34;, \&#34;Segoe UI Symbol\&#34;, Arial, sans-serif;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;}]">10月24日，<span textstyle="" style="font-weight: bold;">海量数据 1024 开发者日暨产品发布会</span>圆满落幕。发布会围绕<span textstyle="" style="font-weight: bold;">“面向下一代 AI 原生应用的数据基座”</span>，联合产学研伙伴，共同探讨未来数据库升级路径。同时发布了海量数据库<span textstyle="" style="font-weight: bold;">向标联合、多模协同</span>两项重磅能力升级。</span></span></p></div><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">开场：AI 原生应用爆发，数据库迎来全新挑战</span></strong></span></p></div></div></div></div><div data-role="paragraph"><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">海量数据董事长、总裁肖枫在致辞中表示：当前，<span textstyle="" style="font-weight: bold;">人工智能</span>已成为全社会关注的核心关键词，AI应用正加速渗透。数据库作为AI应用的数据底座，如何顺应“AI时代”的发展要求，是数据库产业的必答题。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">肖枫特邀产学研伙伴，探讨面对下一代AI原生应用的数据库演进方向。</span></span></p><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.562962962962963" data-s="300,640" data-type="png" data-w="1080" style="width:100%;" type="block" data-backw="568" data-backh="320" data-imgfileid="100154635" src="https://wechat2rss.xlab.app/img-proxy/?k=79f32fa8&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYa1HiaUxMgDq0Rv1eCFd7kOMEb67juOzCxoXOgaqC9j4kVIicicDEbavicYuzvlwkzkPLUdTFicEyw5l8cIsTtLc97gdKfVDWKfeoRM%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="box-sizing: border-box;padding: 0px 5px;text-align: center;line-height: 1.75em;"><span leaf="" style="font-size: 15px;letter-spacing: normal;color: rgb(127, 127, 127);font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span textstyle="" style="font-size: 12px;">海量数据董事长、总裁 肖枫</span></span></p></div><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">圆桌：产学研对话，共议AI原生数据库演进方向</span></strong></span></p></div></div></div></div><div data-role="paragraph"><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">围绕数据库的演进，IDC 中国王楠、清华大学教授、数据智能北京市重点实验室主任李国良、海量数据董事长、总裁肖枫、数智引航产品总监王养浩展开了精彩的四方圆桌讨论。</span></span></p><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img" data-aistatus="1" data-backh="320" data-backw="568" data-imgfileid="100154637" data-ratio="0.562962962962963" data-s="300,640" type="block" data-type="png" data-w="1080" style="width:100%;" src="https://wechat2rss.xlab.app/img-proxy/?k=0c9818d7&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FgiamgWvCHDYaGur7ib0zDb3cBYNRpIKAK4wTllogObEugpFeQlU4NDDc3rUCXlGb6qd3Hqnc1WmwyuTE6Va9TFxCP0arkKFdiaAHEeianeVZ55w%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">王楠</span>指出，根据IDC的观察，2025年-2030年，中国AI数据基础设施正在以每年37.7%的复合增速增长，一个巨大的AI数据基础设施市场正在形成。市场越大、底层数据支撑的压力越大。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">数据库不能只增加一个新功能，<span textstyle="" style="font-weight: bold;">更要在稳定支撑核心业务的同时，处理更复杂的数据和更高的计算要求。</span></span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.562962962962963" data-w="1080" style="-webkit-tap-highlight-color:rgba(0, 0, 0, 0);margin:0px;padding:0px;outline:0px;color:rgba(0, 0, 0, 0.9);font-family:&#34;PingFang SC NEW&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size:16px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:0.544px;orphans:2;text-align:start;text-indent:0px;text-transform:none;widows:2;word-spacing:0px;-webkit-text-stroke-width:0px;white-space:normal;background-color:rgb(255, 255, 255);text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;user-select:auto;width:100%;" data-backw="568" data-backh="320" src="https://wechat2rss.xlab.app/img-proxy/?k=89e294ad&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2F1m9MiaQX6yIYwJqAxHCF6jXffDbDwj6kRlXjuApxlPh4qfQdP1HBzyOfX7EMroxEaPwANUCOe8ibS0Aic8qDld3g8nyIAsTSzVPMMjRSFEp2nM%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></span></p><p style="box-sizing: border-box;padding: 0px 5px;text-align: center;line-height: 1.75em;"><span leaf="" style="font-size: 15px;letter-spacing: normal;color: rgb(127, 127, 127);font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span textstyle="" style="font-size: 12px;">IDC 中国 王楠</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">李国良</span>认为，数据库正在从“存储和查询数据的系统”，演变为<span textstyle="" style="font-weight: bold;">“支撑智能体感知、记忆、推理与行动的数据底座”</span>。这很可能是继分布式和云原生之后，数据库发展的下一个重要阶段。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">他概括了在AI与Agent时代，数据库应该具备的六大特征：<span textstyle="" style="font-weight: bold;">多模态处理、自然语言交互、语义事务、细粒度弹性伸缩、长短期记忆和安全治理。</span></span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.562962962962963" data-w="1080" style="-webkit-tap-highlight-color:rgba(0, 0, 0, 0);margin:0px;padding:0px;outline:0px;color:rgba(0, 0, 0, 0.9);font-family:&#34;PingFang SC NEW&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size:16px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:0.544px;orphans:2;text-align:start;text-indent:0px;text-transform:none;widows:2;word-spacing:0px;-webkit-text-stroke-width:0px;white-space:normal;background-color:rgb(255, 255, 255);text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;user-select:auto;width:100%;" data-backw="568" data-backh="320" src="https://wechat2rss.xlab.app/img-proxy/?k=e646371e&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F1m9MiaQX6yIZhApO8pw14BicAIIw9zDnKGOFCyjh2gGWHCzqHk3bJpkyeHJ9WcpTlEviboFM8RBiaEhWwGXJEhrrWQCGEYrI5HbZPwiaSQZMBTrg%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></span></p><p style="box-sizing: border-box;padding: 0px 5px;text-align: center;line-height: 1.75em;"><span leaf="" style="font-size: 15px;letter-spacing: normal;color: rgb(127, 127, 127);font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span textstyle="" style="font-size: 12px;">清华大学教授、数据智能北京市重点实验室主任 李国良    </span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">肖枫</span>认为，企业数据库的AI化改造应在兼顾改造复杂度、投入成本与应用价值的前提下，实现平滑、无感的升级。不应该再建一套彼此割裂的数据体系。因此，数据库需要<span textstyle="" style="font-weight: bold;">既承接原有业务条件和规则，也要让应用理解新的语义需求。</span></span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">海量数据库将全力搭建好<span textstyle="" style="font-weight: bold;">面向下一代AI原生应用的桥梁。</span></span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.562962962962963" data-w="1080" style="-webkit-tap-highlight-color:rgba(0, 0, 0, 0);margin:0px;padding:0px;outline:0px;color:rgba(0, 0, 0, 0.9);font-family:&#34;PingFang SC NEW&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size:16px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:0.544px;orphans:2;text-align:start;text-indent:0px;text-transform:none;widows:2;word-spacing:0px;-webkit-text-stroke-width:0px;white-space:normal;background-color:rgb(255, 255, 255);text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;user-select:auto;width:100%;" data-backw="568" data-backh="320" src="https://wechat2rss.xlab.app/img-proxy/?k=29b97aa9&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2F1m9MiaQX6yIbg5Saj9SZ0HibCsic5Y9UiaKulVJMXg8ibtO1eXcFpz4GNo4PtGp3Jp0a0IZqddUsZiaib8ljAkJU5evcTkh2mhY99EjEKwrubhrmyg%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></span></p><p style="box-sizing: border-box;padding: 0px 5px;text-align: center;line-height: 1.75em;"><span leaf="" style="font-size: 15px;letter-spacing: normal;color: rgb(127, 127, 127);font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span textstyle="" style="font-size: 12px;">海量数据董事长、总裁 肖枫</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">王养浩</span>结合金融投研与智能投顾场景，指出<span textstyle="" style="font-weight: bold;">AI必须融入现有业务体系</span>，数据底座需要支持多模态数据关联、增量数据一致性和高效在线查询。数智引航的向量数据库产品VexDB，通过向量存储和检索引擎，打造了AI数据的统一底座。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.562962962962963" data-w="1080" style="-webkit-tap-highlight-color:rgba(0, 0, 0, 0);margin:0px;padding:0px;outline:0px;color:rgba(0, 0, 0, 0.9);font-family:&#34;PingFang SC NEW&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size:16px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:0.544px;orphans:2;text-align:start;text-indent:0px;text-transform:none;widows:2;word-spacing:0px;-webkit-text-stroke-width:0px;white-space:normal;background-color:rgb(255, 255, 255);text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;user-select:auto;width:100%;" data-backw="568" data-backh="320" src="https://wechat2rss.xlab.app/img-proxy/?k=5dbcf02d&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2F1m9MiaQX6yIYg8LTYa4SMlZ4GiaVuTAlAlL0nERcCz2RQ28p4aDJHePVH5pIp09SicB5uK52dahicrgnhCVNrbbzfEPwSMHHBxAwia6rSLp2IZcc%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></span></p><p style="box-sizing: border-box;padding: 0px 5px;text-align: center;line-height: 1.75em;"><span leaf="" style="font-size: 15px;letter-spacing: normal;color: rgb(127, 127, 127);font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span textstyle="" style="font-size: 12px;">数智引航产品总监 王养浩</span></span></p></div><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">海量数据产品升级：多模原生 融算一体</span></strong></span></p></div></div></div></div><div data-role="paragraph"><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">海量数据产品经理<span textstyle="" style="font-weight: bold;">黄薇</span>以“多模原生、融算一体”为主线，发布海量数据库<span textstyle="" style="font-weight: bold;">向标联合、多模协同</span>两项能力升级，两项能力共同推动数据库从数据承载平台向智能数据基座演进。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.562962962962963" data-w="1080" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);margin: 0px;padding: 0px;outline: 0px;color: rgba(0, 0, 0, 0.9);font-family: &#34;PingFang SC NEW&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: 0.544px;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;user-select: auto;" src="https://wechat2rss.xlab.app/img-proxy/?k=59229127&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F1m9MiaQX6yIZmC0MSG4tPqlUFPRJt3yjS1CRFnjibAwlfazrkuGEV7VU5FQAWoZak0OYzibic2mlmcRAKeGl7Fm406Lw6yfWdVZJSib2SxTtVCt4%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text" style="line-height: 1.75em;"><span style="color: rgb(19, 139, 222);"><strong><span leaf="">向标联合</span></strong></span></p></div></div></div><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">通过推动语义检索与业务查询高效协同，在经过向标联合的海量数据库中，<span textstyle="" style="font-weight: bold;">一条SQL</span>就能完成病例语义匹配、多表关联、业务筛选和结果排序，并由数据库统一优化执行路径。在400万病例量级的医疗康复知识库应用中，<span textstyle="" style="font-weight: bold;">响应延迟降低46%、效率提升1倍。</span></span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.562962962962963" data-w="1080" style="-webkit-tap-highlight-color:rgba(0, 0, 0, 0);margin:0px;padding:0px;outline:0px;color:rgba(0, 0, 0, 0.9);font-family:&#34;PingFang SC NEW&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size:16px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:0.544px;orphans:2;text-align:start;text-indent:0px;text-transform:none;widows:2;word-spacing:0px;-webkit-text-stroke-width:0px;white-space:normal;background-color:rgb(255, 255, 255);text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;user-select:auto;width:100%;" data-backw="568" data-backh="320" src="https://wechat2rss.xlab.app/img-proxy/?k=76d8c6b4&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2F1m9MiaQX6yIYAxxcOaFlGTgMMdBCqpicBmxGV43dgCcF3sDVbVUc6FVgWdOJaBhOIyGmVeVhSib4kkiaQUvyONsGdP0iceWoyOze4ibyMj8vXrfG4%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text" style="line-height: 1.75em;"><span style="color: rgb(19, 139, 222);"><strong><span leaf="">多模协同</span></strong></span></p></div></div></div><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">通过执行策略与资源调度优化，提升多类计算的协作效率。海量数据库在多模协同计算方面获得大幅性能提升，“融算一体”在大规模、高并发的复杂计算链路下，依然保持<span textstyle="" style="font-weight: bold;">高性能</span>与<span textstyle="" style="font-weight: bold;">低资源消耗</span>，形成面向生产环境的持续承载能力，推动多模态能力在核心生产系统中规模化落地。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">在百万级混合检索测试</span></span><span style="box-sizing: border-box;line-height: 1.75em;font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;">中，<span textstyle="" style="font-weight: bold;">QP</span></span></span><span leaf="" style="box-sizing: border-box;line-height: 1.75em;font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span textstyle="" style="font-weight: bold;">S 超过1万、召回率稳定超过99%。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.562962962962963" data-w="1080" style="-webkit-tap-highlight-color:rgba(0, 0, 0, 0);margin:0px;padding:0px;outline:0px;color:rgba(0, 0, 0, 0.9);font-family:&#34;PingFang SC NEW&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size:16px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:0.544px;orphans:2;text-align:start;text-indent:0px;text-transform:none;widows:2;word-spacing:0px;-webkit-text-stroke-width:0px;white-space:normal;background-color:rgb(255, 255, 255);text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;user-select:auto;width:100%;" data-backw="568" data-backh="320" src="https://wechat2rss.xlab.app/img-proxy/?k=ed10d505&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2F1m9MiaQX6yIbib4xF4fNWqcT37WNo4VGAv6xhNoviam2KiaYDzAWm9QBFwPw4Lq3Pp76gpVVp3iaeBeen9HUdfsQhiazGwicfCjLPbBKZdQxczeC0k%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></span></p><p style="box-sizing: border-box;padding: 0px 5px;text-align: center;line-height: 1.75em;"><span leaf="" style="font-size: 15px;letter-spacing: normal;color: rgb(127, 127, 127);font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span textstyle="" style="font-size: 12px;">海量数据产品经理 黄薇</span></span></p></div><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">数智引航产品升级：从分布式扩展到轻量化部署，VexDB打造面向AI应用的数据底座</span></strong></span></p></div></div></div></div><div data-role="paragraph"><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">数智引航首席专家<span textstyle="" style="font-weight: bold;">孙佶</span>介绍了VexDB在分布式架构与轻量化部署方面的进展。</span></span></p><p style="line-height: 1.75em;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.562962962962963" data-w="1080" style="-webkit-tap-highlight-color:rgba(0, 0, 0, 0);margin:0px;padding:0px;outline:0px;color:rgba(0, 0, 0, 0.9);font-family:&#34;PingFang SC NEW&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size:16px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:0.544px;orphans:2;text-align:start;text-indent:0px;text-transform:none;widows:2;word-spacing:0px;-webkit-text-stroke-width:0px;white-space:normal;background-color:rgb(255, 255, 255);text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;user-select:auto;width:100%;" data-backw="568" data-backh="320" src="https://wechat2rss.xlab.app/img-proxy/?k=99a1916a&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F1m9MiaQX6yIbaWrLvpIURL8LAlA26BnjOFTsibib7LHHRBFAOgiaQFA9J5uZia3pxoIFgo243kjfQK2Yib5hWGrnfCibEiayedfzIQLD8lRrGtuia5NM%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">分布式VexDB支持数据分片、并行计算、弹性扩容和高可用容灾。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">测试中，三节点在20并发下QPS由约1300增至3200，索引创建最高加速3.47倍；通过异步索引更新机制，写入吞吐最高提升<span textstyle="" style="font-weight: bold;">10倍</span>，新数据<span textstyle="" style="font-weight: bold;">毫秒级</span>可查。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">面向本地及端侧应用，VexDB-Lite可通过插件嵌入PostgreSQL、DuckDB、SQLite，并利用图挂桶、子图分割技术降低存储与内存开销。</span></span></p><p style="line-height: 1.75em;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.562962962962963" data-w="1080" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);margin: 0px;padding: 0px;outline: 0px;color: rgba(0, 0, 0, 0.9);font-family: &#34;PingFang SC NEW&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: 0.544px;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;user-select: auto;" src="https://wechat2rss.xlab.app/img-proxy/?k=05453b29&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2F1m9MiaQX6yIZzXcBuN8h7ef1johx0BBEXE4vJEPDYSMr7smctlTfEia49icicRzibRssFVib6LTONX95q7sx7hwGpQ1EvBw4gibV4P1Gqkq3jR4ibTM%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></p><p style="box-sizing: border-box;padding: 0px 5px;text-align: center;line-height: 1.75em;"><span leaf="" style="font-size: 15px;letter-spacing: normal;color: rgb(127, 127, 127);font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span textstyle="" style="font-size: 12px;">数智引航首席专家 孙佶</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">在安防视觉智能场景中，VexDB支持单节点承载10亿以上数据、15分钟写入3000万以上数据，分布式查询延迟低于500毫秒。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">孙佶强调，数据库技术应在真实生产环境中验证，适应不同规模与资源条件下的业务需求。</span></span></p><div data-tools="135编辑器" data-id="85988" data-color="#138bde" data-custom="#138bde" style="font-family: sans-serif;text-align: center;" data-pm-slice="0 0 []"><div style="max-width:100% !important;margin:0 auto;padding: 0;border:none;display:inline-block;width:100%;box-sizing:border-box;" data-width="100%"><p style="margin:0;padding:0;font-size:18px;letter-spacing:-2px;display: inline-block;box-sizing:border-box;"><span style="font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span style="color: #138bde;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: #138bde;opacity: 0.7;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: #138bde;opacity: 0.5;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: #138bde;opacity: 0.3;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span></strong></span></p></div></div><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">从圆桌到产品发布，本次发布会始终围绕一个议题：<span textstyle="" style="font-weight: bold;">国产数据库的AI原生升级之路，最终要落实到应用效果、运行效率和使用成本上。</span></span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">为此，海量数据将持续加大研发投入，依托<span textstyle="" style="font-weight: bold;">数据智能北京市重点实验室，</span>携手数智引航等伙伴推进核心技术攻关，将前沿研究转化为能够支撑真实业务的产品能力。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">放眼人类计算产业的历史，基础软件的格局从未像今天这样面临重塑的可能，海量数据库的所有努力，都是为了在AI时代筑牢国产基础软件的核心底座，以底层实力决胜顶层竞争。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">数据库的进步，离不开基础软件开发者们的长期投入。值此1024程序员节，<span textstyle="" style="font-weight: bold;">海量数据向每一位奋斗在研发一线的开发者致敬！</span></span></span></p><p class="mp_profile_iframe_wrp" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="海量数据库" data-alias="vastdata1" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/4rwKYaRU8dZtAFnCPp5EHkdapPdZpoCicyqrPERYzRRec1OS5FAbJvCItmhY8EreqrjBuibcetauTfic9uLOTjosg/0?wx_fmt=png" data-signature="北京海量数据技术股份有限公司，2007年成立，致力于开发提高硬件效率的数据库，已成为国产企业级数据库的首选品牌之一。" data-id="MzAwMTYxNDU4Ng==" data-is_biz_ban="0" data-servicetype="0" data-verify_status="2"></mp-common-profile></p></div></div></div></div></div></div><p style="box-sizing: border-box;padding: 0px 5px;line-height: 1.75em;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span textstyle="" style="color: rgb(19, 139, 237);font-weight: bold;">↓↓点击获取本期内容直播回放</span></span></p><p style="display: none;"><mp-style-type data-value="3"></mp-style-type></p>


<p><a href="https://weixin.qq.com/sph/AU71X7saJ">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=058a0df1&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzkzMjYzNjkzNw%3D%3D%26mid%3D2247638290%26idx%3D1%26sn%3D17845a2525fb06d84897938012a4c708">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Tue, 27 Oct 2026 07:15:00 +0800</pubDate>
    </item>
    <item>
      <title>HAVING 只能配合 GROUP BY？这个SQL误区害了多少人……</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzkzMjYzNjkzNw==&amp;mid=2247638290&amp;idx=2&amp;sn=24f3a621db15e10eaed2321d045fb98e</link>
      <description>集合论是 SQL 语言的根基，只有从集合的角度来思考，才能明白 SQL 的强大威力。</description>
      <content:encoded><![CDATA[<p><span>dbaplus社群</span> <span>2026-10-27 07:15</span> <span style="display: inline-block;">广东</span></p>






  
  <p><img src="https://wechat2rss.xlab.app/img-proxy/?k=5595607e&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYbxSxEzVgYmdIqTuSyeEYSLcHA2t1rE77AYr9mhxF2O7UKuolZmlebgp6rc2rVyCzp4qrPbXicxoHOYfia4WicZhAgvHleSY7PWmo%2F0%3Fwx_fmt%3Djpeg"/></p>
  <p>集合论是 SQL 语言的根基，只有从集合的角度来思考，才能明白 SQL 的强大威力。</p>
  <p class="mp_profile_iframe_wrp" style="margin-bottom: 0px;" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-service_type="1" data-verify_status="2"></mp-common-profile></p><div data-role="outer" label="edit by 135editor" data-pm-slice="0 0 []"><div data-role="paragraph"><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">一、HAVING 回顾</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">关于 SQL 中的 HAVING，相信大家都不陌生，它往往与 GROUP BY 配合使用，为聚合操作指定条件，例如：</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="sql"><code><span leaf=""><span class="code-snippet__keyword">SELECT</span> name, <span class="code-snippet__built_in">COUNT</span>(<span class="code-snippet__operator">*</span>) <span class="code-snippet__keyword">FROM</span> <span class="code-snippet__keyword">table</span> <span class="code-snippet__keyword">GROUP</span> <span class="code-snippet__keyword">BY</span> name <span class="code-snippet__keyword">HAVING</span> <span class="code-snippet__built_in">COUNT</span>(<span class="code-snippet__operator">*</span>) <span class="code-snippet__operator">&gt;</span> <span class="code-snippet__number">2</span></span></code></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">说到指定条件，我们最先想到的往往是 WHERE 子句，但 WHERE 子句只能指定行的条件，而不能指定组的条件。</span></span></p><div data-role="paragraph" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="color: #7f7f7f;font-size: 15px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">集合论是 SQL 语言的根基，它里面有个阶的概念，我们必须掌握，具体可查看：神奇的 SQL 之层级 → 为什么 GROUP BY 之后不能直接引用原表中的列。</span></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">所以就有了 HAVING 子句，用来指定组的条件，我们来看案例。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">现有学生班级表 tbl_student_class 以及数据：</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="java"><code><span leaf="">CREATE <span class="code-snippet__type">TABLE</span> <span class="code-snippet__title">tbl_student_class</span> <span class="code-snippet__params">(</span></span></code><br/><code><span leaf="">  id <span class="code-snippet__type">int</span>(<span class="code-snippet__number">8</span>) unsigned NOT NULL AUTO_INCREMENT COMMENT <span class="code-snippet__string">&#39;自增主键&#39;</span>,</span></code><br/><code><span leaf="">  <span class="code-snippet__type">sno</span> <span class="code-snippet__title">varchar</span><span class="code-snippet__params">(</span><span class="code-snippet__params"><span class="code-snippet__number">12</span></span><span class="code-snippet__params">)</span> NOT NULL COMMENT <span class="code-snippet__string">&#39;学号&#39;</span>,</span></code><br/><code><span leaf="">  <span class="code-snippet__type">cno</span> <span class="code-snippet__title">varchar</span><span class="code-snippet__params">(</span><span class="code-snippet__params"><span class="code-snippet__number">5</span></span><span class="code-snippet__params">)</span> NOT NULL COMMENT <span class="code-snippet__string">&#39;班级号&#39;</span>,</span></code><br/><code><span leaf="">  <span class="code-snippet__type">cname</span> <span class="code-snippet__title">varchar</span><span class="code-snippet__params">(</span><span class="code-snippet__params"><span class="code-snippet__number">50</span></span><span class="code-snippet__params">)</span> NOT NULL COMMENT <span class="code-snippet__string">&#39;班级名&#39;</span>,</span></code><br/><code><span leaf="">  <span class="code-snippet__type">PRIMARY</span> <span class="code-snippet__title">KEY</span> <span class="code-snippet__params">(id)</span></span></code><br/><code><span leaf="">) ENGINE=InnoDB <span class="code-snippet__type">DEFAULT</span> <span class="code-snippet__variable">CHARSET</span><span class="code-snippet__operator">=</span><span class="code-snippet__type">utf8</span> <span class="code-snippet__variable">COMMENT</span><span class="code-snippet__operator">=</span><span class="code-snippet__string">&#39;学生班级表&#39;</span>;</span></code><br/><code><span leaf="">-- ----------------------------</span></code><br/><code><span leaf="">-- Records of tbl_student_class</span></code><br/><code><span leaf="">-- ----------------------------</span></code><br/><code><span leaf="">INSERT <span class="code-snippet__type">INTO</span> <span class="code-snippet__title">tbl_student_class</span><span class="code-snippet__params">(sno, cno, cname)</span> VALUES (<span class="code-snippet__string">&#39;20190607001&#39;</span>, <span class="code-snippet__string">&#39;0607&#39;</span>, <span class="code-snippet__string">&#39;影视7班&#39;</span>);</span></code><br/><code><span leaf="">INSERT <span class="code-snippet__type">INTO</span> <span class="code-snippet__title">tbl_student_class</span><span class="code-snippet__params">(sno, cno, cname)</span> VALUES (<span class="code-snippet__string">&#39;20190607002&#39;</span>, <span class="code-snippet__string">&#39;0607&#39;</span>, <span class="code-snippet__string">&#39;影视7班&#39;</span>);</span></code><br/><code><span leaf="">INSERT <span class="code-snippet__type">INTO</span> <span class="code-snippet__title">tbl_student_class</span><span class="code-snippet__params">(sno, cno, cname)</span> VALUES (<span class="code-snippet__string">&#39;20190608003&#39;</span>, <span class="code-snippet__string">&#39;0608&#39;</span>, <span class="code-snippet__string">&#39;影视8班&#39;</span>);</span></code><br/><code><span leaf="">INSERT <span class="code-snippet__type">INTO</span> <span class="code-snippet__title">tbl_student_class</span><span class="code-snippet__params">(sno, cno, cname)</span> VALUES (<span class="code-snippet__string">&#39;20190608004&#39;</span>, <span class="code-snippet__string">&#39;0608&#39;</span>, <span class="code-snippet__string">&#39;影视8班&#39;</span>);</span></code><br/><code><span leaf="">INSERT <span class="code-snippet__type">INTO</span> <span class="code-snippet__title">tbl_student_class</span><span class="code-snippet__params">(sno, cno, cname)</span> VALUES (<span class="code-snippet__string">&#39;20190609005&#39;</span>, <span class="code-snippet__string">&#39;0609&#39;</span>, <span class="code-snippet__string">&#39;影视9班&#39;</span>);</span></code><br/><code><span leaf="">INSERT <span class="code-snippet__type">INTO</span> <span class="code-snippet__title">tbl_student_class</span><span class="code-snippet__params">(sno, cno, cname)</span> VALUES (<span class="code-snippet__string">&#39;20190609006&#39;</span>, <span class="code-snippet__string">&#39;0609&#39;</span>, <span class="code-snippet__string">&#39;影视9班&#39;</span>);</span></code><br/><code><span leaf="">INSERT <span class="code-snippet__type">INTO</span> <span class="code-snippet__title">tbl_student_class</span><span class="code-snippet__params">(sno, cno, cname)</span> VALUES (<span class="code-snippet__string">&#39;20190609007&#39;</span>, <span class="code-snippet__string">&#39;0609&#39;</span>, <span class="code-snippet__string">&#39;影视9班&#39;</span>);</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">我们要查询学生人数等于3 的班级，这个SQL该如何写，相信大家都会，用 HAVING 很容易就实现了。</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="sql"><code><span leaf=""><span class="code-snippet__keyword">SELECT</span> cno, <span class="code-snippet__built_in">COUNT</span>(<span class="code-snippet__operator">*</span>) nums <span class="code-snippet__keyword">FROM</span> tbl_student_class <span class="code-snippet__keyword">GROUP</span> <span class="code-snippet__keyword">BY</span> cno <span class="code-snippet__keyword">HAVING</span> <span class="code-snippet__built_in">COUNT</span>(<span class="code-snippet__operator">*</span>) <span class="code-snippet__operator">=</span> <span class="code-snippet__number">3</span>;</span></code></pre></p><p style="text-align: center;"><span leaf=""><img data-aistatus="1" alt="人数等于3的班级_SQL.png" class="rich_pages wxw-img" data-ratio="0.3728813559322034" data-type="other" data-w="354" style="width:341px;height:127px;" data-backw="354" data-backh="132" data-imgfileid="100152833" src="https://wechat2rss.xlab.app/img-proxy/?k=dd11ef95&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYYEFgicCbFn8ibiaH25fj8mhtVCpQwqgUAngxgW6Ef7Y1HxAq77B9VuHKN6zH5QHxhFNlFaupMNcd63RhNPHDv3icS78SMcic7XibOU8%2F640%3Fwx_fmt%3Dother%26from%3Dappmsg"/></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">如果不使用 HAVING 子句，会是什么样的结果？我们来试试。</span></span></p><p style="line-height: 1.75;text-align: center;"><span style="font-size: 15px;color: rgb(62, 62, 62);"><span leaf=""><img data-aistatus="1" alt="查询各个班的人数_SQL.png" class="rich_pages wxw-img" data-ratio="0.47654784240150094" data-type="other" data-w="533" style="width: 347px;height: 165px;" data-backw="533" data-backh="254" data-imgfileid="100152834" src="https://wechat2rss.xlab.app/img-proxy/?k=24f062b6&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYZiamzT593jBqY4GEOQ7o0Avb1KzibSa21hldkdibDTApDHzYn3MGIQr0AAjlm9PAZu8RaIbARew8oyguagCLchMIYQeXAGTDCj3c%2F640%3Fwx_fmt%3Dother%26from%3Dappmsg"/></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">就是查询各个班的人数，能看出来吧？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">所以我们可以总结下：</span></span></p><div data-role="paragraph" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="color: #7f7f7f;font-size: 15px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">WHERE 先过滤出行，然后 GROUP BY 对过滤后的行进行分组，HAVING 再对组进行过滤，筛选出我们需要的组。</span></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" alt="SQL 之 HAVING-初识HAVING.png" class="rich_pages wxw-img" data-ratio="0.3579072532699168" data-type="other" data-w="841" style="width:100%;" data-backw="578" data-backh="207" data-imgfileid="100152835" src="https://wechat2rss.xlab.app/img-proxy/?k=aa111633&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FgiamgWvCHDYawnJHFQLkMOCUTnQT6B6viaunyo0FEOmHlVgxSY2GegSq3OR7Ea7X8qRLOIJMLLwiaCYelKAVc53foopvXiaWYBbicYkWgId9UHo4%2F640%3Fwx_fmt%3Dother%26from%3Dappmsg"/></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">因为 HAVING 操作的对象是组，所以其子句构成要素有限制，只能是常数，聚合函数，聚合键。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">聚合键： GROUP BY 子句中指定的列名，可以是一列，也可以是多列。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">回到前面的案例 SQL，其中 HAVING COUNT(*) = 3，COUNT(*) 就是聚合函数，3 是常数，都在限制中；如果子句中有限制之外的条件，会是什么情况呢，我们来看个案例。</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="sql"><code><span leaf=""><span class="code-snippet__keyword">SELECT</span> cno, <span class="code-snippet__built_in">COUNT</span>(<span class="code-snippet__operator">*</span>) nums <span class="code-snippet__keyword">FROM</span> tbl_student_class <span class="code-snippet__keyword">GROUP</span> <span class="code-snippet__keyword">BY</span> cno <span class="code-snippet__keyword">HAVING</span> cname <span class="code-snippet__operator">=</span> <span class="code-snippet__string">&#39;影视9班&#39;</span>;</span></code></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">执行报错，错误信息如下：</span></span></p><div data-role="paragraph" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="color: #7f7f7f;font-size: 15px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">[Err] 1054 - Unknown column &#39;cname&#39; in &#39;having clause&#39;</span></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">翻译过来就是：不知道 having 子句中的 cname 列；因为 HAVING 操作的对象是组，而 cname 是 tbl_student_class 行记录的列名，而非组的属性，我们换个角度来理解下：GROUP BY 聚合后的结果（组）是 HAVING 子句的输入数据。我们回到案例，通过 cno 进行聚合后的结果如下：</span></span></p><p style="line-height: 1.75;text-align: center;"><span style="font-size: 15px;color: rgb(62, 62, 62);"><span leaf=""><img data-aistatus="1" alt="SQL 之 HAVING-简化理解 HAVING 子句.png" class="rich_pages wxw-img" data-ratio="1" data-type="other" data-w="161" style="width:253px;height:253px;" data-backw="161" data-backh="161" data-imgfileid="100152836" src="https://wechat2rss.xlab.app/img-proxy/?k=d1bfeb4a&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FgiamgWvCHDYYKsKcNSFb0AlMtMQL1FyMVvb4WFjHWynA2wEoyQaCrs7PtRibbMXZqn5981nnqW8aptBOnibrUMicMV5OMA7xq2t7mk7ia79RjpXA%2F640%3Fwx_fmt%3Dother%26from%3Dappmsg"/></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">聚合后的这个结果并没有 cname 这个列，那么通过这个列来进行条件处理，肯定就报错了嘛。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">如果你们细心点，就会发现：</span></span></p><div data-role="paragraph" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="color: #7f7f7f;font-size: 15px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">HAVING 子句的构成要素和包含 GROUP BY 子句时的 SELECT 子句的构成要素是一样的，都是只能包含 常数 、 聚合函数和聚合键。</span></span></p></div></div></div></div><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">二、被忽视的魅力</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">HAVING 子句是 SQL 里一个非常重要的功能，是理解 SQL 面向集合这一本质的关键，我们结合几个具体的案例，来感受下 HAVING 那些被忽略的魅力。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">1、是否存在缺失的编号</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">tbl_student_class 表中记录的 id 是连续的（id 的起始值不一定是 1），我们去掉其中 3 条。</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="apache"><code><span leaf=""><span class="code-snippet__attribute">DELETE</span> FROM tbl_student_class WHERE id IN(<span class="code-snippet__number">2</span>,<span class="code-snippet__number">5</span>,<span class="code-snippet__number">6</span>);</span></code></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">此时表中数据如下：</span></span></p><p style="line-height: 1.75;text-align: center;"><span style="font-size: 15px;color: rgb(62, 62, 62);"><span leaf=""><img data-aistatus="1" alt="缺失的编号_初始数据" class="rich_pages wxw-img" data-ratio="0.2684563758389262" data-type="other" data-w="447" data-imgfileid="100152837" src="https://wechat2rss.xlab.app/img-proxy/?k=780ab341&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYb6xHq845qmHz1o8oAWH1tOtMVp5IMdgEibqNXficl31Bbvhziawia5UJCxznvxmRskwsxr4IVGu7tgZpJLonLgqW2uURvdTMq8O60%2F640%3Fwx_fmt%3Dother%26from%3Dappmsg"/></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">问：是否有编号缺失？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">SQL 该如何实现，你们想想，我提供一种：</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="sql"><code><span leaf=""><span class="code-snippet__keyword">SELECT</span> <span class="code-snippet__string">&#39;存在缺失的编号&#39;</span> <span class="code-snippet__keyword">AS</span> gap</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">FROM</span> tbl_student_class</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">HAVING</span> <span class="code-snippet__built_in">COUNT</span>(<span class="code-snippet__operator">*</span>) <span class="code-snippet__operator">&lt;&gt;</span> <span class="code-snippet__built_in">MAX</span>(id) <span class="code-snippet__operator">-</span> <span class="code-snippet__built_in">MIN</span>(id) <span class="code-snippet__operator">+</span> <span class="code-snippet__number">1</span>;</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">上述 SQL 语句里没有 GROUP BY 子句，此时整张表会被聚合为一组，这种情况下 HAVING 子句也是可以使用的。</span></span></p><div data-role="paragraph" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="color: #7f7f7f;font-size: 15px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">HAVING 不是一定要和 GROUP BY 一起使用。</span></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">更严谨的写法如下：</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="sql"><code><span leaf=""><span class="code-snippet__comment">-- 无论如何都有结果返回</span></span></code><br/><code><span leaf=""><span class="code-snippet__keyword">SELECT</span> <span class="code-snippet__keyword">CASE</span> <span class="code-snippet__keyword">WHEN</span> <span class="code-snippet__built_in">COUNT</span>(<span class="code-snippet__operator">*</span>) <span class="code-snippet__operator">=</span> <span class="code-snippet__number">0</span> <span class="code-snippet__keyword">THEN</span> <span class="code-snippet__string">&#39;表为空&#39;</span></span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">WHEN</span> <span class="code-snippet__built_in">COUNT</span>(<span class="code-snippet__operator">*</span>) <span class="code-snippet__operator">&lt;&gt;</span> <span class="code-snippet__built_in">MAX</span>(id) <span class="code-snippet__operator">-</span> <span class="code-snippet__built_in">MIN</span>(id) <span class="code-snippet__operator">+</span> <span class="code-snippet__number">1</span> <span class="code-snippet__keyword">THEN</span> <span class="code-snippet__string">&#39;存在缺失的编号&#39;</span></span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">ELSE</span> <span class="code-snippet__string">&#39;连续&#39;</span> <span class="code-snippet__keyword">END</span> <span class="code-snippet__keyword">AS</span> gap</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">FROM</span> tbl_student_class;</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">延伸下问题：如果有编号缺失，如何找到那些缺失的编号？欢迎评论区留言。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">2、众数</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">有一张表： tbl_student_salary，记录着毕业生首份工作的年薪。</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="java"><code><span leaf="">CREATE <span class="code-snippet__type">TABLE</span> <span class="code-snippet__title">tbl_student_salary</span> <span class="code-snippet__params">(</span></span></code><br/><code><span leaf="">  id <span class="code-snippet__type">int</span>(<span class="code-snippet__number">8</span>) unsigned NOT NULL AUTO_INCREMENT COMMENT <span class="code-snippet__string">&#39;自增主键&#39;</span>,</span></code><br/><code><span leaf="">  <span class="code-snippet__type">name</span> <span class="code-snippet__title">varchar</span><span class="code-snippet__params">(</span><span class="code-snippet__params"><span class="code-snippet__number">5</span></span><span class="code-snippet__params">)</span> NOT NULL COMMENT <span class="code-snippet__string">&#39;姓名&#39;</span>,</span></code><br/><code><span leaf="">  <span class="code-snippet__type">salary</span> <span class="code-snippet__title">DECIMAL</span><span class="code-snippet__params">(</span><span class="code-snippet__params"><span class="code-snippet__number">15</span></span><span class="code-snippet__params">,</span><span class="code-snippet__params"><span class="code-snippet__number">2</span></span><span class="code-snippet__params">)</span> NOT NULL COMMENT <span class="code-snippet__string">&#39;年薪, 单位元&#39;</span>,</span></code><br/><code><span leaf="">  <span class="code-snippet__type">PRIMARY</span> <span class="code-snippet__title">KEY</span> <span class="code-snippet__params">(id)</span></span></code><br/><code><span leaf="">) ENGINE=InnoDB <span class="code-snippet__type">DEFAULT</span> <span class="code-snippet__variable">CHARSET</span><span class="code-snippet__operator">=</span><span class="code-snippet__type">utf8</span> <span class="code-snippet__variable">COMMENT</span><span class="code-snippet__operator">=</span><span class="code-snippet__string">&#39;毕业生年薪标&#39;</span>;</span></code><br/><code><span leaf="">insert into <span class="code-snippet__type">tbl_student_salary</span> <span class="code-snippet__title">values</span> <span class="code-snippet__params">(</span><span class="code-snippet__params"><span class="code-snippet__number">1</span></span><span class="code-snippet__params">,</span><span class="code-snippet__params"><span class="code-snippet__string">&#39;李小龙&#39;</span></span><span class="code-snippet__params">, </span><span class="code-snippet__params"><span class="code-snippet__number">1000000</span></span><span class="code-snippet__params">)</span>;</span></code><br/><code><span leaf="">insert into <span class="code-snippet__type">tbl_student_salary</span> <span class="code-snippet__title">values</span> <span class="code-snippet__params">(</span><span class="code-snippet__params"><span class="code-snippet__number">2</span></span><span class="code-snippet__params">,</span><span class="code-snippet__params"><span class="code-snippet__string">&#39;李四&#39;</span></span><span class="code-snippet__params">, </span><span class="code-snippet__params"><span class="code-snippet__number">50000</span></span><span class="code-snippet__params">)</span>;</span></code><br/><code><span leaf="">insert into <span class="code-snippet__type">tbl_student_salary</span> <span class="code-snippet__title">values</span> <span class="code-snippet__params">(</span><span class="code-snippet__params"><span class="code-snippet__number">3</span></span><span class="code-snippet__params">,</span><span class="code-snippet__params"><span class="code-snippet__string">&#39;王五&#39;</span></span><span class="code-snippet__params">, </span><span class="code-snippet__params"><span class="code-snippet__number">50000</span></span><span class="code-snippet__params">)</span>;</span></code><br/><code><span leaf="">insert into <span class="code-snippet__type">tbl_student_salary</span> <span class="code-snippet__title">values</span> <span class="code-snippet__params">(</span><span class="code-snippet__params"><span class="code-snippet__number">4</span></span><span class="code-snippet__params">,</span><span class="code-snippet__params"><span class="code-snippet__string">&#39;赵六&#39;</span></span><span class="code-snippet__params">, </span><span class="code-snippet__params"><span class="code-snippet__number">50000</span></span><span class="code-snippet__params">)</span>;</span></code><br/><code><span leaf="">insert into <span class="code-snippet__type">tbl_student_salary</span> <span class="code-snippet__title">values</span> <span class="code-snippet__params">(</span><span class="code-snippet__params"><span class="code-snippet__number">5</span></span><span class="code-snippet__params">,</span><span class="code-snippet__params"><span class="code-snippet__string">&#39;张三&#39;</span></span><span class="code-snippet__params">, </span><span class="code-snippet__params"><span class="code-snippet__number">70000</span></span><span class="code-snippet__params">)</span>;</span></code><br/><code><span leaf="">insert into <span class="code-snippet__type">tbl_student_salary</span> <span class="code-snippet__title">values</span> <span class="code-snippet__params">(</span><span class="code-snippet__params"><span class="code-snippet__number">6</span></span><span class="code-snippet__params">,</span><span class="code-snippet__params"><span class="code-snippet__string">&#39;张一三&#39;</span></span><span class="code-snippet__params">, </span><span class="code-snippet__params"><span class="code-snippet__number">70000</span></span><span class="code-snippet__params">)</span>;</span></code><br/><code><span leaf="">insert into <span class="code-snippet__type">tbl_student_salary</span> <span class="code-snippet__title">values</span> <span class="code-snippet__params">(</span><span class="code-snippet__params"><span class="code-snippet__number">7</span></span><span class="code-snippet__params">,</span><span class="code-snippet__params"><span class="code-snippet__string">&#39;张二三&#39;</span></span><span class="code-snippet__params">, </span><span class="code-snippet__params"><span class="code-snippet__number">70000</span></span><span class="code-snippet__params">)</span>;</span></code><br/><code><span leaf="">insert into <span class="code-snippet__type">tbl_student_salary</span> <span class="code-snippet__title">values</span> <span class="code-snippet__params">(</span><span class="code-snippet__params"><span class="code-snippet__number">8</span></span><span class="code-snippet__params">,</span><span class="code-snippet__params"><span class="code-snippet__string">&#39;张三三&#39;</span></span><span class="code-snippet__params">, </span><span class="code-snippet__params"><span class="code-snippet__number">60000</span></span><span class="code-snippet__params">)</span>;</span></code><br/><code><span leaf="">insert into <span class="code-snippet__type">tbl_student_salary</span> <span class="code-snippet__title">values</span> <span class="code-snippet__params">(</span><span class="code-snippet__params"><span class="code-snippet__number">9</span></span><span class="code-snippet__params">,</span><span class="code-snippet__params"><span class="code-snippet__string">&#39;张三四&#39;</span></span><span class="code-snippet__params">, </span><span class="code-snippet__params"><span class="code-snippet__number">40000</span></span><span class="code-snippet__params">)</span>;</span></code><br/><code><span leaf="">insert into <span class="code-snippet__type">tbl_student_salary</span> <span class="code-snippet__title">values</span> <span class="code-snippet__params">(</span><span class="code-snippet__params"><span class="code-snippet__number">10</span></span><span class="code-snippet__params">,</span><span class="code-snippet__params"><span class="code-snippet__string">&#39;张三丰&#39;</span></span><span class="code-snippet__params">, </span><span class="code-snippet__params"><span class="code-snippet__number">30000</span></span><span class="code-snippet__params">)</span>;</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">如果光从平均工资（149000）来看，感觉毕业生都能拿到很高的工资。但这个平均工资背后却有一些玄机，因为功夫大师李小龙在这一届毕业生中，由于他出众的薪资，将大家的平均薪资拉升了一大截。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">简单地求平均值有一个缺点，那就是很容易受到离群值（outlier）的影响，这种时候就必须使用更能准确反映出群体趋势的指标，众数（mode）就是其中之一；那么如何用 SQL 来求众数了，请看我表演。</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="sql"><code><span leaf=""><span class="code-snippet__comment">-- 使用谓词 ALL 求众数</span></span></code><br/><code><span leaf=""><span class="code-snippet__keyword">SELECT</span> salary, <span class="code-snippet__built_in">COUNT</span>(<span class="code-snippet__operator">*</span>) <span class="code-snippet__keyword">AS</span> cnt</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">FROM</span> tbl_student_salary</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">GROUP</span> <span class="code-snippet__keyword">BY</span> salary</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">HAVING</span> <span class="code-snippet__built_in">COUNT</span>(<span class="code-snippet__operator">*</span>) <span class="code-snippet__operator">&gt;=</span> <span class="code-snippet__keyword">ALL</span> (</span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">SELECT</span> <span class="code-snippet__built_in">COUNT</span>(<span class="code-snippet__operator">*</span>)</span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">FROM</span> tbl_student_salary</span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">GROUP</span> <span class="code-snippet__keyword">BY</span> salary);</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">执行结果如下：</span></span></p><p style="line-height: 1.75;text-align: center;"><span style="font-size: 15px;color: rgb(62, 62, 62);"><span leaf=""><img data-aistatus="1" alt="众数结果" class="rich_pages wxw-img" data-ratio="0.2976190476190476" data-type="other" data-w="252" data-imgfileid="100152838" src="https://wechat2rss.xlab.app/img-proxy/?k=e0f10deb&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYYtyLoBzprYz9JiaB4xa6ibibCM406U6LCZj0QjImAOITrRzha7QF9347DTGJfaIEARl7QIoDzeMoJGj6rYTbc7AvWNnVAD9bM2fk%2F640%3Fwx_fmt%3Dother%26from%3Dappmsg"/></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">ALL 谓词用于 NULL 或空集时会出现问题，我们可以用极值函数来代替；这里要求的是元素数最多的集合，因此可以用 MAX 函数。</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="sql"><code><span leaf=""><span class="code-snippet__comment">-- 使用极值函数求众数</span></span></code><br/><code><span leaf=""><span class="code-snippet__keyword">SELECT</span> salary, <span class="code-snippet__built_in">COUNT</span>(<span class="code-snippet__operator">*</span>) <span class="code-snippet__keyword">AS</span> cnt</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">FROM</span> tbl_student_salary</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">GROUP</span> <span class="code-snippet__keyword">BY</span> salary</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">HAVING</span> <span class="code-snippet__built_in">COUNT</span>(<span class="code-snippet__operator">*</span>) <span class="code-snippet__operator">&gt;=</span> (</span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">SELECT</span> <span class="code-snippet__built_in">MAX</span>(cnt)</span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">FROM</span> (</span></code><br/><code><span leaf="">        <span class="code-snippet__keyword">SELECT</span> <span class="code-snippet__built_in">COUNT</span>(<span class="code-snippet__operator">*</span>) <span class="code-snippet__keyword">AS</span> cnt</span></code><br/><code><span leaf="">        <span class="code-snippet__keyword">FROM</span> tbl_student_salary</span></code><br/><code><span leaf="">        <span class="code-snippet__keyword">GROUP</span> <span class="code-snippet__keyword">BY</span> salary</span></code><br/><code><span leaf="">        ) TMP</span></code><br/><code><span leaf="">    ) ;</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">是不是触及到你们的知识盲区了？但你们先别慌，因为后面会让你们更慌。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">3、中位数</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">当平均值不可信时，与众数一样经常被用到的另一个指标是中位数（median），它指的是将集合中的元素按升序排列后恰好位于正中间的元素。如果集合的元素个数为偶数，则取中间两个元素的平均值作为中位数。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">回到表 tbl_student_salary，共有 10 条记录，那么 张三三, 60000 和 李四, 50000 的平均值 55000 就是中位数。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">那么问题来了，通过 SQL 如何求中位数？实现也不复杂，将集合里的元素按照大小分为上半部分和下半部分两个子集，同时让这 2 个子集共同拥有集合正中间的元素，这样，共同部分的元素的平均值就是中位数，思路如下图所示：</span></span></p><p style="line-height: 1.75;text-align: center;"><span style="font-size: 15px;color: rgb(62, 62, 62);"><span leaf=""><img data-aistatus="1" alt="中位数_思路" class="rich_pages wxw-img" data-ratio="0.44789356984478934" data-type="other" data-w="451" style="width:395px;height:177px;" data-backw="451" data-backh="202" data-imgfileid="100152839" src="https://wechat2rss.xlab.app/img-proxy/?k=5d1f1e9c&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FgiamgWvCHDYaN9oaM5ibYCorMKnk8eqRmiaXsJLsUUjMWydbDWCGHzJsrHvBZdhicibE8DqV98mIuArlwQo1yaCQZXxw2aibZeicIQQYcYWu89bmx4%2F640%3Fwx_fmt%3Dother%26from%3Dappmsg"/></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">像这样需要根据大小关系生成子集时，就轮到 非等值自连接出场了：</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">-</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="sql"><code><span leaf=""><span class="code-snippet__operator">-</span> 求中位数的<span class="code-snippet__keyword">SQL</span> 语句：在<span class="code-snippet__keyword">HAVING</span> 子句中使用非等值自连接</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">SELECT</span> <span class="code-snippet__built_in">AVG</span>(<span class="code-snippet__keyword">DISTINCT</span> salary)</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">FROM</span> (</span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">SELECT</span> T1.salary</span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">FROM</span> tbl_student_salary T1, tbl_student_salary T2</span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">GROUP</span> <span class="code-snippet__keyword">BY</span> T1.salary</span></code><br/><code><span leaf="">    <span class="code-snippet__comment">-- S1 的条件</span></span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">HAVING</span> <span class="code-snippet__built_in">SUM</span>(<span class="code-snippet__keyword">CASE</span> <span class="code-snippet__keyword">WHEN</span> T2.salary <span class="code-snippet__operator">&gt;=</span> T1.salary <span class="code-snippet__keyword">THEN</span> <span class="code-snippet__number">1</span> <span class="code-snippet__keyword">ELSE</span> <span class="code-snippet__number">0</span> <span class="code-snippet__keyword">END</span>) <span class="code-snippet__operator">&gt;=</span> <span class="code-snippet__built_in">COUNT</span>(<span class="code-snippet__operator">*</span>) <span class="code-snippet__operator">/</span> <span class="code-snippet__number">2</span></span></code><br/><code><span leaf="">    <span class="code-snippet__comment">-- S2 的条件</span></span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">AND</span> <span class="code-snippet__built_in">SUM</span>(<span class="code-snippet__keyword">CASE</span> <span class="code-snippet__keyword">WHEN</span> T2.salary <span class="code-snippet__operator">&lt;=</span> T1.salary <span class="code-snippet__keyword">THEN</span> <span class="code-snippet__number">1</span> <span class="code-snippet__keyword">ELSE</span> <span class="code-snippet__number">0</span> <span class="code-snippet__keyword">END</span>) <span class="code-snippet__operator">&gt;=</span> <span class="code-snippet__built_in">COUNT</span>(<span class="code-snippet__operator">*</span>) <span class="code-snippet__operator">/</span> <span class="code-snippet__number">2</span></span></code><br/><code><span leaf="">) TMP;</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这条 SQL 语句的要点在于比较条件 &gt;= COUNT(*)/2 里的等号，加上等号并不是为了清晰地分开子集 S1 和 S2，而是为了让这 2 个子集拥有共同部分；如果去掉等号，将条件改成 &gt; COUNT(*)/2 ，那么当元素个数为偶数时，S1 和 S2 就没有共同的元素了，也就无法求出中位数了；加上等号是为了写出通用性更高的 SQL。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">是不是满头大汗了？但别慌，把 SQL 拆开执行，根据结果来反推每个拆分 SQL 的逻辑含义，慢慢的你们就能理解了。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">4、不包含 NULL 的集合</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">假设我们有一张学生报告提交记录表：tbl_student_submit_log：</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="java"><code><span leaf="">CREATE <span class="code-snippet__type">TABLE</span> <span class="code-snippet__title">tbl_student_submit_log</span> <span class="code-snippet__params">(</span></span></code><br/><code><span leaf="">  id <span class="code-snippet__type">int</span>(<span class="code-snippet__number">8</span>) unsigned NOT NULL AUTO_INCREMENT COMMENT <span class="code-snippet__string">&#39;自增主键&#39;</span>,</span></code><br/><code><span leaf="">  <span class="code-snippet__type">sno</span> <span class="code-snippet__title">varchar</span><span class="code-snippet__params">(</span><span class="code-snippet__params"><span class="code-snippet__number">12</span></span><span class="code-snippet__params">)</span> NOT NULL COMMENT <span class="code-snippet__string">&#39;学号&#39;</span>,</span></code><br/><code><span leaf="">  <span class="code-snippet__type">dept</span> <span class="code-snippet__title">varchar</span><span class="code-snippet__params">(</span><span class="code-snippet__params"><span class="code-snippet__number">50</span></span><span class="code-snippet__params">)</span> NOT NULL COMMENT <span class="code-snippet__string">&#39;学院&#39;</span>,</span></code><br/><code><span leaf="">  submit_date DATE COMMENT <span class="code-snippet__string">&#39;提交日期&#39;</span>,</span></code><br/><code><span leaf="">  <span class="code-snippet__type">PRIMARY</span> <span class="code-snippet__title">KEY</span> <span class="code-snippet__params">(id)</span></span></code><br/><code><span leaf="">) ENGINE=InnoDB <span class="code-snippet__type">DEFAULT</span> <span class="code-snippet__variable">CHARSET</span><span class="code-snippet__operator">=</span><span class="code-snippet__type">utf8</span> <span class="code-snippet__variable">COMMENT</span><span class="code-snippet__operator">=</span><span class="code-snippet__string">&#39;学生报告提交记录表&#39;</span>;</span></code><br/><code><span leaf="">insert into <span class="code-snippet__type">tbl_student_submit_log</span> <span class="code-snippet__title">values</span></span></code><br/><code><span leaf=""><span class="code-snippet__params">(</span><span class="code-snippet__params"><span class="code-snippet__number">1</span></span><span class="code-snippet__params">,</span><span class="code-snippet__params"><span class="code-snippet__string">&#39;20200607001&#39;</span></span><span class="code-snippet__params">, </span><span class="code-snippet__params"><span class="code-snippet__string">&#39;理学院&#39;</span></span><span class="code-snippet__params">, </span><span class="code-snippet__params"><span class="code-snippet__string">&#39;2020-12-12&#39;</span></span><span class="code-snippet__params">)</span>,</span></code><br/><code><span leaf="">(<span class="code-snippet__number">2</span>,<span class="code-snippet__string">&#39;20200607002&#39;</span>, <span class="code-snippet__string">&#39;理学院&#39;</span>, <span class="code-snippet__string">&#39;2020-12-13&#39;</span>),</span></code><br/><code><span leaf="">(<span class="code-snippet__number">3</span>,<span class="code-snippet__string">&#39;20200608001&#39;</span>, <span class="code-snippet__string">&#39;文学院&#39;</span>, <span class="code-snippet__literal">null</span>),</span></code><br/><code><span leaf="">(<span class="code-snippet__number">4</span>,<span class="code-snippet__string">&#39;20200608002&#39;</span>, <span class="code-snippet__string">&#39;文学院&#39;</span>, <span class="code-snippet__string">&#39;2020-12-22&#39;</span>),</span></code><br/><code><span leaf="">(<span class="code-snippet__number">5</span>,<span class="code-snippet__string">&#39;20200608003&#39;</span>, <span class="code-snippet__string">&#39;文学院&#39;</span>, <span class="code-snippet__string">&#39;2020-12-22&#39;</span>),</span></code><br/><code><span leaf="">(<span class="code-snippet__number">6</span>,<span class="code-snippet__string">&#39;20200612001&#39;</span>, <span class="code-snippet__string">&#39;工学院&#39;</span>, <span class="code-snippet__literal">null</span>),</span></code><br/><code><span leaf="">(<span class="code-snippet__number">7</span>,<span class="code-snippet__string">&#39;20200617001&#39;</span>, <span class="code-snippet__string">&#39;经济学院&#39;</span>, <span class="code-snippet__string">&#39;2020-12-23&#39;</span>);</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">学生提交报告后， submit_date 列会被写入日期，而提交之前是 NULL。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">问：从这张表里找出哪些学院的学生全部都提交了报告，SQL 该怎么写？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">如果只是用 WHERE submit_date IS NOT NULL 条件进行查询，那文学院也会被包含进来，结果就不正确了，正确的做法应该先以 dept 进行分组，然后对组进行条件的过滤，SQL 如下：</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="sql"><code><span leaf=""><span class="code-snippet__keyword">SELECT</span> dept</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">FROM</span> tbl_student_submit_log</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">GROUP</span> <span class="code-snippet__keyword">BY</span> dept</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">HAVING</span> <span class="code-snippet__built_in">COUNT</span>(<span class="code-snippet__operator">*</span>) <span class="code-snippet__operator">=</span> <span class="code-snippet__built_in">COUNT</span>(submit_date);</span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这里其实用到了 COUNT 函数，COUNT(*) 可以用于 NULL ，而 COUNT(列名) 与其他聚合函数一样，要先排除掉 NULL 的行再进行统计。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">当然，更通用的实现是使用 CASE 表达式：</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="sql"><code><span leaf=""><span class="code-snippet__keyword">SELECT</span> dept</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">FROM</span> tbl_student_submit_log</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">GROUP</span> <span class="code-snippet__keyword">BY</span> dept</span></code><br/><code><span leaf=""><span class="code-snippet__keyword">HAVING</span> <span class="code-snippet__built_in">COUNT</span>(<span class="code-snippet__operator">*</span>) <span class="code-snippet__operator">=</span> <span class="code-snippet__built_in">SUM</span>(</span></code><br/><code><span leaf="">    <span class="code-snippet__keyword">CASE</span> <span class="code-snippet__keyword">WHEN</span> submit_date <span class="code-snippet__keyword">IS</span> <span class="code-snippet__keyword">NOT NULL</span> <span class="code-snippet__keyword">THEN</span> <span class="code-snippet__number">1</span></span></code><br/><code><span leaf="">        <span class="code-snippet__keyword">ELSE</span> <span class="code-snippet__number">0</span> <span class="code-snippet__keyword">END</span></span></code><br/><code><span leaf="">    );</span></code><br/></pre></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">三、聚合键条件归属</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">我们来看个有趣的东西，还是用表：tbl_student_class：</span></span></p><p style="line-height: 1.75;text-align: center;"><span style="font-size: 15px;color: rgb(62, 62, 62);"><span leaf=""><img data-aistatus="1" alt="SQL 之 HAVING-条件归属.png" class="rich_pages wxw-img" data-ratio="0.634765625" data-type="other" data-w="512" style="width: 470px;height: 298px;" data-backw="512" data-backh="325" data-imgfileid="100152840" src="https://wechat2rss.xlab.app/img-proxy/?k=52648552&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYZJaXiaMsw8Ckz5NgS34XQf5p0WF01ib1kxgrjkSAeJsVJTWSeIKymPNSl7A1Cu9SgIBHfNOcX7j6fWgricQaCqAQQX9njH0pb5Dc%2F640%3Fwx_fmt%3Dother%26from%3Dappmsg"/></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">我们发现，聚合键所对应的条件既可以写在 HAVING 子句当中，也可以写在 WHERE 子句当中，虽然条件分别写在 HAVING 子句和 WHERE 子句当中，但是条件的内容，以及返回的结果都完全相同，因此，很多小伙伴就会觉得两种书写方式都没问题，单从结果来看，确实没问题，但其中有一种属于偏离了 SQL 规范的非正规用法，推荐做法是： 聚合键所对应的条件应该书写在 WHERE 子句中 ，理由有二：</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">1、语义更清晰</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">WHERE 子句和 HAVING 子句的作用是不同的；前面已经说过，HAVING 子句是用来指定 组 的条件的，而 行 所对应的条件应该写在 WHERE 子句中，这样一来，写出来的 SQL 语句不但可以分清两者各自的功能，而且理解起来也更容易。</span></span></p><p style="line-height: 1.75;text-align: center;"><span style="font-size: 15px;color: rgb(62, 62, 62);"><span leaf=""><img data-aistatus="1" alt="SQL 之 HAVING-HAVING 与 WHERE的语义区别" class="rich_pages wxw-img" data-ratio="0.26199261992619927" data-type="other" data-w="271" data-imgfileid="100152841" src="https://wechat2rss.xlab.app/img-proxy/?k=d07e156e&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYYfFtNEeoJXY5Nvo9bm4w1KnIRLsgLhvARuSKd4wcp8ibjQIuqTeozqYULlXzRKoo9kC9CmD3peyKk9GwsLxpMTA91diay1nSbiag%2F640%3Fwx_fmt%3Dother%26from%3Dappmsg"/></span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">2、执行速度更快</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">使用 COUNT 等函数对表中数据进行聚合操作时，DBMS 内部进行排序处理，而排序处理会大大增加机器的负担，从而降低处理速度；因此，尽可能减少排序的行数，可以提高处理速度；通过 WHERE 子句指定条件时，由于排序之前就对数据进行了过滤，那么就减少了聚合操作时的需要排序的记录数量；而 HAVING 子句是在排序之后才对数据进行分组的，与在 WHERE 子句中指定条件比起来，需要排序的数量就会多得多。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">另外，索引是 WHERE 根据速度优势的另一个有利支持，在 WHERE 子句指定条件所对应的列上创建索引，可以大大提高 WHERE 子句的处理速度。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">四、总结</span></strong></span></p></div></div></div></div><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">1、SQL 的本质是集合论</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">集合论是 SQL 语言的根基，只有从集合的角度来思考，才能明白 SQL 的强大威力；学习 HAVING 子句的用法是帮助我们顺利地忘掉面向过程语言的思考方式并理解 SQL 面向集合特性的最为有效的方法。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">2、HAVING 子句的三要素</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">常数、聚合函数和聚合键。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">3、HAVING 与 WHERE</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">WHERE 子句是指定行所对应的条件，而 HAVING 子句是指定组所对应的条件；能放到 WHERE 子句的条件统统放到 WHERE 子句中，这样能够减少需要分组的记录数，从而提高分组后操作的效率。</span></span></p><div data-role="paragraph" style="font-family:sans-serif;" data-pm-slice="0 0 []"><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">作者丨青石路</span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;text-align: left;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">来源丨网址：<a href="https://juejin.cn/post/7415653658706247707" target="_blank">https://juejin.cn/post/7415653658706247707</a></span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">dbaplus社群欢迎广大技术人员投稿，投稿邮箱：</span></span><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">editor@dbaplus.cn</span></span></p><p class="mp_profile_iframe_wrp" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-servicetype="0" data-verify_status="2"></mp-common-profile></p><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.07777777777777778" data-s="300,640" data-w="1080" type="block" data-imgfileid="100130225" src="https://wechat2rss.xlab.app/img-proxy/?k=f32823a4&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FufWcjcomw8Zf2jiaBBH3vdgfP4A2rem5YEAHYH074dc4GibhojA5B3lLZrXLDRciaVnficveaHcAUCiaIPoDsTkAduA%2F640%3Fwx_fmt%3Dpng"/></p></div></div></div><p style="display: none;"><mp-style-type data-value="3"></mp-style-type></p>



<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=b576afa7&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzkzMjYzNjkzNw%3D%3D%26mid%3D2247638290%26idx%3D2%26sn%3D24f3a621db15e10eaed2321d045fb98e">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Tue, 27 Oct 2026 07:15:00 +0800</pubDate>
    </item>
    <item>
      <title>软件倒逼硬件！当年没人相信x86能虚拟化，直到这家公司出现……</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzkzMjYzNjkzNw==&amp;mid=2247638280&amp;idx=1&amp;sn=fa3a6f47d1072d43163eda876a37e597</link>
      <description>x86 虚拟化如何从缺陷变成基石？</description>
      <content:encoded><![CDATA[<p>原创 <span>Ernie Smith</span> <span>2026-10-26 07:15</span> <span style="display: inline-block;">广东</span></p>






  
  <p><img src="https://wechat2rss.xlab.app/img-proxy/?k=41217299&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYbPo7RhmpUcZVqMDKYBD4LvabvDZnjUyESE97AIe8uCfYxd9653vX21VjGgfbjTture08Dia1zUONGZKibiam9b6lO80N88KGjleA%2F0%3Fwx_fmt%3Djpeg"/></p>
  <p>x86 虚拟化如何从缺陷变成基石？</p>
  <p class="mp_profile_iframe_wrp" style="margin-bottom: 0px;" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-service_type="1" data-verify_status="2"></mp-common-profile></p><div data-role="outer" label="edit by 135editor" data-pm-slice="0 0 []"><div data-role="paragraph"><div data-tools="135编辑器" data-id="88516" style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;color: #333333;font-size: 17px;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, Arial, sans-serif;"><div style="margin: 0.5em 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><div style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;line-height: 1.75em;"><div data-width="100%" style="margin: -10px 0px;padding: 0px 10px;max-width: 100%;display: inline-block;vertical-align: top;width: 100%;word-wrap: break-word !important;box-sizing:border-box;"><div hm_fix="461:527" style="margin: 0px;padding: 10px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;border-width: 2px;border-style: solid;border-color: white;background-color: #efefef;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="font-size: 15px;color: #7f7f7f;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf="">虚拟机是云计算的基石。两位科学家证明两个定理有误之后，它才真正找到了现代立足点。这中间发生了什么？</span></span></p></div></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">在现代计算机领域，虚拟化大概是最容易被当成理所当然的技术。包括云基础设施在内的很多核心场景，都离不开它。要知道，21 世纪初，虚拟机才在 x86 站稳脚跟。如今遍布各地的海量服务器集群，正是这条技术脉络顺理成章的产物。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">但虚拟化的普及，绝非历史必然。当年英特尔几乎放弃了服务器虚拟化的路线，甚至打算推出新一代硬件，另辟赛道。然而一家初创公司横空破局：它不仅证实虚拟化可以落地，更催生了前所未有的云经济。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">这在 IT 史上相当罕见：</span><span textstyle="" style="color: rgb(62, 62, 62);font-weight: bold;">硬件，被迫追赶软件。</span></span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">一、为什么当年没人相信 x86 能实现虚拟化？</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">20 世纪 70 年代的大型机时代，一个新概念走进人们的视野——<span textstyle="" style="font-weight: bold;">Hypervisor</span>，顾名思义，即“监管所有管理程序得程序”，它预示着软硬件深度协同的未来。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这个由 IBM 创造的名词，也叫<span textstyle="" style="font-weight: bold;">虚拟机监视器（VMM，Virtual Machine Monitor）</span>。它的核心构想是，把一台物理计算机切分成若干逻辑分区，各个分区在理论上彼此完全隔离。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这套机制具体是如何运作的？IBM 研究员 Gary Allred 在论文中给出了解释：</span></span></p><div data-tools="135编辑器" data-id="5" data-color="rgb(198, 198, 199)" data-custom="rgb(198, 198, 199)" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;border: 0px none;z-index: 0;max-width: 100%;font-size: 16px;widows: 1;visibility: visible;" data-pm-slice="0 0 []"><div style="max-inline-size: 100%;margin: 2px auto;padding: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;max-width: 100%;font-size: 14px;line-height: 25px;border-width: 2px;border-style: dashed;border-color: #c6c6c7;visibility: visible;"><p style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;clear: both;min-height: 1em;cursor: text;max-width: 100%;vertical-align: inherit;line-height: 1.5em;visibility: visible;"><span style="caret-color: red;color: #3e3e3e;"><span leaf="">Hypervisor 的原理其实相对简单。它由两部分构成：一是仿真程序的附加模块，二是对带有兼容特性的 Model 65 大型机所做的硬件改动。这项硬件改动把 Model 65 划分为两个分区，每个分区的寻址空间都从 0 开始到最大地址 n。程序附加模块会用自身内容覆盖系统的程序状态字（PSW），并作为整个系统的中断处理器。当判断出是哪个分区触发了中断事件后，系统就把控制权移交到对应分区。Hypervisor 要求每个分区都配备独立专用 I/O 设备。正因如此，整套 I/O 配置通常十分庞大，成本高到绝大多数用户都负担不起。</span></span></p></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">所以它和现代虚拟机并不一样：<span textstyle="" style="font-weight: bold;">这套方案实际上是同时运行两台完全相互隔离的计算机，仿佛二者之间毫无关联。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">在大型机时代，这种设计有着现实意义，要知道，当时一台小型计算机的体积差不多就和自动售货机一般大小。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">但众所周知，此后计算机的体积便不断缩小。先是比面包盒要大，接着缩小到面包盒级别，再后来差不多只有一条面包那么大；如今手机的大小，几乎就等同于一块面包。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">有那么一段时期，计算机体积越小，计算能力往往也越弱，哪怕处理器主频越做越高。当然，性能受限并不仅仅是体积这一个因素造成的。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" alt="intel-386.jpg" class="rich_pages wxw-img" data-ratio="0.75125" data-type="jpeg" data-w="800" style="width:100%;" data-backw="578" data-backh="434" data-imgfileid="100154372" src="https://wechat2rss.xlab.app/img-proxy/?k=dbd9ad46&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FgiamgWvCHDYaqt7mr8Yb90D7Cq2jAzL0TthPOxgONicb9r8297jtAr2nwbEIiciczUjx1ibQpqg5d8M4uRNdicESLtibdf2XrMgppaAaZEWOwSN4Og%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;"><span style="font-size: 15px;color: rgb(62, 62, 62);"><span leaf=""><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">它看着像是一块方形晶圆，实际上却是由一圈圈环带构成。（图片来源：flickr，编号 508518299）</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">英特尔与 AMD 的 x86 处理器拥有庞大的指令集，让芯片硬件变得非常复杂。</span>这恰恰给 Gerald Popek 与 Robert Goldberg 提出的虚拟化定理带来了难题。</span></span></p><div data-tools="135编辑器" data-id="5" data-color="rgb(198, 198, 199)" data-custom="rgb(198, 198, 199)" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;border: 0px none;z-index: 0;max-width: 100%;font-size: 16px;widows: 1;visibility: visible;" data-pm-slice="0 0 []"><div style="max-inline-size: 100%;margin: 2px auto;padding: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;max-width: 100%;font-size: 14px;line-height: 25px;border-width: 2px;border-style: dashed;border-color: #c6c6c7;visibility: visible;"><p style="max-inline-size: 100%;margin: 0px;padding: 0px;outline: 0px;clear: both;min-height: 1em;cursor: text;max-width: 100%;vertical-align: inherit;line-height: 1.75em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="color: rgb(62, 62, 62);caret-color: red;"><span leaf=""><span textstyle="" style="font-weight: bold;">&#34;对于任何传统的第三代计算机，如果该计算机的敏感指令集是特权指令集的子集，则可以构建虚拟机监视器。&#34;</span></span></span></p><p style="max-inline-size: 100%;margin: 0px;padding: 0px;outline: 0px;clear: both;min-height: 1em;cursor: text;max-width: 100%;vertical-align: inherit;line-height: 1.75em;visibility: visible;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="color: rgb(62, 62, 62);caret-color: red;"><span leaf="">——这是加州大学洛杉矶分校（UCLA）的 Gerald Popek 与霍尼韦尔公司的 Robert Goldberg 提出的三条定理中的第一条，用于判断在特定系统架构上能否实现虚拟化。他们发表于 1974 年的论文，在此后几十年间堪称虚拟化领域的 &#34;摩尔定律&#34;，成为衡量虚拟化可行性的分水岭。而 x86 系列处理器因其 CISC 架构特性，违背了这些定理中的许多基本原则。</span></span></p></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">英特尔为 x86 芯片设计了多层特权分级机制（保护环），初衷是缩减内核的攻击面，提升系统安全性。这套机制对筑牢安全防线十分有利，但如果你想在 Windows 2000 内部再跑一份 Linux，这套架构就显得捉襟见肘。这套权限体系限制了软件能够调用的指令集合，所以它<span textstyle="" style="font-weight: bold;">无法像 IBM 在 System/360 大型机上那样，实现原生的虚拟化。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">当然，在 Windows 2000 上模拟一台 Linux 机器在技术上并非完全做不到，但会产生巨大性能开销。相当于要用软件完整复现一套硬件，而这套硬件其实物理上就摆在眼前。这么做非常不合理。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这个问题并非英特尔一家独有，当年几乎所有主流处理器平台都存在同类缺陷，属于行业普遍困境。但由于 x86 的市场占有率极高，英特尔成了这一矛盾最典型的代表。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">x86 指令集有十余处地方违背了 Popek 和 Goldberg 提出的虚拟化定理的前提条件，这就意味着，<span textstyle="" style="font-weight: bold;">在当时现有的硬件体系之下，搭建高性能虚拟机几乎行不通。</span></span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">二、两条被忽视的技术暗线</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" alt="动态重编译专利.jpg" class="rich_pages wxw-img" data-ratio="1.3333333333333333" data-type="jpeg" data-w="603" style="width:100%;" data-backw="578" data-backh="771" data-imgfileid="100154373" src="https://wechat2rss.xlab.app/img-proxy/?k=f1cc35c0&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYYP8pkLicIasuyRQNa1zPV61OW6ckboc2mbicn72iaM6ia1eGz0C4KicZ94l4YlnNicenejUc6CggPPYDoGJdGS3MpFqmulQUyc9Ie0I%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;"><span style="font-size: 15px;color: rgb(62, 62, 62);"><span leaf=""><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">苹果工程师 Eric Traut 在 90 年代中期提交的动态重编译专利附图， 解决了老旧 Mac 应用在 PowerPC 上运行性能糟糕的问题</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">不过，当时已经出现一些新思路，暗示事情本不必落到这般境地。在 Mac 平台上，苹果完成过堪称魔术级别的架构迁移：从 68000 向 PowerPC 过渡时，它打造了一套转换层，几乎可以让旧代码近乎原生地运行。苹果最初采用的是模拟方案，后来转而使用一种叫做<span textstyle="" style="font-weight: bold;">动态重编译（dynamic recompilation）</span>的技术。</span></span></p><div data-role="paragraph" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="color: #7f7f7f;font-size: 15px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">专利 US5790825A 由苹果员工 Eric Traut 开发，此人后来参与开发了大名鼎鼎的 PlayStation 模拟器 </span><span leaf="">Connectix Virtual Game Station</span><span leaf="">。</span></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">换句话说，</span></span><span style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);" data-pm-slice="0 0 []"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-weight: bold;">该系统重新编程了旧代码，使其能够在MacOS上实时运行。</span>这项技术非常</span></span><span leaf="">出色，后续基于 PowerPC 的经典 MacOS 版本中</span><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);">，</span><span style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);" data-pm-slice="0 0 []"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);">大部分软件仍然是模拟的68k代码。</span></span><span leaf="" style="line-height: 1.75;font-size: 15px;color: rgb(62, 62, 62);">开</span><span leaf="">发者不用更新程序，软件就可以直接正常工作。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">与此同时，Java 编程语言普及了即时编译的概念：<span textstyle="" style="font-weight: bold;">程序可以实时在目标机器上执行，不再被绑定到特定硬件架构。</span>也正因如此，90 年代中期计算机杂志上大量关于虚拟机的讨论，都围绕这一技术展开。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">JIT 堪称现代计算领域最重要的技术之一：浏览器用它加速 JavaScript 执行，现代虚拟化也建立在它的基础之上。JIT 已经证明，对应用程序做实时指令转译是可行的。但如果要转译完整操作系统呢？x86 架构的先天缺陷让这类方案举步维艰。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">于是，那个源自大型机时代、一度被人淡忘的技术——Hypervisor，依旧没能重返主流。Popek‑Goldberg theorems 定理带来的桎梏，依旧困扰着现代计算机。<span textstyle="" style="font-weight: bold;">不过，一台顶级 SGI Origin 2000 服务器上开展的计算机科学实验，即将彻底改写这一切。</span></span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">三、从 SGI 到市场：Disco 实验如何变成 VMware</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" alt="sgi-origin-2000.jpg" class="rich_pages wxw-img" data-ratio="1.5" data-type="jpeg" data-w="1000" style="width:100%;" data-backw="578" data-backh="867" data-imgfileid="100154375" src="https://wechat2rss.xlab.app/img-proxy/?k=b7ee58db&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FgiamgWvCHDYbGsrAZmL0Ig3Vn1FEH6Y71Ve6MnTtBJ1h5Fh7ib4CjfiaiaF17ulaKzTXMbmAGw5QQXXsibDpynHcTzfyxagZCTyuZwW6pcNgj9Pw%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;"><span style="font-size: 15px;color: rgb(62, 62, 62);"><span leaf=""><span textstyle="" style="font-size: 12px;color: rgb(62, 62, 62);">一台 SGI Origin 2000 服务器，VMware 创始人当年在斯坦福大学使用的正是同型号设备</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">如果说 Backrub（Google 的前身）是 90 年代中期斯坦福大学最重要的科研实验，<span textstyle="" style="font-weight: bold;">那 Disco 项目，也就是 VMware 的技术源头，绝对可以排到第二位。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">该项目由博士生 Edouard Bugnion、Scott Devine，以及导师 Mendel Rosenblum 主导开发，目标是破解种种阻碍虚拟机发挥全部能力的技术难题。在 1997 年发表的研究论文《Disco：在可扩展多处理器上运行通用操作系统》中，研究团队探讨了虚拟机与宿主机之间的资源共享机制。论文写道：</span></span></p><div data-tools="135编辑器" data-id="5" data-color="rgb(198, 198, 199)" data-custom="rgb(198, 198, 199)" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;border: 0px none;z-index: 0;max-width: 100%;font-size: 16px;widows: 1;visibility: visible;" data-pm-slice="0 0 []"><div style="max-inline-size: 100%;margin: 2px auto;padding: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;max-width: 100%;font-size: 14px;line-height: 25px;border-width: 2px;border-style: dashed;border-color: #c6c6c7;visibility: visible;"><p style="line-height: 1.75em;"><span style="color: rgb(62, 62, 62);caret-color: red;"><span leaf="">Disco 具备多项特性，能够缓解甚至消除传统虚拟机监视器存在的各类问题。具体来说，它大幅降低虚拟机带来的性能开销，提升同一台主机上多个虚拟机之间的资源共享能力。</span></span></p><p style="line-height: 1.75em;"><span style="color: rgb(62, 62, 62);caret-color: red;"><span leaf="">Disco 支持不同虚拟机内运行的操作系统，通过 NFS、TCP/IP 这类标准分布式系统协议实现互联。同时它还能在虚拟机之间高效共享内存与磁盘资源。依托这套共享机制，Disco 可以维护一个全局缓冲区缓存，所有虚拟机都能透明共用这份缓存，即便虚拟机之间是通过标准分布式协议通信。</span></span></p></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这和 System/360 时代需要为每一台独立虚拟机配备专属硬件的模式相比，无疑是巨大的转变。计算机行业从远程桌面这类技术实践，以及 SoftWindows、VirtualPC 这类模拟器产品中获得启发：<span textstyle="" style="font-weight: bold;">我们完全可以通过软件虚拟化运行环境，实现硬件组件的复用。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" alt="迪斯科纸.jpg" class="rich_pages wxw-img" data-ratio="0.747172859450727" data-type="jpeg" data-w="1238" style="width:100%;" data-backw="578" data-backh="432" data-imgfileid="100154377" src="https://wechat2rss.xlab.app/img-proxy/?k=29aab720&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FgiamgWvCHDYYfVqfibhfuj9Thb8yRhlHyaCES1qwws7nDABX5udV5AoXhxDnw9avEegOwvlgzCC3e5GAMwV7Ex4BQuuUAEeEOvApDT62o5FL4%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;"><span style="font-size: 15px;color: rgb(62, 62, 62);"><span leaf=""><span textstyle="" style="font-size: 12px;color: rgb(62, 62, 62);">论文的 HTML 版本，由互联网档案馆（Internet Archive）永久存档</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Disco 实验脱胎于 Rosenblum 主导的 SimOS 项目。SimOS 是 Rosenblum 与其他研究人员基于 IRIX 搭建的前期研究项目，目标是完全依靠软件来模拟整套计算环境。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">该项目最初是为了帮助斯坦福大学自研一款名为 Flash 的处理器而启动，但后续它成为实现虚拟机、以及一套用来统筹全部资源的极简操作系统层 SlimOS 的关键基础。</span></span></p><div data-role="paragraph" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="color: #7f7f7f;font-size: 15px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">为什么选 Silicon Graphics？当时多核处理器还相当罕见，而 SGI Origin 2000 是市场上少数能处理这类任务的系统之一，充足的性能余量让他们可以做更极端的测试。</span></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" alt="disco_chart.jpg" class="rich_pages wxw-img" data-ratio="0.9688279301745636" data-type="jpeg" data-w="802" style="width:100%;" data-backw="578" data-backh="560" data-imgfileid="100154378" src="https://wechat2rss.xlab.app/img-proxy/?k=cb40a786&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYZ1wAQPbCdPOyjNgKOuZiaOwqhZ4zUHlaaALXULVRTdicWJqWWWh0qribQgmeNnygBYqW1bkHTcaia8n0odwmHQDdicqK1nU9XK1RbQ%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;"><span style="font-size: 15px;color: rgb(62, 62, 62);"><span leaf=""><span textstyle="" style="font-size: 12px;color: rgb(62, 62, 62);">研究发现，将 hypervisor 与即时编译结合使用，只会带来极小的性能损耗。这是一项重大突破，也可以说是 VMware 整套商业模式的根基</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">而实验验证了这套模型。综合性能来看，整体开销处于可控范围。这意味着<span textstyle="" style="font-weight: bold;">理论上可以借助 hypervisor，把一台物理机器切分成多个独立分区，每个分区各自运行不同的任务。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">论文的结尾是这样写的：</span></span></p><div data-tools="135编辑器" data-id="5" data-color="rgb(198, 198, 199)" data-custom="rgb(198, 198, 199)" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;border: 0px none;z-index: 0;max-width: 100%;font-size: 16px;widows: 1;visibility: visible;" data-pm-slice="0 0 []"><div style="max-inline-size: 100%;margin: 2px auto;padding: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;max-width: 100%;font-size: 14px;line-height: 25px;border-width: 2px;border-style: dashed;border-color: #c6c6c7;visibility: visible;"><p style="line-height: 1.75em;"><span style="color: rgb(62, 62, 62);caret-color: red;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">当代计算机系统的发展推动了虚拟机监视器的再度兴起。尽管操作系统与应用程序的体量和复杂度持续增长，但机器级接口却一直保持相对简洁。运行在这一层的软件本身并不复杂，同时还能提供必要的兼容性，充分利用已有的大量操作系统与应用程序。我们希望进一步探索虚拟机监视器，以此应对现代计算机系统与日俱增的复杂性。</span></span></span></p></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这篇论文在行业内掀起巨大反响。论文发表还不到一年，Bugnion、Devine 与 Rosenblum 三人就成了 VMware 的联合创始人。Rosenblum 的妻子 Diane Greene，一名曾任职于 SGI 的工程师，成为第四位创始人。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">论文发布仅仅两年后，VMware 便迅速崭露头角：经过一整年的秘密研发，基于 Disco 改造、可运行在 Windows 和 Linux 平台上的 VMware Workstation，在 1999 年初一经推出便轰动业界。</span></span></p><div data-role="paragraph" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;" data-pm-slice="0 0 []"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="color: #7f7f7f;font-size: 15px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="" data-pm-slice="1 1 [&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;outer&#34;,&#34;class&#34;:&#34;article135&#34;,&#34;label&#34;:&#34;edit by 135editor&#34;,&#34;data-pm-slice&#34;:&#34;0 0 []&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;paragraph&#34;,&#34;class&#34;:&#34;_135editor&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;p&#34;,&#34;attributes&#34;:{&#34;style&#34;:&#34;line-height:1.75;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;node&#34;,{&#34;tagName&#34;:&#34;span&#34;,&#34;attributes&#34;:{&#34;style&#34;:&#34;font-size: 15px; color: #3e3e3e;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;}]">《InfoWorld》早期一篇文章还引用过一位 IT 顾问的质疑言论。当时谁也料想不到，这款产品之后会深度重塑他们的工作。</span></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">数十年之后，几位研究者发表了一篇后续论文，复盘初代 VMware Workstation 的完整开发历程。这篇文章写于几位创始人离开公司多年之后，文中提到，x86 错综复杂的指令集，再加上五花八门的外设生态，带来了极高的额外开发复杂度。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">而各个操作系统本身也带来不少麻烦，他们只能逐个去做适配。Linux 还算好办，Windows 难度很高，OS/2 几乎无从下手。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">正如作者所写，IBM 当年和微软竞争的这套系统封闭性太强，根本不具备实现条件：</span></span></p><div data-tools="135编辑器" data-id="5" data-color="rgb(198, 198, 199)" data-custom="rgb(198, 198, 199)" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;border: 0px none;z-index: 0;max-width: 100%;font-size: 16px;widows: 1;visibility: visible;" data-pm-slice="0 0 []"><div style="max-inline-size: 100%;margin: 2px auto;padding: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;max-width: 100%;font-size: 14px;line-height: 25px;border-width: 2px;border-style: dashed;border-color: #c6c6c7;visibility: visible;"><p style="line-height: 1.75em;"><span style="color: rgb(62, 62, 62);caret-color: red;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">尽管我们开发的 VMM 并不依赖客户操作系统内部的语义与接口，但必须充分理解客户系统对硬件的配置方式。举个典型例子：我们曾考虑支持 IBM 的老旧操作系统 OS/2。OS/2 大量用到 x86 架构里的多项特性，这些特性在其他客户操作系统中从未出现。而且它使用这些特性的方式，让虚拟化实现变得格外困难。尽管我们投入大量时间做针对 OS/2 的专项优化，最后还是放弃了这项工作。</span></span></span></p></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">开发各类硬件驱动、处理各种边界场景，甚至还要造出一些只存在于软件中的虚拟硬件，这些工作耗费了大量时间，但回报十分丰厚。这家自筹资金的公司，短短几个月营收就达到了 500 万美元。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">以当时的标准来看，这款软件很快走向大众市场。</span>据报道，时任公司 CEO 的 Greene 提到，公司甚至收到过泰国佛教僧侣发来的邮件，僧侣们内部产生分歧：电脑上到底该装 Linux，还是 Windows。而 VMware 刚好帮他们两全其美。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">“1998 年我们起草 VMware 商业计划书的时候，万万没有想到泰国的佛教僧侣会成为我们的客户群体。”在1999年《今日美国》的一篇人物报道中，Greene表示，“但能做到真正全球化，确实很有意思。”</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">当然，僧侣只是一个缩影。如果你了解如今的 VMware 就会知道，Workstation 仅仅是这家庞大企业很小的一块业务。虚拟机拥有成千上万种实用场景，可以用于安全隔离与系统维护。举个例子：想给数千名员工的手机部署企业内部应用，同时又要和手机上其他数据隔离开？把应用跑在虚拟机里就可以。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" alt="vmware-workstation-haiku.jpg" class="rich_pages wxw-img" data-ratio="0.9025" data-type="jpeg" data-w="800" style="width:100%;" data-backw="578" data-backh="522" data-imgfileid="100154381" src="https://wechat2rss.xlab.app/img-proxy/?k=0ae06754&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FgiamgWvCHDYYNJicHYibHNe7SfJcaG0icmcglqgpZ3icb3MAnAEn7uNwMDZjTON66iaH4ANk3qFZ9QV6oxIIu2mu9ia0FHDP4aV6eEvLqsEwJLGGr0%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;"><span style="font-size: 15px;color: rgb(62, 62, 62);"><span leaf=""><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">VMware Workstation 运行的是基于 BeOS 的 Haiku 操作系统，这算是典型的极客虚拟机使用场景</span></span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">四、当硬件开始追赶软件</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">不到十年时间，Greene 与 Rosenblum 带领公司完成上市，然后以超过6亿美元的价格出售。又过了二十年，历经多轮并购与业务分拆，这笔业务最终的交易估值达到上市时的百倍。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">而这一切发生的时候，现代虚拟机那些人性化的体验特性还尚未出现，VMware 也几乎没有像样的竞争对手。直到 2000 年代中期，英特尔与 AMD 才在芯片中加入原生硬件虚拟化支持。与此同时，微软在 2003 年收购了虚拟化领域当时唯一真正的竞争对手 Connectix。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Mac 平台上广受欢迎的虚拟机软件 Parallels 直到 2006 年才问世；而 Xen、QEMU、VirtualBox、Proxmox 这些知名开源虚拟化项目，也都是 2000 年代中期才逐渐走入大众视野。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">换句话说，<span textstyle="" style="font-weight: bold;">VMware 凭借数年的先发优势，主导了虚拟化市场。</span>这也在很大程度上解释了，为什么这家企业能长期在企业级市场占据举足轻重的地位。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">2006 年，亚马逊正式发布了 Elastic Compute Cloud（EC2）平台，它堪称现代云计算最核心的基石之一。<span textstyle="" style="font-weight: bold;">虽然 EC2 并没有采用 VMware 的技术，但它却印证了 VMware 最终重塑整个计算行业的发展方向。</span>EC2 最初选用的是 Xen hypervisor，而 Xen 能够释放出强大能力，离不开 CPU 层面的硬件虚拟化支持。很大程度上，正是受到 VMware 的推动，英特尔和 AMD 才在自家处理器中加入了这套虚拟化硬件特性。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">下面这个观点或许会有些争议：VMware 的成功，也是 x86 架构能够延续生命力的重要因素。当年英特尔花费数十亿美元试图推出全新架构的新一代处理器安腾，想把它推成行业主流。就像电影《Mean Girls》里硬要把新词 “fetch” 炒火的桥段，到头来，只有惠普还在硬撑这套架构。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">毕竟，VMware 用 hypervisor 的创新实践证明：即便 x86 在虚拟化方面先天缺陷重重，也可以通过技术手段绕开这些痛点，而且还不用破坏英特尔原有的安全模型。既然现有的 x86 架构潜力都能被挖掘到这种程度，那又何必迁移到新架构？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">VMware 这项重大创新虽然诞生于一台 SGI 机器之上，但它实实在在为摩尔定律续上了生命力。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">五、VMware 的黄昏与虚拟化的永生</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">VMware 作为亲手开辟了一整个产品赛道的企业级巨头，虽然在现代科技领域拥有举足轻重的地位，但如今早已不复往日荣光。过去这两年，它被博通收购。<span textstyle="" style="font-weight: bold;">博通大刀阔斧，重塑商业模式，追求更高盈利，彻底抛弃了一次性永久授权的模式。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">正如 CIO Dive 在 2024 年所言：</span></span></p><div data-tools="135编辑器" data-id="5" data-color="rgb(198, 198, 199)" data-custom="rgb(198, 198, 199)" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;border: 0px none;z-index: 0;max-width: 100%;font-size: 16px;widows: 1;visibility: visible;" data-pm-slice="0 0 []"><div style="max-inline-size: 100%;margin: 2px auto;padding: 15px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: 0px;max-width: 100%;font-size: 14px;line-height: 25px;border-width: 2px;border-style: dashed;border-color: #c6c6c7;visibility: visible;"><p style="line-height: 1.75em;"><span style="color: rgb(62, 62, 62);caret-color: red;"><span leaf=""><span textstyle="" style="color: rgb(62, 62, 62);">这场变革在 2024 年掀起企业 IT 界的大地震。诚然，生成式 AI 也带来不小的行业冲击，但它尚未实现大规模落地。可 VMware 的收购，以及随之而来的授权规则变动，却动摇了企业的核心基础设施，扰乱关键业务流程，还大幅推高了 IT 开支。</span></span></span></p></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">不久前，它旗下 ESXi 软件还爆出了一起备受关注的零日安全漏洞事件。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">VMware 的创始团队早在近二十年前就已离开。2016 年戴尔收购这家公司的时候，主力产品 Workstation 的整个开发团队遭到解散。说实话，这件事也侧面说明：Workstation 并不是真正的利润来源。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">如今，实现虚拟化、做资源解耦的选择已经非常多。QEMU 这类工具构建起庞大的技术生态；Docker、Podman 等软件，更是把虚拟化能力融入大量日常开发工作流。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;"><span leaf="">近期，博通开始免费提供 VMware Workstation。</span></span><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;"><span leaf="">这款软件正是 VMware 的开山之作。博通此前的政策一直摇摆不定：</span></span><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;"><span leaf="">此前它已经取消过这款软件的免费版本。但在现代硬件上，实现操作系统虚拟化的方案已经有几十种，Workstation 以及 Mac 端对应产品 Fusion，早已不再具备开创性。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">没错，VMware 开创了先河，无数厂商都在它的技术地基之上继续建设。我们今天的数字经济，正是建立在层层嵌套的虚拟机之上。博通完全可以把这款标志性工具变成一款亏本引流产品：就是它，曾经既可以让僧侣共用一台电脑，又能帮助财富五百强企业完成老旧硬件体系的现代化改造。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">VMware 能被以超过 600 亿美元的价格收购，自有其道理。这恰恰印证了它最初构想的内在价值：<span textstyle="" style="font-weight: normal;">与其部署一大堆只能跑少量业务的计算机，不如用少量机器同时运行大量虚拟实例，这样会更有利。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">不过，当初整个计算机行业并没有预料到：<span textstyle="" style="font-weight: bold;">虚拟化技术，反倒进一步推高了对计算机硬件的整体需求。</span></span></span></p><div data-tools="135编辑器" data-id="85988" data-color="#138bde" data-custom="#138bde" style=""><div style="margin: 0px auto;padding: 0px;border: none;display: inline-block;width: 100%;max-width: 100% !important;box-sizing:border-box;" data-width="100%"><p style="margin: 0px;padding: 0px;font-size: 18px;letter-spacing: -2px;display: inline-block;box-sizing: border-box;font-family:sans-serif;"><span style="font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span style="color: #138bde;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: #138bde;opacity: 0.7;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: #138bde;opacity: 0.5;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: #138bde;opacity: 0.3;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span></strong></span></p><div style="margin-left: 10px;color: #138bde;display: inline-block;"><p data-brushtype="text" style="font-size: 16px;color: inherit;margin-top: 0px;margin-bottom: 0px;"><span style="font-family:Helvetica Neue, Helvetica, Hiragino Sans GB, Apple Color Emoji, Emoji Symbols Font, Segoe UI Symbol, Arial, sans-serif;"><strong><span leaf="">番外：你可能不知道的五个虚拟化冷知识</span></strong></span></p></div></div></div><p style="line-height: 1.75;text-align: center;"><span style="font-size: 15px;color: rgb(62, 62, 62);"><span leaf=""><img data-aistatus="1" alt="960px-Zork-photo.jpg" class="rich_pages wxw-img" data-ratio="1.5" data-type="jpeg" data-w="960" style="width:100%;" data-backw="578" data-backh="867" data-imgfileid="100154380" src="https://wechat2rss.xlab.app/img-proxy/?k=0539f085&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYaNsG3S4WhicSicuwvjkMx7mClDiakMeH7j7bwUNIaQ8P92pGY9UBUaWskQqicyf2TjQWaFX4Peib2Ix4HCrQOgTW9R1ibeg3vA50qHI%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;"><span style="font-size: 15px;color: rgb(62, 62, 62);"><span leaf=""><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">得益于 Zork 内置的虚拟机，这款游戏在 iPhone 和 Kaypro II 上都可以正常游玩</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">1）Zork 能在命令行时代走红，虚拟化功不可没。</span>Zork 系列的开发方 Infocom 做了一款轻量虚拟机 Z-machine，大幅降低这款热门游戏向不同设备移植的难度。当年各类计算机软硬件互不兼容，这套方案是非常关键的产品策略：团队不用针对每一台新机器重写完整游戏，只需要为不同平台单独开发对应的解释器。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">2）有一款知名游戏模拟器，本质其实是虚拟机。</span>ScummVM 可以运行 LucasArts 使用 SCUMM 引擎开发的游戏，底层思路和 Z-machine 很像，只是组件更新，并且用现代语言重构，用来解析这些老游戏。尽管名字里自带 VM，很多人依旧误以为它只是硬件模拟器。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">3）早在 386 处理器时代，就已经出现硬件虚拟化雏形。</span>虽然和我们今天使用的硬件虚拟化不是一回事，但从 386 开始，x86 芯片就内置了虚拟 8086 模式（Virtual-8086 mode）。借助这个特殊模式，386 处理器可以运行老旧的 8086 软件。Desqview、Windows 3.1 这类软件正是利用这个特性，为用户提供多任务能力。x64 架构取消了这个模式，直到 Intel 和 AMD 推出各自的硬件虚拟化扩展，同类能力才重新回归。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">4）虚拟机可以直接调用物理 GPU。</span>Linux 的 KVM 技术，脱胎于 70 年代 IBM System/360 的虚拟化思路，并且做了深度升级，支持虚拟机直接访问物理硬件，高端显卡也能直接透传给虚拟机。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">5）虚拟化是老旧嵌入式系统现代化改造的核心手段。</span>像飞机这类大型装备，不可能仅仅因为配套软件老旧就直接退役。更可行的办法是：换掉维修困难的老旧硬件，改用更现代、模块化的新硬件，再在新平台上通过虚拟化继续运行原有软件。航空航天设备以及很多难以替换的工业设备，都在用这种方案。</span></span></p></div><div data-role="paragraph" style="font-family:sans-serif;"><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">作者丨Ernie Smith</span><span style="color: #888888;font-size: 14px;letter-spacing: 0.5px;text-align: justify;text-decoration-thickness: initial;display: inline !important;font-family:Helvetica, Arial, sans-serif;"><span leaf="">      编译丨dbaplus社群</span></span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;text-align: left;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">来源丨网址：<a href="https://tedium.co/2026/01/12/vmware-virtualization-history/" target="_blank">https://tedium.co/2026/01/12/vmware-virtualization-history/</a></span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">dbaplus社群欢迎广大技术人员投稿，投稿邮箱：</span></span><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">editor@dbaplus.cn</span></span></p></div></div><p class="mp_profile_iframe_wrp" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-service_type="1" data-verify_status="2"></mp-common-profile></p><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.07777777777777778" data-s="300,640" data-w="1080" type="block" data-imgfileid="100130225" src="https://wechat2rss.xlab.app/img-proxy/?k=f32823a4&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FufWcjcomw8Zf2jiaBBH3vdgfP4A2rem5YEAHYH074dc4GibhojA5B3lLZrXLDRciaVnficveaHcAUCiaIPoDsTkAduA%2F640%3Fwx_fmt%3Dpng"/></p><p style="display: none;"><mp-style-type data-value="3"></mp-style-type></p>



<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=b2abfe78&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzkzMjYzNjkzNw%3D%3D%26mid%3D2247638280%26idx%3D1%26sn%3Dfa3a6f47d1072d43163eda876a37e597">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Mon, 26 Oct 2026 07:15:00 +0800</pubDate>
    </item>
    <item>
      <title>被难住了！如何设计一个十亿级QPS的URL短链系统？</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzkzMjYzNjkzNw==&amp;mid=2247638279&amp;idx=1&amp;sn=de4966a934e8adc72febc2d423f08ef9</link>
      <description>从全局出发、层层递-进、权衡利弊的系统化思维方式，尤为重要！</description>
      <content:encoded><![CDATA[<p><span>IT杨秀才</span> <span>2026-10-25 08:00</span> <span style="display: inline-block;">广东</span></p>




  <p>以下文章来源于：IT杨秀才</p>
  <strong>IT杨秀才</strong>
  <p>秀才的学习网站：https://golangstar.cn/</p>



  
  <p><img src="https://wechat2rss.xlab.app/img-proxy/?k=d43904fb&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FvCTfE5pGMr9Jucy98W02YMcdgV1g3dNBnxUDHexPSqbGtciauexWYbnwibWaAUu53aNlQE6iclm8RKKA7icxtqSLIg%2F0%3Fwx_fmt%3Djpeg"/></p>
  <p>从全局出发、层层递-进、权衡利弊的系统化思维方式，尤为重要！</p>
  <div data-role="outer" label="edit by 135editor" data-tplid="291729" data-pm-slice="0 0 []"><div data-tools="135编辑器" data-id="us-3745001"><div style="box-sizing: border-box;padding:0 5px;"><div data-role="paragraph" style=""><div data-role="paragraph" style=""><div data-role="paragraph" style="font-family:sans-serif;"><p class="mp_profile_iframe_wrp" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-service_type="1" data-verify_status="2"></mp-common-profile></p></div><div data-role="paragraph" style="font-family:sans-serif;"><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">在后端面试中，系统设计题是检验一位工程师架构思维和技术深度的试金石。其中，“设计一个短链系统”可以说是最高频的题目之一。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这个问题看似简单——不就是把长网址变短吗？但如果你真的这么认为，那可能就危险了。一个看似基础的功能背后，隐藏着海量数据存储、高并发处理、服务高可用等一系列复杂的工程挑战。面试官抛出这个问题，正是想看看你如何抽丝剥茧，从一个简单的需求出发，逐步构建出一个稳健、高效、可扩展的十亿级系统。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">今天，笔者就带大家来模拟一次真实的面试过程，一步步剖析如何完美地回答这个问题，让你在面试中脱颖而出。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">一、什么是短链系统？</span></strong></span></p></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">首先，我们得确保和面试官在同一个“频道”上。短链系统，顾名思义，就是将一个冗长的URL（例如一篇新闻的链接）转换成一个非常短的URL。当用户访问这个短链接时，系统会自动将他重定向到原始的长链接地址。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这个过程的核心在于“生成”和“重定向”。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.637962962962963" data-w="1080" style="width:100%;" data-backw="568" data-backh="362" src="https://wechat2rss.xlab.app/img-proxy/?k=eb7608ae&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FfjW5u71LIiad2UJ7IwGpiaX03QvFBL0C4wBMeQySyQNISnKQRia962shZyHvgcOFaoGIoibM52iboFfEv8btibBgnBZQ%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg%26watermark%3D1"/></span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">上图清晰地展示了整个交互流程：</span></span></p><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">1）生成：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">应用程序将原始长URL发送给短链系统。</span></span></p><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">2）返回：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">短链系统生成一个唯一的短URL，并返回给应用程序。</span></span></p><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">3）访问：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">用户点击短URL。</span></span></p><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">4）重定向：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">浏览器访问短链系统，系统查询到原始长URL后，返回一个HTTP 302重定向响应，浏览器随即访问原始的URL目标服务器。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">二、为什么我们需要URL短链系统？</span></strong></span></p></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">明确了“是什么”，接下来就要理解“为什么”。在面试中，能清晰地阐述一个技术的业务价值，是体现你商业思考和产品思维的加分项。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">URL短链系统的价值主要体现在以下几个方面：</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">1、美观与便捷</span></strong></span></p></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">在社交媒体（如微博）、短信、二维码等对字符长度有限制的场景下，短链接是刚需。它更易于分享、打印和口头传播，用户也更不容易输错。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">2、数据追踪与分析</span></strong></span></p></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这是短链接一个非常核心的商业价值。通过在短链接的重定向上增加统计逻辑，我们可以追踪到链接的点击次数、点击来源、用户地域分布、设备信息等，为运营决策和广告效果衡量提供精准的数据支持。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">3、功能扩展</span></strong></span></p></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">短链接可以作为一层中间代理，在这层代理上我们可以实现很多高级功能，比如链接的有效期控制、访问密码保护、设备跳转控制（移动端和PC端访问跳转到不同页面）等。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">4、隐藏原始链接</span></strong></span></p></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">在某些推广场景下，可以隐藏真实的、带有复杂参数的原始URL。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">比如，一个很长的商品链接：</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><a href="https://www.designsystem/shyfeawou/csline/ccosifhyew/online-course/clare-system-design-interview" target="_blank">https://www.designsystem/shyfeawou/csline/ccosifhyew/online-course/clare-system-design-interview</a></span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">可以被缩短为：</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><a href="https://tinyurl.com/vzxt58la" target="_blank">https://tinyurl.com/vzxt58la</a></span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">长度缩短了近三分之二，无论是在哪个场景下使用，都显得清爽利落。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">三、 面试实战指南</span></strong></span></p></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">好了，背景知识铺垫完毕，现在正式进入面试环节。系统设计题的回答，切忌一上来就抛出最终方案。一个优秀的回答过程，应该像一次与面试官共同探索的旅程，充满互动和逐步深入的思考。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf=""> 需求分析：一切设计的起点</span></strong></span></p></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">面试官：“我们来聊聊系统设计吧。如果要你设计一个高性能的短链系统，你会怎么入手？”</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这是一个开放性问题，千万不要直接回答：“我会用Redis、用哈希算法……”。正确的起手式是<span textstyle="" style="font-weight: bold;">确认需求</span>。这能体现你严谨的工程素养。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">你可以这样回应：</span></span></p><div data-tools="135编辑器" data-id="88516" style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;color: #333333;font-size: 17px;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, Arial, sans-serif;"><div style="margin: 0.5em 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><div style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;line-height: 1.75em;"><div data-width="100%" style="margin: -10px 0px;padding: 0px 10px;max-width: 100%;display: inline-block;vertical-align: top;width: 100%;word-wrap: break-word !important;box-sizing:border-box;"><div hm_fix="461:527" style="margin: 0px;padding: 10px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;border-width: 2px;border-style: solid;border-color: white;background-color: #efefef;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="font-size: 15px;color: #7f7f7f;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf="">“在开始设计之前，我想先和您明确一下系统的具体需求和目标范围，这样我们的讨论会更有针对性。比如，我们需要支持哪些核心功能？对系统的性能和可用性有什么样的要求？”</span></span></p></div></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">通过这样的提问，你就把问题抛给了面试官，也展示了你的专业性。并且更重要的是，可以从面试官那里确认出这个系统的一个大概的需求范围。假设经过沟通，你们明确了以下需求：</span></span></p><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">1）功能性需求：</span></span></strong></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">生成短链：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">输入一个长URL，系统能生成一个唯一的、更短的别名（短链接）。</span></span></p></li><li><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">支持自定义：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">用户可以选择性地为他们的URL指定一个有意义的自定义短链接。</span></span></p></li><li><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">重定向：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">访问短链接时，系统必须能准确、快速地重定向到原始的长链接。</span></span></p></li><li><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">过期机制：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">链接可以设置过期时间，过期后失效。</span></span></p></li></ul><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">2）非功能性需求：</span></span></strong></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">高可用：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">系统必须7x24小时可用。因为一旦服务宕机，所有短链接都将失效，这在很多场景下是灾难性的。</span></span></p></li><li><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">高性能：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">重定向过程必须延迟极低，用户几乎无感知。</span></span></p></li><li><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">唯一且不可预测：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">生成的短链接必须是唯一的，并且不能被轻易地猜到规律，以防被恶意遍历。</span></span></p></li></ul><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">3）扩展性需求：</span></span></strong></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">数据分析：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">需要支持统计短链接的访问数据。</span></span></p></li><li><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">开放API：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">系统应提供REST API，方便其他服务接入。</span></span></p></li></ul><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">容量预估：用数据指导架构</span></strong></span></p></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">需求明确了，下一步就要进行一个容量预估了。对于后端设计者而言，必须要做一个容量的估算，这样才方便我们选定合适的方案。</span></span></p><div data-tools="135编辑器" data-id="88516" style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;color: #333333;font-size: 17px;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, Arial, sans-serif;"><div style="margin: 0.5em 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><div style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;line-height: 1.75em;"><div data-width="100%" style="margin: -10px 0px;padding: 0px 10px;max-width: 100%;display: inline-block;vertical-align: top;width: 100%;word-wrap: break-word !important;box-sizing:border-box;"><div hm_fix="461:527" style="margin: 0px;padding: 10px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;border-width: 2px;border-style: solid;border-color: white;background-color: #efefef;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="font-size: 15px;color: #7f7f7f;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf="">“需求很清晰了。接下来，我想做一个简单的容量预估，这有助于我们判断系统的量级，从而选择合适的技术方案。”</span></span></p></div></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这是展示你架构设计能力的关键一步。没有数据支撑的设计都是空中楼阁。</span></span></p><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">1）流量估算</span></span></strong></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">假设我们是一个快速发展的业务，预计每月新增5亿个短链接。短链系统的读写比通常非常悬殊，读取（重定向）远多于写入（生成）。我们假设读写比例为 100:1。</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">写入QPS：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">每月5亿次写入，那么每秒的写入请求大约是 5亿 / (30天 * 24小时 * 3600秒) ≈ 200次/秒。</span></span></p></li><li><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">读取QPS：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">根据100:1的读写比，读取请求大约是 200 * 100 = 2万次/秒。这个并发量已经不低了。</span></span></p></li></ul><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">2）存储估算</span></span></strong></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">假设每个短链接数据（包括长URL、短URL、创建时间、用户ID等）我们存储5年。</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">总记录数：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">5亿/月 * 12个月/年 * 5年 = 300亿。这是一个非常庞大的数字。</span></span></p></li><li><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">单条记录大小：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">我们粗略估计每条记录为500字节。</span></span></p></li><li><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">总存储空间：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">300亿 * 500字节 ≈ 15TB。这个存储需求对于单机数据库来说是无法承受的。</span></span></p></li></ul><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">3）带宽估算：</span></span></strong></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">入口带宽（写）：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">200次/秒 * 500字节/次 ≈ 100 KB/s。</span></span></p></li><li><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">出口带宽（读）：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">2万次/秒 * 500字节/次 ≈ 10 MB/s。</span></span></p></li></ul><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">4）缓存估算：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">为了提升读取性能，缓存是必不可少的。根据二八原则，80%的访问量集中在20%的热点链接上。</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">每日总请求数：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">2万次/秒 * 3600秒/小时 * 24小时/天 ≈ 17亿次。</span></span></p></li><li><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">缓存目标：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">我们需要缓存这17亿次请求中的20%。</span></span></p></li><li><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">所需内存：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">17亿 * 20% * 500字节 ≈ 170GB。</span></span></p></li></ul><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">将这些估算结果汇总成一个表格，展示给面试官，会显得非常专业：</span></span></p><p data-tool="mdnice编辑器" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgba(0, 0, 0, 0.9);font-family: &#34;PingFang SC&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 17px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: 0.544px;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;overflow-x: auto;" data-pm-slice="0 0 []"><table style="-webkit-tap-highlight-color: transparent;margin: 0px 0px 10px;padding: 0px;outline: 0px;border-collapse: collapse;display: table;width: 677px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;text-align: left;"><thead><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><th style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(240, 240, 240);max-width: 100%;box-sizing: border-box !important;color: rgb(0, 0, 0);font-size: 14px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;height: auto;border-radius: 0px;min-width: 85px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">指标</span></span></p></th><th style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(240, 240, 240);max-width: 100%;box-sizing: border-box !important;color: rgb(0, 0, 0);font-size: 14px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;height: auto;border-radius: 0px;min-width: 85px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">估算值</span></span></p></th></tr></thead><tbody><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(255, 255, 255);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">新增URL（写QPS）</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">~200/s</span></span></p></td></tr><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(248, 248, 248);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">URL重定向（读QPS）</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">~20K/s</span></span></p></td></tr><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(255, 255, 255);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">入口带宽</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">100KB/s</span></span></p></td></tr><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(248, 248, 248);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">出口带宽</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">10MB/s</span></span></p></td></tr><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(255, 255, 255);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">5年总存储</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">15TB</span></span></p></td></tr><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(248, 248, 248);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">缓存所需内存</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">170GB</span></span></p></td></tr></tbody></table></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">通过估算，我们可以看到，这个系统面临的是<span textstyle="" style="font-weight: bold;">高并发读取</span><span textstyle="" style="font-weight: normal;">和</span><span textstyle="" style="font-weight: bold;">海量数据存储</span>两大挑战。这将是我们后续架构设计的核心出发点。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">系统接口定义（API Design）</span></strong></span></p></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">在宏观设计之前，先定义微观的接口，是一种自底向上的优秀设计习惯。这有助于我们厘清系统的边界和能力。</span></span></p><div data-tools="135编辑器" data-id="88516" style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;color: #333333;font-size: 17px;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, Arial, sans-serif;"><div style="margin: 0.5em 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><div style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;line-height: 1.75em;"><div data-width="100%" style="margin: -10px 0px;padding: 0px 10px;max-width: 100%;display: inline-block;vertical-align: top;width: 100%;word-wrap: break-word !important;box-sizing:border-box;"><div hm_fix="461:527" style="margin: 0px;padding: 10px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;border-width: 2px;border-style: solid;border-color: white;background-color: #efefef;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="font-size: 15px;color: #7f7f7f;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf="">“接下来我们可以设计一套RESTful API来暴露服务能力。主要包括以下几个接口：”</span></span></p></div></div></div></div></div><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">1） 创建短链 API</span></span></strong></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">请求路由：GET /{shortened_url}</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">请求参数：</span></span></p><table style="-webkit-tap-highlight-color: transparent;margin: 0px 0px 10px;padding: 0px;outline: 0px;border-collapse: collapse;display: table;width: 677px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgba(0, 0, 0, 0.9);font-family: &#34;PingFang SC&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 17px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: 0.544px;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;"><thead><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><th style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(240, 240, 240);max-width: 100%;box-sizing: border-box !important;color: rgb(0, 0, 0);font-size: 14px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;height: auto;border-radius: 0px;min-width: 85px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;">参数</span></p></th><th style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(240, 240, 240);max-width: 100%;box-sizing: border-box !important;color: rgb(0, 0, 0);font-size: 14px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;height: auto;border-radius: 0px;min-width: 85px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;">释义</span></p></th></tr></thead><tbody><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(255, 255, 255);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">original_url</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">需要缩短的原始长网址(字符串，必填)</span></span></p></td></tr><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(248, 248, 248);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">custom_alias</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">用户希望指定的短网址自定义别名(字符串，可选)</span></span></p></td></tr><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(255, 255, 255);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">expiration_date</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">短网址应过期的日期和时间(时间戳，可选)</span></span></p></td></tr><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(248, 248, 248);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">user_id</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">创建缩短 URL 的用户 ID（如果支持用户账户功能）(字符串，可选)</span></span></p></td></tr></tbody></table><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">响应参数：</span></span></p><table style="-webkit-tap-highlight-color: transparent;margin: 0px 0px 10px;padding: 0px;outline: 0px;border-collapse: collapse;display: table;width: 677px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgba(0, 0, 0, 0.9);font-family: &#34;PingFang SC&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 17px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: 0.544px;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;"><thead><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><th style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(240, 240, 240);max-width: 100%;box-sizing: border-box !important;color: rgb(0, 0, 0);font-size: 14px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;height: auto;border-radius: 0px;min-width: 85px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">参数</span></span></p></th><th style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(240, 240, 240);max-width: 100%;box-sizing: border-box !important;color: rgb(0, 0, 0);font-size: 14px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;height: auto;border-radius: 0px;min-width: 85px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">释义</span></span></p></th></tr></thead><tbody><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(255, 255, 255);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">shortened_url</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">由服务生成的缩短后 URL(字符串)</span></span></p></td></tr><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(248, 248, 248);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">creation_date</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">URL 被缩短时的日期和时间(时间戳)</span></span></p></td></tr><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(255, 255, 255);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">expiration_date</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">短网址的过期日期（时间戳，如提供）</span></span></p></td></tr></tbody></table><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">2）重定向 API</span></span></strong></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">将用户从短链接重定向至原始长网址</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">请求路由：GET /{shortened_url}</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">请求参数：</span></span></p><table style="-webkit-tap-highlight-color: transparent;margin: 0px 0px 10px;padding: 0px;outline: 0px;border-collapse: collapse;display: table;width: 677px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgba(0, 0, 0, 0.9);font-family: &#34;PingFang SC&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 17px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: 0.544px;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;"><thead><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><th style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(240, 240, 240);max-width: 100%;box-sizing: border-box !important;color: rgb(0, 0, 0);font-size: 14px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;height: auto;border-radius: 0px;min-width: 85px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">参数</span></span></p></th><th style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(240, 240, 240);max-width: 100%;box-sizing: border-box !important;color: rgb(0, 0, 0);font-size: 14px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;height: auto;border-radius: 0px;min-width: 85px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">释义</span></span></p></th></tr></thead><tbody><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(255, 255, 255);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><code style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">shortened_url</span></span></code></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">需要解析为原始网址的短链接（字符串，必填）</span></span></p></td></tr></tbody></table><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">3） 数据分析接口</span></span></strong></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">提供短链接的详细分析数据，包括点击次数和用户人口统计信息</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">请求路由：GET /analytics/{shortened_url}</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">请求参数：</span></span></p><table style="-webkit-tap-highlight-color: transparent;margin: 0px 0px 10px;padding: 0px;outline: 0px;border-collapse: collapse;display: table;width: 677px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgba(0, 0, 0, 0.9);font-family: &#34;PingFang SC&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 17px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: 0.544px;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;"><thead><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><th style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(240, 240, 240);max-width: 100%;box-sizing: border-box !important;color: rgb(0, 0, 0);font-size: 14px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;height: auto;border-radius: 0px;min-width: 85px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">参数</span></span></p></th><th style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(240, 240, 240);max-width: 100%;box-sizing: border-box !important;color: rgb(0, 0, 0);font-size: 14px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;height: auto;border-radius: 0px;min-width: 85px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">释义</span></span></p></th></tr></thead><tbody><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(255, 255, 255);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">shortened_url</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">需要获取分析数据的短链接(字符串，必填)</span></span></p></td></tr><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(248, 248, 248);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">start_date</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">用于筛选分析数据的开始日期(时间戳，可选)</span></span></p></td></tr><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(255, 255, 255);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">end_date</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">用于筛选分析数据的结束日期(时间戳，可选)</span></span></p></td></tr></tbody></table><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">响应参数：</span></span></p><table style="-webkit-tap-highlight-color: transparent;margin: 0px 0px 10px;padding: 0px;outline: 0px;border-collapse: collapse;display: table;width: 677px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgba(0, 0, 0, 0.9);font-family: &#34;PingFang SC&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 17px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: 0.544px;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;"><thead><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><th style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(240, 240, 240);max-width: 100%;box-sizing: border-box !important;color: rgb(0, 0, 0);font-size: 14px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;height: auto;border-radius: 0px;min-width: 85px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">参数</span></span></p></th><th style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(240, 240, 240);max-width: 100%;box-sizing: border-box !important;color: rgb(0, 0, 0);font-size: 14px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;height: auto;border-radius: 0px;min-width: 85px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">释义</span></span></p></th></tr></thead><tbody><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(255, 255, 255);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">click_count</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">该短链接被点击的总次数(整数)</span></span></p></td></tr><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(248, 248, 248);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">unique_clicks</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">点击该短链接的唯一用户数(整数)</span></span></p></td></tr><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(255, 255, 255);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">referring_sites</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">为该短链接带来流量的来源网站(列表)</span></span></p></td></tr><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(248, 248, 248);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">location_data</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">点击该网址的用户地理分布(地图)</span></span></p></td></tr><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(255, 255, 255);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">device_data</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">点击 URL 所使用的设备（移动设备、桌面设备等）的细分（映射）</span></span></p></td></tr></tbody></table><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">4）网址管理 API</span></span></strong></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">请求路由： GET /user/urls</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">请求参数：</span></span></p><table style="-webkit-tap-highlight-color: transparent;margin: 0px 0px 10px;padding: 0px;outline: 0px;border-collapse: collapse;display: table;width: 677px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgba(0, 0, 0, 0.9);font-family: &#34;PingFang SC&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 17px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: 0.544px;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;"><thead><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><th style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(240, 240, 240);max-width: 100%;box-sizing: border-box !important;color: rgb(0, 0, 0);font-size: 14px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;height: auto;border-radius: 0px;min-width: 85px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">参数</span></span></p></th><th style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(240, 240, 240);max-width: 100%;box-sizing: border-box !important;color: rgb(0, 0, 0);font-size: 14px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;height: auto;border-radius: 0px;min-width: 85px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">释义</span></span></p></th></tr></thead><tbody><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(255, 255, 255);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">user_id</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">请求其短网址的用户 ID(字符串, 必需)</span></span></p></td></tr><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(248, 248, 248);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">page</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">分页结果的页码(整数, 可选)</span></span></p></td></tr><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(255, 255, 255);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">page_size</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">每页的结果数量(整数，可选)</span></span></p></td></tr></tbody></table><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">响应参数：</span></span></p><table style="-webkit-tap-highlight-color: transparent;margin: 0px 0px 10px;padding: 0px;outline: 0px;border-collapse: collapse;display: table;width: 677px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgba(0, 0, 0, 0.9);font-family: &#34;PingFang SC&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 17px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: 0.544px;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;"><thead><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><th style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(240, 240, 240);max-width: 100%;box-sizing: border-box !important;color: rgb(0, 0, 0);font-size: 14px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;height: auto;border-radius: 0px;min-width: 85px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">参数</span></span></p></th><th style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(240, 240, 240);max-width: 100%;box-sizing: border-box !important;color: rgb(0, 0, 0);font-size: 14px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;height: auto;border-radius: 0px;min-width: 85px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">释义</span></span></p></th></tr></thead><tbody><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(255, 255, 255);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">urls</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">用户缩短的 URL 列表，包括创建日期和过期日期等元数据(列表)</span></span></p></td></tr></tbody></table><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">5） 删除短链接 API</span></span></strong></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">请求路由： DELETE /{shortened_url}</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">请求参数：</span></span></p><table style="-webkit-tap-highlight-color: transparent;margin: 0px 0px 10px;padding: 0px;outline: 0px;border-collapse: collapse;display: table;width: 677px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgba(0, 0, 0, 0.9);font-family: &#34;PingFang SC&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 17px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: 0.544px;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;"><thead><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><th style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(240, 240, 240);max-width: 100%;box-sizing: border-box !important;color: rgb(0, 0, 0);font-size: 14px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;height: auto;border-radius: 0px;min-width: 85px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">参数</span></span></p></th><th style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(240, 240, 240);max-width: 100%;box-sizing: border-box !important;color: rgb(0, 0, 0);font-size: 14px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;height: auto;border-radius: 0px;min-width: 85px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">释义</span></span></p></th></tr></thead><tbody><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(255, 255, 255);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">shortened_url</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">需要删除的短链接(字符串，必填)</span></span></p></td></tr><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(248, 248, 248);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">user_id</span></span></p></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">请求删除的用户 ID(字符串，必填)</span></span></p></td></tr></tbody></table><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">响应参数：</span></span></p><table style="-webkit-tap-highlight-color: transparent;margin: 0px 0px 10px;padding: 0px;outline: 0px;border-collapse: collapse;display: table;width: 677px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgba(0, 0, 0, 0.9);font-family: &#34;PingFang SC&#34;, system-ui, -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei UI&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;font-size: 17px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: 0.544px;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: left;"><thead><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><th style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(240, 240, 240);max-width: 100%;box-sizing: border-box !important;color: rgb(0, 0, 0);font-size: 14px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;height: auto;border-radius: 0px;min-width: 85px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">参数</span></span></p></th><th style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(240, 240, 240);max-width: 100%;box-sizing: border-box !important;color: rgb(0, 0, 0);font-size: 14px;line-height: 1.5em;letter-spacing: 0em;text-align: left;font-weight: bold;height: auto;border-radius: 0px;min-width: 85px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">释义</span></span></p></th></tr></thead><tbody><tr style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgb(255, 255, 255);width: auto;height: auto;"><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><code style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">status</span></span></code></td><td style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 5px 10px;outline: 0px;overflow-wrap: break-word !important;word-break: break-all;hyphens: auto;border: 1px solid rgba(204, 204, 204, 0.4);max-width: 100%;box-sizing: border-box !important;min-width: 85px;border-radius: 0px;"><p style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span leaf="" style="-webkit-tap-highlight-color: transparent;margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span textstyle="" style="font-size: 15px;">删除确认信息或操作失败时的错误提示(字符串)</span></span></p></td></tr></tbody></table><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">面试官：“接口设计得不错。但有个问题，如果恶意用户疯狂调用创建接口，把我们生成的短码耗尽了怎么办？”。这是一个很好的追问，考察你对系统安全性的思考。</span></span></p><div data-tools="135编辑器" data-id="88516" style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;color: #333333;font-size: 17px;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, Arial, sans-serif;"><div style="margin: 0.5em 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><div style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;line-height: 1.75em;"><div data-width="100%" style="margin: -10px 0px;padding: 0px 10px;max-width: 100%;display: inline-block;vertical-align: top;width: 100%;word-wrap: break-word !important;box-sizing:border-box;"><div hm_fix="461:527" style="margin: 0px;padding: 10px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;border-width: 2px;border-style: solid;border-color: white;background-color: #efefef;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="font-size: 15px;color: #7f7f7f;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf="">“如果不加限制，面对恶意调用，短url肯定很快会被耗尽。所以我们需要加入防滥用机制。核心手段是API速率限制。我们可以基于用户ID或IP地址进行限流，比如，限制每个IP每分钟只能创建10个短链接。对于未登录的匿名用户，这个限制可以更严格。”</span></span></p></div></div></div></div></div><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">数据库设计</span></strong></span></p></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">基于前面的需求和接口，我们可以设计出数据库的表结构。</span></span></p><div data-tools="135编辑器" data-id="88516" style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;color: #333333;font-size: 17px;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, Arial, sans-serif;"><div style="margin: 0.5em 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><div style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;line-height: 1.75em;"><div data-width="100%" style="margin: -10px 0px;padding: 0px 10px;max-width: 100%;display: inline-block;vertical-align: top;width: 100%;word-wrap: break-word !important;box-sizing:border-box;"><div hm_fix="461:527" style="margin: 0px;padding: 10px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;border-width: 2px;border-style: solid;border-color: white;background-color: #efefef;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="font-size: 15px;color: #7f7f7f;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf="">“考虑到300亿的记录量和高并发读取的需求，关系型数据库可能不是最佳选择。因为分库分表会非常复杂，而且我们数据之间的关系很简单。我更倾向于使用NoSQL数据库，比如AWS的DynamoDB、阿里云的Table Store (OTS) 或者开源的Riak，它们的水平扩展能力更强。”</span></span></p></div></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">我们可以设计以下几张表（以NoSQL的宽表模型为例）：</span></span></p><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">1）URL表 (url_mapping)</span></span></strong></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Hash (Partition Key): 短链码，例如 vzet59pa。这是我们的主键，用于快速查找。</span></span></p></li><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">OriginalURL: 原始长链接。</span></span></p></li><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">CreationDate: 创建时间。</span></span></p></li><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">ExpirationDate: 过期时间。</span></span></p></li><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">UserID: 创建者ID。</span></span></p></li></ul><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">2）用户表 (users)</span></span></strong></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">UserID (Partition Key): 用户ID。</span></span></p></li><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Name, Email, PasswordHash, ...</span></span></p></li></ul><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">3）分析表 (analytics)</span></span></strong></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">AnalyticsID (Partition Key): 唯一分析记录ID。</span></span></p></li><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">URLHash: 关联的短链码。</span></span></p></li><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">ClickTimestamp: 点击时间。</span></span></p></li><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">ReferringSite: 来源网站。</span></span></p></li><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Location: 地理位置。</span></span></p></li></ul><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.5861111111111111" data-w="1080" style="width:100%;" data-backw="568" data-backh="333" src="https://wechat2rss.xlab.app/img-proxy/?k=8e366b40&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FfjW5u71LIiad2UJ7IwGpiaX03QvFBL0C4wialEySicibZQL44bB5N4UFsDfSKsJvcuU1zc8uD1JhNGwEPzicZsibdM3iaQ%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg%26watermark%3D1"/></span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">核心算法：如何生成短链码？</span></strong></span></p></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">面试官：“数据库选型和表结构设计都比较合理。现在我们来聊聊最核心的部分，这个短链码（比如 vzet59pa）到底该怎么生成呢？”</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这是整个设计的灵魂。你可以提出几种方案，并分析优劣，展示你的技术广度和深度。</span></span></p><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">方案一：哈希编码</span></span></strong></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">最直接的想法是对原始长URL进行哈希，然后取一部分作为短链码。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">“一个直接的思路是对原始URL进行哈希，比如用MD5生成一个128位的哈希值，然后通过Base64编码将其转换为字符串。编码方式有很多种，比如base36 (a-z, 0-9) 或 base62 (A-Z, a-z, 0-9)，如果加上 + 和 / 就是标准的Base64编码。”</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">标准的Base64编码表如下：</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.612037037037037" data-w="1080" style="width:100%;" data-backw="568" data-backh="348" src="https://wechat2rss.xlab.app/img-proxy/?k=25f3d8c6&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FfjW5u71LIiad2UJ7IwGpiaX03QvFBL0C4wnhzcDUAcIkXvmoib9ENsZ6uYWjibtVarTQI3EuR1OJI9Ndjhficc3NibmA%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg%26watermark%3D1"/></span></span></p><div data-tools="135编辑器" data-id="88516" style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;color: #333333;font-size: 17px;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, Arial, sans-serif;"><div style="margin: 0.5em 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><div style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;line-height: 1.75em;"><div data-width="100%" style="margin: -10px 0px;padding: 0px 10px;max-width: 100%;display: inline-block;vertical-align: top;width: 100%;word-wrap: break-word !important;box-sizing:border-box;"><div hm_fix="461:527" style="margin: 0px;padding: 10px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;border-width: 2px;border-style: solid;border-color: white;background-color: #efefef;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="font-size: 15px;color: #7f7f7f;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf="">“在使用标准Base64时，我们需要考虑一个问题：短链码的长度应该设为多少？6位、8位还是10位？”</span></span></p></div></div></div></div></div><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">使用Base64编码，一个6位长度的短码，可以产生 64^6 ≈ 687亿 个可能的组合。</span></span></p></li><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">使用Base64编码，一个8位长度的短码，可以产生 64^8 ≈ 281万亿 个可能的组合。</span></span></p></li></ul><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">“假设6位长度的短码（687亿）已经足够满足我们的系统需求。如果我们使用MD5算法，它会生成一个128位的哈希值，经过Base64编码后会得到一个超过21个字符的字符串。我们只取前6位或8位作为短码，这可能会导致冲突。为了解决这个问题，我们可以采取一些策略，比如当发现冲突时，换取哈希值的其他部分，或者对原始URL加盐后重新哈希。”</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">“不过，这个方案还有几个更麻烦的问题。第一，标准Base64中的 + 和 / 字符在URL中是特殊保留字符，其中“+”和“/”在URL中会被编码为“%2B”以及“%2F”，⽽“%”在写⼊数据库的时候⼜和SQL编码规则冲突，需要进⾏再编码，因此直接使⽤标准Base64编码进⾏短URL编码并不合适，直接使用会导致问题。URL保留字符编码表如下。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.1925925925925926" data-w="1080" style="width:100%;" data-backw="568" data-backh="109" src="https://wechat2rss.xlab.app/img-proxy/?k=e0a6aaaf&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FfjW5u71LIiad2UJ7IwGpiaX03QvFBL0C4wZ9J6iaA1XqoWNd5x25ewWib4iafjBOHbpYez9t1rSxuCjqG6QVgxCRMag%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg%26watermark%3D1"/></span></span></p><div data-tools="135编辑器" data-id="88516" style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;color: #333333;font-size: 17px;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, Arial, sans-serif;"><div style="margin: 0.5em 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><div style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;line-height: 1.75em;"><div data-width="100%" style="margin: -10px 0px;padding: 0px 10px;max-width: 100%;display: inline-block;vertical-align: top;width: 100%;word-wrap: break-word !important;box-sizing:border-box;"><div hm_fix="461:527" style="margin: 0px;padding: 10px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;border-width: 2px;border-style: solid;border-color: white;background-color: #efefef;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="font-size: 15px;color: #7f7f7f;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf="">“所以，我们需要对Base64编码进行改造，使其对URL友好。一个常见的做法是<span textstyle="" style="font-weight: bold;">将 + 替换为 -，将 / 替换为 _</span>。这样改造后的字符集就完全可以在URL中安全使用了。”</span></span></p></div></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.6324074074074074" data-w="1080" style="width:100%;" data-backw="568" data-backh="359" src="https://wechat2rss.xlab.app/img-proxy/?k=fcb4e6f1&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FfjW5u71LIiad2UJ7IwGpiaX03QvFBL0C4wicfaibHRuibPjYkz6rzpVwibicmCjNvBQWp08VPukn0Xakiatiad6icJhh3ALA%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg%26watermark%3D1"/></span></span></p><div data-tools="135编辑器" data-id="88516" style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;color: #333333;font-size: 17px;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, Arial, sans-serif;"><div style="margin: 0.5em 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><div style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;line-height: 1.75em;"><div data-width="100%" style="margin: -10px 0px;padding: 0px 10px;max-width: 100%;display: inline-block;vertical-align: top;width: 100%;word-wrap: break-word !important;box-sizing:border-box;"><div hm_fix="461:527" style="margin: 0px;padding: 10px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;border-width: 2px;border-style: solid;border-color: white;background-color: #efefef;"><p style="line-height:1.75em;"><span style="font-size: 15px;color: #7f7f7f;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf="">“第二，如果多个用户输入同一个URL，他们会得到相同的短链接，这在某些需要独立追踪的场景下是不可接受的。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #7f7f7f;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf="">第三，URL的部分内容如果经过编码，例如 .../?id=design 和 .../%3Fid%3Ddesign，本质上是同一个URL，但哈希值却完全不同。针对这些问题，我们可以为每个输入URL附加一个递增的序列号或者唯一的用户ID来确保唯一性，不过这个序列号无需存入数据库。这种方法可能带来的问题是序列号会无限增长——是否存在溢出风险？同时附加递增序列号也会影响服务性能，引入新的复杂度。”</span></span></p></div></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.6175925925925926" data-w="1080" style="width:100%;" data-backw="568" data-backh="351" src="https://wechat2rss.xlab.app/img-proxy/?k=510d18ff&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FfjW5u71LIiad2UJ7IwGpiaX03QvFBL0C4wDQ57vaZCMhB6XkeJEunnTfGBrar3pW6PgmdqbrIkkTJaDWibz25lZxw%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg%26watermark%3D1"/></span></span></p><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">方案二：自增ID转码（推荐）</span></span></strong></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">我们可以有一个独立的密钥生成服务（KGS），它预先生成随机的六字母字符串并将其存储在数据库中（我们称之为 key-DB）。每当我们想要缩短一个 URL 时，我们会取一个已经生成的密钥并使用它。这种方法就简单了，我们不仅不需要对 URL 进行编码，而且也不必担心重复或冲突。KGS 将确保所有插入到 key-DB 中的密钥都是唯一的。生成六字母字符串的方式这里我们可以用<span textstyle="" style="font-weight: bold;">自增ID转码的方式来实现。</span></span></span></p><div data-tools="135编辑器" data-id="88516" style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;color: #333333;font-size: 17px;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, Arial, sans-serif;"><div style="margin: 0.5em 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><div style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;line-height: 1.75em;"><div data-width="100%" style="margin: -10px 0px;padding: 0px 10px;max-width: 100%;display: inline-block;vertical-align: top;width: 100%;word-wrap: break-word !important;box-sizing:border-box;"><div hm_fix="461:527" style="margin: 0px;padding: 10px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;border-width: 2px;border-style: solid;border-color: white;background-color: #efefef;"><p style="line-height:1.75em;"><span style="color: #7f7f7f;font-size: 15px;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf="">“考虑到哈希方案的种种复杂性，我更推荐另一种方案：<span textstyle="" style="font-weight: bold;">发号器 + 进制转换</span>。我们可以使用一个全局唯一的ID生成服务（类似Snowflake算法或数据库自增ID），每当有新的短链生成请求时，就获取一个唯一的十进制ID。”</span></span></p></div></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">比如，我们获取到了ID 10086。然后，我们将这个ID从十进制转换为62进制（a-z, A-Z, 0-9）。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">10086 (10进制) = 2Bi (62进制)</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这样，2Bi 就是我们的短链码。这个方案的优点非常突出：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">绝对唯一：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">每个ID都是唯一的，所以转换后的短链码也绝对不会冲突。</span></span></p></li><li><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">长度可控：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">生成的短链码长度是递增的，可以从很短开始，有效利用了码空间。</span></span></p></li><li><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">性能高效：</span></span></strong><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">转换过程是纯计算，速度极快。</span></span></p></li></ul><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">面试官：“这个方案听起来不错。但这个全局ID生成器不就成了系统的单点了吗？如果它挂了，整个服务就不可用了。”</span></span></p><div data-tools="135编辑器" data-id="88516" style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;color: #333333;font-size: 17px;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, Arial, sans-serif;"><div style="margin: 0.5em 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><div style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;line-height: 1.75em;"><div data-width="100%" style="margin: -10px 0px;padding: 0px 10px;max-width: 100%;display: inline-block;vertical-align: top;width: 100%;word-wrap: break-word !important;box-sizing:border-box;"><div hm_fix="461:527" style="margin: 0px;padding: 10px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;border-width: 2px;border-style: solid;border-color: white;background-color: #efefef;"><p style="line-height:1.75em;"><span style="color: #7f7f7f;font-size: 15px;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf="">“您提到了关键点。这个方案通常被称为密钥生成服务 (Key Generation Service, KGS)。为了解决单点问题，KGS本身需要设计成高可用的集群。我们可以为KGS设置备用副本，当主服务器宕机时，备用服务器就能接管。同时，KGS可以预先生成大量的唯一短码，并存入一个专用的数据库（Key-DB）。为了提升性能和可用性，我们可以设计两张表：一张存未使用的密钥，一张存已使用的。当KGS分配密钥给应用服务器时，就将其从未用表移动到已用表。KGS还可以在内存中缓存一批密钥，以便快速响应。为了避免多个应用服务器同时请求到同一个密钥，KGS在分配密钥时需要加锁同步。”</span></span></p></div></div></div></div></div><div data-tools="135编辑器" data-id="88516" style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;color: #333333;font-size: 17px;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, Arial, sans-serif;"><div style="margin: 0.5em 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><div style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;line-height: 1.75em;"><div data-width="100%" style="margin: -10px 0px;padding: 0px 10px;max-width: 100%;display: inline-block;vertical-align: top;width: 100%;word-wrap: break-word !important;box-sizing:border-box;"><div hm_fix="461:527" style="margin: 0px;padding: 10px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;border-width: 2px;border-style: solid;border-color: white;background-color: #efefef;"><p style="line-height:1.75em;"><span style="color: #7f7f7f;font-size: 15px;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf="">“<span textstyle="" style="font-weight: bold;">关于这个密钥数据库的大小，我们也可以估算一下。采用62进制，6位长度的短码，大约有</span> 62^6 ≈ 568亿 种组合。如果每个字符占1字节，那么存储所有密钥需要 6 * 568亿 ≈ 340GB 的空间。”</span></span></p></div></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.5574074074074075" data-w="1080" style="width:100%;" data-backw="568" data-backh="317" src="https://wechat2rss.xlab.app/img-proxy/?k=83488666&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FfjW5u71LIiad2UJ7IwGpiaX03QvFBL0C4wQvCs2pWCtMb72OzMkDwgctxZk0Dq2pJPoIZvgWUtcDHI5icp8iaud1Fg%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg%26watermark%3D1"/></span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">我们如何进行密钥查找？我们可以在数据库中查找该密钥以获取完整的 URL。如果该密钥存在于数据库中，则向浏览器返回一个“HTTP 302 重定向”状态，并在请求的“Location”字段中传递存储的 URL。如果该密钥不在我们的系统中，则返回一个“HTTP 404 未找到”状态或将用户重定向回主页。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">数据分区与复制</span></strong></span></p></div></div></div><div data-tools="135编辑器" data-id="88516" style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;color: #333333;font-size: 17px;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, Arial, sans-serif;"><div style="margin: 0.5em 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><div style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;line-height: 1.75em;"><div data-width="100%" style="margin: -10px 0px;padding: 0px 10px;max-width: 100%;display: inline-block;vertical-align: top;width: 100%;word-wrap: break-word !important;box-sizing:border-box;"><div hm_fix="461:527" style="margin: 0px;padding: 10px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;border-width: 2px;border-style: solid;border-color: white;background-color: #efefef;"><p style="line-height:1.75em;"><span style="color: #7f7f7f;font-size: 15px;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf="">“前面我们估算出有15TB的数据，单机数据库肯定扛不住，所以必须进行数据分区（Sharding）。”</span></span></p></div></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">面试官：“具体说说你会怎么分区？”</span></span></p><div data-tools="135编辑器" data-id="88516" style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;color: #333333;font-size: 17px;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, Arial, sans-serif;"><div style="margin: 0.5em 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><div style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;line-height: 1.75em;"><div data-width="100%" style="margin: -10px 0px;padding: 0px 10px;max-width: 100%;display: inline-block;vertical-align: top;width: 100%;word-wrap: break-word !important;box-sizing:border-box;"><div hm_fix="461:527" style="margin: 0px;padding: 10px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;border-width: 2px;border-style: solid;border-color: white;background-color: #efefef;"><p style="line-height:1.75em;"><span style="color: #7f7f7f;font-size: 15px;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf="">“主要有两种思路：”</span></span></p><p style="line-height:1.75em;"><span style="color: #7f7f7f;font-size: 15px;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">1）基于范围的分区</span></span></span></p><p style="line-height:1.75em;"><span style="color: #7f7f7f;font-size: 15px;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf="">我们可以根据短链码的首字母来分区。比如所有以&#39;a&#39;开头的存一个分片，&#39;b&#39;开头的存另一个。以此类推。这种策略称为基于范围的分区。我们甚至可以将某些出现频率较低的字母组合存入同一个数据库分区。</span></span></p></div></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这种方式实现简单，但很容易导致数据倾斜和热点问题。例如，我们决定将所有以字母&#39;E&#39;开头的 URL 存入某个数据库分区，但后来发现以&#39;E&#39;开头的 URL 数量过多。</span></span></p><div data-tools="135编辑器" data-id="88516" style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;color: #333333;font-size: 17px;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, Arial, sans-serif;"><div style="margin: 0.5em 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><div style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;line-height: 1.75em;"><div data-width="100%" style="margin: -10px 0px;padding: 0px 10px;max-width: 100%;display: inline-block;vertical-align: top;width: 100%;word-wrap: break-word !important;box-sizing:border-box;"><div hm_fix="461:527" style="margin: 0px;padding: 10px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;border-width: 2px;border-style: solid;border-color: white;background-color: #efefef;"><p style="line-height:1.75em;"><strong><span style="color: #7f7f7f;font-size: 15px;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">2）基于哈希的分区</span></span></span></strong></p><p style="line-height:1.75em;"><span style="color: #7f7f7f;font-size: 15px;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf="">这是更优的选择。我们对短链码（Hash）进行哈希计算，然后对分片总数取模，决定这条记录应该存储在哪个数据库分片上。例如 hash(short_code) % 256。这种方式能让数据均匀分布。</span></span></p><p style="line-height:1.75em;"><span style="color: #7f7f7f;font-size: 15px;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf="">为了更好地处理增删节点带来的数据迁移问题，我们还可以引入<span textstyle="" style="font-weight: bold;">一致性哈希</span>算法。同时，为了保证数据的高可用，每个数据库分片都应该有主从副本，实现读写分离和故障转移。</span></span></p></div></div></div></div></div><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">缓存策略</span></strong></span></p></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">“为了应对每秒2万次的读取请求，缓存是必不可少的一环。我们可以在应用服务器和数据库之间加入分布式缓存层，比如Redis或Memcached。”</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">我们可以对高频访问的 URL 进行缓存。采用 redis 等现成解决方案即可存储完整 URL 及其对应哈希值。这样应用服务器在访问后端存储前，能快速检查缓存中是否存在目标 URL。</span></span></p><div data-tools="135编辑器" data-id="88516" style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;color: #333333;font-size: 17px;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, Arial, sans-serif;"><div style="margin: 0.5em 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><div style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;line-height: 1.75em;"><div data-width="100%" style="margin: -10px 0px;padding: 0px 10px;max-width: 100%;display: inline-block;vertical-align: top;width: 100%;word-wrap: break-word !important;box-sizing:border-box;"><div hm_fix="461:527" style="margin: 0px;padding: 10px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;border-width: 2px;border-style: solid;border-color: white;background-color: #efefef;"><p style="line-height:1.75em;"><span style="color: #7f7f7f;font-size: 15px;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf="">“为了应对每秒2万次的读取请求，缓存是必不可少的一环。我们可以在应用服务器和数据库之间加入分布式缓存层，比如Redis或Memcached。”</span></span></p><p style="line-height:1.75em;"><span style="color: #7f7f7f;font-size: 15px;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf="">我们可以对高频访问的 URL 进行缓存。采用 redis 等现成解决方案即可存储完整 URL 及其对应哈希值。这样应用服务器在访问后端存储前，能快速检查缓存中是否存在目标 URL。”</span></span></p></div></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">缓存内容：</span>缓存 短链码 -&gt; 原始长URL 的映射关系。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">工作流程：</span></span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">当请求到达时，应用服务器首先查询缓存。</span></span></p></li><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">如果缓存命中（Cache Hit），直接从缓存中获取原始URL并返回重定向。</span></span></p></li><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">如果缓存未命中（Cache Miss），则查询后端的数据库。</span></span></p></li><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">从数据库查到数据后，先将其写入缓存，然后再返回给用户。这样后续相同的请求就能直接命中缓存了。</span></span></p></li></ul><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">面试官：那需要配置多大的缓存内存呢？</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">我们可以从每日流量的 20%开始，根据客户端使用模式动态调整所需缓存服务器的数量。根据前文估算，缓存 20%的日流量需要 170GB 内存。由于现代服务器可配备 256GB 内存，我们完全可以用单台机器承载全部缓存。当然，也可以选择用多台配置较低的服务器来存储这些热门 URL。</span></span></p><div data-tools="135编辑器" data-id="88516" style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;color: #333333;font-size: 17px;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, Arial, sans-serif;"><div style="margin: 0.5em 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><div style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;line-height: 1.75em;"><div data-width="100%" style="margin: -10px 0px;padding: 0px 10px;max-width: 100%;display: inline-block;vertical-align: top;width: 100%;word-wrap: break-word !important;box-sizing:border-box;"><div hm_fix="461:527" style="margin: 0px;padding: 10px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;border-width: 2px;border-style: solid;border-color: white;background-color: #efefef;"><p style="line-height:1.75em;"><span style="color: #7f7f7f;font-size: 15px;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf="">我们可以从每日流量的 20%开始，根据客户端使用模式动态调整所需缓存服务器的数量。根据前文估算，缓存 20%的日流量需要 170GB 内存。由于现代服务器可配备 256GB 内存，我们完全可以用单台机器承载全部缓存。当然，也可以选择用多台配置较低的服务器来存储这些热门 URL。</span></span></p></div></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">哪种缓存淘汰策略最适合我们的需求？</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">可以使用 LRU (Least Recently Used) 策略。因为热点链接会经常被访问，而冷门链接则会逐渐被淘汰出缓存，这符合我们的业务场景。</span></span></p><div data-tools="135编辑器" data-id="88516" style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;color: #333333;font-size: 17px;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, Arial, sans-serif;"><div style="margin: 0.5em 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><div style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;line-height: 1.75em;"><div data-width="100%" style="margin: -10px 0px;padding: 0px 10px;max-width: 100%;display: inline-block;vertical-align: top;width: 100%;word-wrap: break-word !important;box-sizing:border-box;"><div hm_fix="461:527" style="margin: 0px;padding: 10px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;border-width: 2px;border-style: solid;border-color: white;background-color: #efefef;"><p style="line-height:1.75em;"><span style="color: #7f7f7f;font-size: 15px;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf="">可以使用 <span textstyle="" style="font-weight: bold;">LRU (Least Recently Used) 策略</span>。因为热点链接会经常被访问，而冷门链接则会逐渐被淘汰出缓存，这符合我们的业务场景。</span></span></p><p style="line-height:1.75em;"><span style="color: #7f7f7f;font-size: 15px;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf="">同时，为了进一步提升效率，我们可以部署缓存集群。当发生缓存未命中并从数据库取回数据后，应用服务器需要将这个新条目写入所有缓存副本，以保证数据一致性。</span></span></p></div></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.4925925925925926" data-w="1080" style="width:100%;" data-backw="568" data-backh="280" src="https://wechat2rss.xlab.app/img-proxy/?k=1f3ce975&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FfjW5u71LIiad2UJ7IwGpiaX03QvFBL0C4wHHeEibcVXiaiaW8ZpfMKPcCXEoBC4nGyGpNyPvv0AqfGXVZz2CD4BoCicQ%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg%26watermark%3D1"/></span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">负载均衡</span></strong></span></p></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">十亿级别的短链存储，在业务上访问量应该不低，所以服务实例基本上都要采用多节点部署。因此我们可以在系统中的三个位置添加负载均衡层。</span></span></p><div data-tools="135编辑器" data-id="88516" style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;color: #333333;font-size: 17px;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, Arial, sans-serif;"><div style="margin: 0.5em 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><div style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;line-height: 1.75em;"><div data-width="100%" style="margin: -10px 0px;padding: 0px 10px;max-width: 100%;display: inline-block;vertical-align: top;width: 100%;word-wrap: break-word !important;box-sizing:border-box;"><div hm_fix="461:527" style="margin: 0px;padding: 10px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;border-width: 2px;border-style: solid;border-color: white;background-color: #efefef;"><p style="line-height:1.75em;"><span style="color: #7f7f7f;font-size: 15px;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf="">“我们的应用服务、缓存服务、数据库服务都会是集群部署，所以在系统的关键节点都需要部署负载均衡器（Load Balancer）。”</span></span></p></div></div></div></div></div><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">客户端 -&gt; 应用服务器</span></span></p></li><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">应用服务器 -&gt; 数据库集群</span></span></p></li><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">应用服务器 -&gt; 缓存集群</span></span></p></li></ul><div data-tools="135编辑器" data-id="88516" style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;color: #333333;font-size: 17px;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, Arial, sans-serif;"><div style="margin: 0.5em 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><div style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;line-height: 1.75em;"><div data-width="100%" style="margin: -10px 0px;padding: 0px 10px;max-width: 100%;display: inline-block;vertical-align: top;width: 100%;word-wrap: break-word !important;box-sizing:border-box;"><div hm_fix="461:527" style="margin: 0px;padding: 10px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;border-width: 2px;border-style: solid;border-color: white;background-color: #efefef;"><p style="line-height:1.75em;"><span style="color: #7f7f7f;font-size: 15px;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf="">“最初，我们可以采用简单的<span textstyle="" style="font-weight: bold;">轮询</span>策略。但这种策略不关心服务器的实际负载。如果某台服务器因为某些原因响应变慢，轮询策略依然会给它分配新请求，可能导致问题恶化。因此，更智能的方案是采用<span textstyle="" style="font-weight: bold;">最少连接</span>或<span textstyle="" style="font-weight: bold;">基于响应时间的加权轮询</span>等策略，负载均衡器会定期探测后端服务器的健康状况和负载，动态地调整流量分配。”</span></span></p></div></div></div></div></div><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><p data-brushtype="text"><span style="color: #138bde;"><strong><span leaf="">过期链接清理</span></strong></span></p></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">面试官：“设计得差不多了。最后一个问题，那些设置了过期时间的链接，你们是怎么处理的？会有一个定时任务去扫描数据库删除吗？”</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这是一个考察系统维护和资源优化的好问题。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">“主动扫描整个庞大的数据库去删除过期链接，成本太高，会对数据库造成不必要的压力。我们可以采用更优雅的惰性删除（Lazy Deletion）和异步清理结合的策略。”</span></span></p><div data-tools="135编辑器" data-id="88516" style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;color: #333333;font-size: 17px;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, Arial, sans-serif;"><div style="margin: 0.5em 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><div style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;line-height: 1.75em;"><div data-width="100%" style="margin: -10px 0px;padding: 0px 10px;max-width: 100%;display: inline-block;vertical-align: top;width: 100%;word-wrap: break-word !important;box-sizing:border-box;"><div hm_fix="461:527" style="margin: 0px;padding: 10px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;border-width: 2px;border-style: solid;border-color: white;background-color: #efefef;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="font-size: 15px;color: #7f7f7f;letter-spacing: 0.544px;caret-color: red;font-family:Helvetica, Arial, sans-serif;"><span leaf="">“主动扫描整个庞大的数据库去删除过期链接，成本太高，会对数据库造成不必要的压力。我们可以采用更优雅的<span textstyle="" style="font-weight: bold;">惰性删除（Lazy Deletion）和异步清理</span>结合的策略。”</span></span></p></div></div></div></div></div><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">1）设置默认过期时间</span></span></strong></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">我们可以为每个链接设置默认有效期（例如两年）</span></span></p><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">2）访问时删除</span></span></strong></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">当一个用户访问某个短链接时，我们在查询到数据后，会检查其是否过期。如果已过期，我们不会返回重定向，而是直接删除该记录，并向用户返回一个“链接已失效”的页面。</span></span></p><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">3）异步清理</span></span></strong></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">同时，我们还会有一个低优先级的后台清理服务，它会在系统负载较低的时候（比如凌晨），慢慢地、分批地去清理那些已经过期但长时间未被访问的“僵尸”链接。这个服务必须被设计成轻量级的，避免影响核心业务。</span></span></p><p style="line-height:1.75em;"><strong style="letter-spacing: normal;font-size: 15px;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">4）密钥复用</span></span></strong></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">在删除了过期链接后，我们可以将它对应的短链码回收，放回到KGS的未使用密钥库中，实现循环利用。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.6037037037037037" data-w="1080" style="width:100%;" data-backw="568" data-backh="343" src="https://wechat2rss.xlab.app/img-proxy/?k=eecf7cf8&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FfjW5u71LIiad2UJ7IwGpiaX03QvFBL0C4wdO0LX0WB1oN2rPMPiafdvQXORRenpA8tJuMWguqug60QE2KSEKeHibxA%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg%26watermark%3D1"/></span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">四、小结</span></strong></span></p></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">至此，一个相对完整、考虑周全的十亿级短链系统设计方案就展现在面试官面前了。我们再来回顾一下整体架构。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">从一个简单的需求出发，我们通过<span textstyle="" style="font-weight: bold;">需求分析、容量预估</span>，明确了系统的核心挑战。然后，我们定义了清晰的<span textstyle="" style="font-weight: bold;">API接口</span>，设计了可扩展的<span textstyle="" style="font-weight: bold;">数据库模型</span>，并深入探讨了最核心的<span textstyle="" style="font-weight: bold;">短码生成算法</span>。为了应对高性能和高可用的要求，我们引入了<span textstyle="" style="font-weight: bold;">数据分区、缓存和负载均衡</span>等关键组件。最后，我们还考虑到了<span textstyle="" style="font-weight: bold;">过期数据清理</span>这样的维护性细节。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">整个回答过程，不仅展示了你的技术深度和广度，更重要的是，体现了你作为一名架构师，那种从全局出发、层层递-进、权衡利弊的系统化思维方式。这才是面试官最想看到的。</span></span></p></div><div data-role="paragraph" style="font-family:sans-serif;"><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">作者丨IT杨秀才</span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;text-align: left;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">来源丨公众号：IT杨秀才（ID：</span><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="" data-pm-slice="1 1 [&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-tools&#34;:&#34;135编辑器&#34;,&#34;data-id&#34;:&#34;us-3745001&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;style&#34;:&#34;box-sizing: border-box;padding:0 5px;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;paragraph&#34;,&#34;style&#34;:&#34;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;paragraph&#34;,&#34;style&#34;:&#34;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;paragraph&#34;,&#34;style&#34;:&#34;font-family:sans-serif;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;style&#34;:&#34;margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;text-align: left;font-family:sans-serif;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;},&#34;node&#34;,{&#34;tagName&#34;:&#34;span&#34;,&#34;attributes&#34;:{&#34;style&#34;:&#34;margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;},&#34;node&#34;,{&#34;tagName&#34;:&#34;span&#34;,&#34;attributes&#34;:{&#34;style&#34;:&#34;margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;}]">gh_90a41873eb21</span></span></span><span leaf="">）</span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">dbaplus社群欢迎广大技术人员投稿，投稿邮箱：</span></span><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">editor@dbaplus.cn</span></span></p></div></div></div></div></div></div><p class="mp_profile_iframe_wrp" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-servicetype="0" data-verify_status="2"></mp-common-profile></p><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img" data-aistatus="1" data-imgfileid="100130225" data-ratio="0.07777777777777778" data-s="300,640" type="block" data-w="1080" src="https://wechat2rss.xlab.app/img-proxy/?k=f32823a4&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FufWcjcomw8Zf2jiaBBH3vdgfP4A2rem5YEAHYH074dc4GibhojA5B3lLZrXLDRciaVnficveaHcAUCiaIPoDsTkAduA%2F640%3Fwx_fmt%3Dpng"/></p><p style="display: none;"><mp-style-type data-value="3"></mp-style-type></p>



<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=e33928fc&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzkzMjYzNjkzNw%3D%3D%26mid%3D2247638279%26idx%3D1%26sn%3Dde4966a934e8adc72febc2d423f08ef9">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Sun, 25 Oct 2026 08:00:00 +0800</pubDate>
    </item>
    <item>
      <title>互联网中心化与NAT原罪：为啥你的电脑不能当服务器？</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzkzMjYzNjkzNw==&amp;mid=2247638276&amp;idx=1&amp;sn=3a59f4840da67954121ef28fc870dd5b</link>
      <description>临时方案活成了永久方案，IPv6反而成了那个“永远在明年”的东西。</description>
      <content:encoded><![CDATA[<p><span>dbaplus社群</span> <span>2026-10-24 08:00</span> <span style="display: inline-block;">广东</span></p>






  
  <p><img src="https://wechat2rss.xlab.app/img-proxy/?k=bcdeb004&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYbzK2wgO0sh55nI3YSdwIPWhdMg0YsO7NQBkzKuWfticw7veIdGWHUN5y77fYXya4LdicWtfursChvYHPolYuic9jO0DibfZXic9icj8%2F0%3Fwx_fmt%3Djpeg"/></p>
  <p>临时方案活成了永久方案，IPv6反而成了那个“永远在明年”的东西。</p>
  <p class="mp_profile_iframe_wrp" style="margin-bottom: 0px;" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-service_type="1" data-verify_status="2"></mp-common-profile></p><div data-role="outer" label="edit by 135editor" data-pm-slice="0 0 []"><div data-role="paragraph"><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">你让朋友发一个 25MB 的文件给你。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">他说微信传不了，你让他开个 FTP，他反问你：FTP 是什么？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这个场景对很多人来说只是日常，但仔细想想其实非常离谱：互联网已经发明几十年了，两台电脑之间直接传个文件，居然还是个难题，更离谱的是，今天如果你问一个“懂电脑”的人，他会告诉你：你家里那台电脑当然不能让别人直接连，那叫服务器，服务器是要买云服务的。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">我可以非常明确地告诉大家：这个认知是错的，但错得非常有来由。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">互联网在 1970 年代被设计出来的时候，<span textstyle="" style="font-weight: bold;">从来没有“客户端”和“服务器”这种等级区别</span>，每一台主机都是一个完整的节点，有全局唯一的地址，既可以是服务的消费者，也可以是服务的提供者，1980 年代的 UNIX 工作站，装个 sendmail 就是邮件服务器，装个 ftpd 就是文件服务器，没有云，也不需要云，这就是互联网的原始设计：<span textstyle="" style="font-weight: bold;">端到端，对等，任何人都能向任何人发起连接。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">那么问题来了：为什么今天你的电脑，只能主动找别人，不能让别人找你？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">答案藏在 1994 年的一份 RFC 里。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">一、地址不够了，NAT 上场</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">1994 年，IETF 发布了 RFC 1631，正式提出了 NAT（Network Address Translation，网络地址转换）。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这份文档的摘要写得很清楚：IP 互联网面前有两个最紧迫的问题：地址枯竭和路由扩展，长期方案是下一代互联网协议，也就是后来的 IPv6；短期方案是 CIDR；而 RFC 1631 自己，提出了第二个短期方案，就是 NAT。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">很多人不知道的是，NAT 最初的定位只是一个临时过渡，用来给 IPv6 争取时间，后来发生的事大家都知道了：<span textstyle="" style="font-weight: bold;">临时方案活成了永久方案，IPv6 反而成了那个“永远在明年”的东西。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">但先不急着骂人，我们先把 NAT 到底干了什么搞清楚。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">NAT 最早被设想成纯 IP 地址翻译，但今天你家路由器上跑的那个东西，学名其实叫 NAPT（Network Address and Port Translation，网络地址端口转换），由后来的 RFC 3022 标准化，它同时改 IP 地址和端口号，你访问一个网站时，数据包是这么走的：</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">你的电脑发出去一个包：</span></span></p><table style="border-collapse: collapse;font-size: 15px;margin: 1.4em auto;max-width: 100%;table-layout: fixed;text-align: left;width: 654px;color: rgb(25, 27, 31);font-family: -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Microsoft YaHei&#34;, &#34;Source Han Sans SC&#34;, &#34;Noto Sans CJK SC&#34;, &#34;WenQuanYi Micro Hei&#34;, &#34;MiSans L3&#34;, &#34;Segoe UI&#34;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;"><tbody><tr><th style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;background: rgb(235, 236, 237);color: rgb(25, 27, 31);font-weight: 500;"><p><span leaf="">源 IP</span></p></th><th style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;background: rgb(235, 236, 237);color: rgb(25, 27, 31);font-weight: 500;"><p><span leaf="">源端口</span></p></th><th style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;background: rgb(235, 236, 237);color: rgb(25, 27, 31);font-weight: 500;"><p><span leaf="">目的 IP</span></p></th><th style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;background: rgb(235, 236, 237);color: rgb(25, 27, 31);font-weight: 500;"><p><span leaf="">目的端口</span></p></th></tr><tr><td style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;"><p><span leaf="">192.168.1.100</span></p></td><td style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;"><p><span leaf="">50413</span></p></td><td style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;"><p><span leaf="">93.184.216.34</span></p></td><td style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;"><p><span leaf="">80</span></p></td></tr></tbody></table><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">路由器收到之后，把它改成：</span></span></p><table style="border-collapse: collapse;font-size: 15px;margin: 1.4em auto;max-width: 100%;table-layout: fixed;text-align: left;width: 654px;color: rgb(25, 27, 31);font-family: -apple-system, BlinkMacSystemFont, &#34;Helvetica Neue&#34;, &#34;PingFang SC&#34;, &#34;Microsoft YaHei&#34;, &#34;Source Han Sans SC&#34;, &#34;Noto Sans CJK SC&#34;, &#34;WenQuanYi Micro Hei&#34;, &#34;MiSans L3&#34;, &#34;Segoe UI&#34;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;"><tbody><tr><th style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;background: rgb(235, 236, 237);color: rgb(25, 27, 31);font-weight: 500;"><p><span leaf="">源 IP</span></p></th><th style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;background: rgb(235, 236, 237);color: rgb(25, 27, 31);font-weight: 500;"><p><span leaf="">源端口</span></p></th><th style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;background: rgb(235, 236, 237);color: rgb(25, 27, 31);font-weight: 500;"><p><span leaf="">目的 IP</span></p></th><th style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;background: rgb(235, 236, 237);color: rgb(25, 27, 31);font-weight: 500;"><p><span leaf="">目的端口</span></p></th></tr><tr><td style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;"><p><span leaf="">203.0.113.7</span></p></td><td style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;"><p><span leaf="">60612</span></p></td><td style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;"><p><span leaf="">93.184.216.34</span></p></td><td style="border: 1px solid rgb(196, 199, 206);height: 24px;line-height: 24px;padding: 3px 12px;"><p><span leaf="">80</span></p></td></tr></tbody></table><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">1）服务器回包，发给 203.0.113.7:60612。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">2）路由器查自己的 NAT 映射表，把目的地址和端口改回 192.168.1.100:50413，然后丢给内网。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">如果你仔细想过这个流程，问题就来了：</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">外面有台服务器想主动找你，怎么办？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">它往 203.0.113.7:60612 发一个包，你的路由器翻遍映射表，发现根本没有这一条。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">为什么没有？因为 NAT 的映射表是<span textstyle="" style="font-weight: bold;">出站流量触发建立的</span>，内部设备不先发，映射就不存在；映射不存在，外部设备就是瞎子，这是 NAT 的固有属性。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">顺便说一个硬核细节：NAT 映射不是永久的，TCP 映射在连接关闭后很快过期，UDP 映射通常只有几十秒到几分钟，这意味着即使你成功建立过一条映射，只要你安静一会儿，外面的路就又断了，这就是为什么大量 P2P 应用必须周期性发 keepalive 包，真不是它们想费电，是它们在和 NAT 的计时器赛跑。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">二、端口转发：最直接，也最没用</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">聪明的人可能已经想到了：那我直接告诉路由器“凡是来 60612 端口的包，都给我转给 192.168.1.100”不就行了？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这就是端口转发，它确实是 NAT 最广为人知的补丁，但问题也很明显。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">第一，一个公网 IP 的一个端口，一次只能映射给一台设备，宿舍四个人，都想开 Minecraft 服务器，默认端口 25565 只有一个，你想开第二个，就得换端口，让朋友记一个“25566”这种没人记得住的数字。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">第二，端口转发的前提是你能控制那台做 NAT 的设备，但这个前提正在消失，因为运营商也缺地址。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">运营商级的 NAT，叫 CGNAT（Carrier-Grade NAT），RFC 6598 专门划了一段 100.64.0.0/10 给运营商级 NAT 当内网地址用。换句话说，你家的路由器从运营商那里拿到的“公网 IP”，很可能根本不是一个真公网 IP，而是 100.64.0.0/10 里的一个运营商内网地址，你的路由器再做一层 NAT，于是你的包要经过两层翻译才能出网。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这时候你想配置端口转发？对不起，翻译表根本不在你手里，你连“我的包出网时长什么样”都不知道，更别提 CGNAT 为了满足监管和溯源要求，可能还要记录海量映射日志——地址是省了，成本转嫁给了运营商，最终转嫁给你。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">三、UPnP：让软件自己敲门</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">端口转发太麻烦，于是有人发明了<span textstyle="" style="font-weight: bold;"> UPnP</span>，以及它的现代亲戚 <span textstyle="" style="font-weight: bold;">NAT-PMP 和 PCP</span>。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">想法很朴素：既然用户不会配路由器，那让程序自己去配，你的 BT 客户端启动时，直接跟路由器说：“帮我开一个 51413 端口的映射，期限两小时，”</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这个方案技术上没问题，但现实里经常用不了，因为很多路由器默认关闭 UPnP，原因被包装成“安全”，早期某些 UPnP 实现确实有漏洞，这是事实；但更普遍的理由，是一个根深蒂固的误解：</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">NAT 被当成防火墙了。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这里我要非常明确地说一句：NAT 不是防火墙，它只是一个因为地址不够而发明的翻译机制，它“挡住”入站连接，不是因为它在检查什么恶意流量，而是因为它根本不知道该把包转给谁，它带来的隐蔽感，是副作用，不是设计。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">但就是这个副作用，让整整一代人形成了“别人能连到你的电脑 = 危险”的直觉，这个直觉后来成了 IPv6 推广最大的障碍之一，我们先按下不表。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">四、STUN、TURN、ICE：互联网史上最复杂的绕路工程</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">如果端口转发没戏，UPnP 也没戏，还有什么办法？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">有，人类为了解决“两台都在 NAT 后面的设备如何直连”这个问题，发明了一整套协议，复杂到可以写好几本教材。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">先讲 STUN。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">STUN 的思路很优雅：既然路由器不配合，那我不求路由器，我求公网上的一台服务器，我发个包给 STUN 服务器，然后问它：“我的包到你这里的时候，长什么样？”STUN 服务器回答：“你看起来是 203.0.113.7:60612，”</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">拿到这个地址之后，你把它告诉对方，对方直接打过来，如果顺利，两边都向对方发几个包，把各自 NAT 上的映射打开，连接就通了，这就是打洞（hole punching）。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">但这里有一个关键的硬核细节：<span textstyle="" style="font-weight: bold;">NAT 分型</span>。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">老的 RFC 3489 把 NAT 分成四类：Full Cone、Restricted Cone、Port Restricted Cone、Symmetric，后来 RFC 5780 把它修正成两个维度：映射行为（Mapping Behavior）和过滤行为（Filtering Behavior）。</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">Endpoint-Independent Mapping：</span>同一个内网 IP:端口，无论目的地址是谁，映射出来的公网 IP:端口都一样，这就是所谓“锥型”。</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">Address-Dependent Mapping：</span>目的 IP 不同，映射出来的公网端口就不同。</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">Address and Port-Dependent Mapping：</span>目的 IP 和端口都不同，映射也不同，这就是所谓“对称型 NAT”。</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">STUN 打洞能不能成，关键就在映射行为，只有 Endpoint-Independent Mapping，STUN 问到的地址才对别人也有效，如果是 Address and Port-Dependent Mapping，你在 STUN 服务器眼里是 60612，在 peer 眼里又是 60613，问到的答案根本没用。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">而对称型 NAT 恰恰大量出现在 CGNAT、校园网、企业网这些<span textstyle="" style="font-weight: bold;">最需要打洞</span>的地方，这就是这个世界的恶意：有公网 IP 的人不需要打洞，最需要打洞的人偏偏打不通。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">打洞失败怎么办？上 TURN。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">TURN 用一句话就能说清楚：放弃治疗，两台设备都主动连一台公网中继服务器，所有流量全部绕中继转发，这招几乎 100% 能通，因为两边都是主动出站连接，NAT 拦不住，但代价是：本来点对点 10ms 的延迟变成 30ms，本来免费的流量变成烧中继服务器的带宽钱，谁的带宽？要么是你的，要么是服务商的，反正不是免费的。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">最后是 ICE，ICE 不是一个新协议，它是一套妥协框架：把直连、STUN 打洞、TURN 中继全部列为候选地址，排好优先级，一个个做连通性检查，能直连就直连，不能就绕，WebRTC 用的就是这一套。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">所以每次你的视频会议卡顿、每次网页版语音通话出现回声，背后都可能有一个悲伤的故事：你和对方都在对称 NAT 后面，STUN 失败，TURN 兜底，你们的数据包正绕着一台本不该存在的服务器在跑长途。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">我们用一个极其复杂的协议栈，模拟了一个本来应该非常简单的东西：两台电脑直接说话。</span></span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">五、IPv6：长期方案为什么没救场</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">NAT 的所有荒诞，原本都应该由 IPv6 来终结。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">IPv6 地址有 128 位，总地址数是 2^128，大约 3.4×10^38 个，这个数字大到什么程度？把地球上所有沙滩和沙漠里的沙子全部编上号，都还绰绰有余，在 IPv6 的世界里，每台设备都可以有全局唯一地址，NAT 根本没有存在的必要。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">但现实是，IPv6 的采用率在爬了很多年之后，依然没有形成碾压，更荒诞的是，很多已经部署 IPv6 的网络，依然在用 NAT 的思维管理 IPv6。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">有的管理员给 IPv6 也做 NAT66，把 fc00::/7 的 Unique Local Address 当私网地址用，再翻译成公网 IPv6，翻译一个本来不需要翻译的东西，这已经是路径依赖了。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">更多的网络，哪怕分了公网 IPv6 地址，防火墙也默认拒绝一切入站连接，为什么？因为大家已经被 NAT 训练了三十年，形成了肌肉记忆：入站连接 = 攻击，你终于有了自己的地址，但全网都习惯性地把你的门焊死。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这就好比你家漏了三十年雨，全楼的人都学会了在屋里打伞，后来屋顶修好了，但没人愿意把伞放下，因为“在屋里不打伞不安全”已经成了常识。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">六、中心化不是商业阴谋，是技术债</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">现在我们可以回答开头那个问题了：为什么你的电脑永远只能当客户端？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">因为 NAT 把你的地址藏起来了，你没有公网地址，所以别人找不到你；别人找不到你，所以你必须先找别人；所有人都必须先找别人，所以必须有一个“别人”在那里等着所有人来连接。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">那个“别人”，就是服务器，那个“别人的集合”，就是云。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这就是互联网中心化的技术根源，中心化不是某个公司的商业阴谋，它是 NAT 三十年积累下来的技术债。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">这笔债的账单很长：</span></span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">你想自己跑一个邮件服务器？多数云厂商和运营商把住宅 IP 段整段拉黑，因为垃圾邮件发送者早就用 NAT 后面的肉鸡把住宅 IP 的信誉打穿了。</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">你想用 BT 下载？为什么那么多 peer 连不上你？因为你在 NAT 后面没有可连接性，只能靠别人有公网 IP 的节点救你。</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">你想从公司连回家里 NAS 拿文件？你要么配端口转发，要么依赖厂商的中继服务器，而后者意味着你的文件从别人的机器上绕了一圈。</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">你想做视频会议？WebRTC 打洞失败的代价，就是所有人都得为 TURN 中继的带宽买单。</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">你想跑一个游戏服务器？先看看你的宽带是不是 CGNAT，再看看你有没有本事让运营商给你真公网 IP。</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">最讽刺的地方来了：NAT 本来是为了节省地址而发明的省钱方案，结果它催生了一个庞大的云计算产业，地址是省下来了，但你本来可以跑在家里旧电脑上的服务，现在只能去租一台 VPS。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">NAT 把“拥有一台服务器”从每个互联网用户的默认权利，变成了需要额外付费的稀缺资源。</span></span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">七、所以，谁该为互联网的封闭负责？</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">你可以怪云厂商，可以怪运营商，可以怪防火墙厂商，甚至可以怪那个把“你的 IP 被别人</span><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">知道了”拍成恐怖片的安全文化。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">但真正最早按下开关的，是 1994 年那个为了解决地址短缺而提出的临时方案。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">NAT 当然不是互联网中心化的唯一原因，但它是最早的那个，它改变了三件事：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">第一，它改变了拓扑</span>，互联网从对等网络变成了客户端-服务器星型结构，因为大部分节点失去了被寻址的能力。</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">第二，它改变了心智</span>，人们开始觉得“我的设备只配主动找云，不配被别人找”是自然规律，甚至把这种残缺当成安全。</span></span></p></li></ul><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">第三，它改变了经济</span>，当可连接性变成稀缺资源，谁拥有公网地址和服务器，谁就能收税。</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">所以，当你下一次打开网盘，看着几十 KB/s 的上传速度想骂产品经理的时候，不妨想一想：真正该背锅的，可能不是产品经理，也不是云厂商，而是那个本该被 IPv6 送进历史博物馆、却一直赖着没走的 NAT。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold;">中心化不是互联网的原设计，它是 NAT 的原罪。</span></span></span></p></div><div data-role="paragraph"><div data-role="paragraph" style="font-family:sans-serif;"><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">作者丨</span><span style="color: #888888;font-size: 14px;letter-spacing: 0.5px;text-align: justify;text-decoration-thickness: initial;display: inline !important;font-family:Helvetica, Arial, sans-serif;"><span leaf="">最后的绅士</span></span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;text-align: left;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">来源丨网址：<a href="https://zhuanlan.zhihu.com/p/2077783800315172271?share_code=vfPkpUjp2Vp1&amp;utm_psn=2078496680681418931" target="_blank">https://zhuanlan.zhihu.com/p/2077783800315172271?share_code=vfPkpUjp2Vp1&amp;utm_psn=2078496680681418931</a></span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">dbaplus社群欢迎广大技术人员投稿，投稿邮箱：</span></span><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">editor@dbaplus.cn</span></span></p><p class="mp_profile_iframe_wrp" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-service_type="1" data-verify_status="2"></mp-common-profile></p><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.07777777777777778" data-s="300,640" data-w="1080" type="block" data-imgfileid="100130225" src="https://wechat2rss.xlab.app/img-proxy/?k=f32823a4&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FufWcjcomw8Zf2jiaBBH3vdgfP4A2rem5YEAHYH074dc4GibhojA5B3lLZrXLDRciaVnficveaHcAUCiaIPoDsTkAduA%2F640%3Fwx_fmt%3Dpng"/></p></div></div></div><p style="display: none;"><mp-style-type data-value="3"></mp-style-type></p>



<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=72e16d3d&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzkzMjYzNjkzNw%3D%3D%26mid%3D2247638276%26idx%3D1%26sn%3D3a59f4840da67954121ef28fc870dd5b">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Sat, 24 Oct 2026 08:00:00 +0800</pubDate>
    </item>
    <item>
      <title>数据散、口径乱、重复搭：企业AI Agent如何跨过三道坎？</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzkzMjYzNjkzNw==&amp;mid=2247638266&amp;idx=1&amp;sn=f9f96c657ae85f739b6d067a0aeb62b5</link>
      <description>如何建立MIP极速统一的企业级AI数据平台？</description>
      <content:encoded><![CDATA[<p><span>dbaplus社群</span> <span>2026-10-23 07:15</span> <span style="display: inline-block;">广东</span></p>






  
  <p><img src="https://wechat2rss.xlab.app/img-proxy/?k=86de3e10&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYbajhVCG0XDGhJ3XIyBXDbXcNGf3pSRocpLs29Op2jKFBswnspshH8G8lszGQVnvOyRKDkWztk8YCVLGUib3WicDdLqjwRtOwApo%2F0%3Fwx_fmt%3Djpeg"/></p>
  <p>如何建立MIP极速统一的企业级AI数据平台？</p>
  <div data-role="outer" label="edit by 135editor" data-tplid="295085" data-pm-slice="0 0 []"><div data-tools="135编辑器" data-id="us-3745001"><div style="box-sizing: border-box;padding:0 5px;"><div data-role="paragraph" style=""><div data-role="paragraph" style=""><div data-tools="135编辑器" data-id="us-4110356"><div data-role="paragraph" style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;color: #333333;font-size: 17px;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-family:mp-quote, -apple-system-font, BlinkMacSystemFont, Arial, sans-serif;"><div data-role="outer" label="edit by 135editor" data-tplid="295085" data-pm-slice="0 0 []"><div data-tools="135编辑器" data-id="us-3745001"><div style="box-sizing: border-box;padding:0 5px;"><div data-role="paragraph" style=""><div data-role="paragraph" style="" data-pm-slice="5 9 [&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;outer&#34;,&#34;label&#34;:&#34;edit by 135editor&#34;,&#34;data-tplid&#34;:&#34;295085&#34;,&#34;data-pm-slice&#34;:&#34;0 0 []&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-tools&#34;:&#34;135编辑器&#34;,&#34;data-id&#34;:&#34;us-3745001&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;style&#34;:&#34;box-sizing: border-box;padding:0 5px;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null},&#34;para&#34;,{&#34;tagName&#34;:&#34;section&#34;,&#34;attributes&#34;:{&#34;data-role&#34;:&#34;paragraph&#34;,&#34;style&#34;:&#34;&#34;},&#34;namespaceURI&#34;:&#34;http://www.w3.org/1999/xhtml&#34;,&#34;data-layout-id&#34;:null}]"><div data-role="paragraph" style="font-family:sans-serif;"><p><strong style="color: #138bd5;font-size: 16px;letter-spacing: 0.544px;text-align: justify;caret-color: red;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">作者介绍</span></strong></p></div><div data-role="paragraph" style="font-family:sans-serif;"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="margin: 0px;padding: 0px;max-width: 100%;font-size: 16px;box-sizing: border-box !important;overflow-wrap: break-word !important;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">董颖婷，</span></span></strong><span style="text-decoration: inherit;letter-spacing: 0.544px;caret-color: red;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">镜舟科技产品负责人。</span></span></span></p></div></div></div></div></div></div></div></div></div></div></div><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">企业落地 AI Agent 的三个问题</span></strong></span></p></div></div></div></div><div data-role="paragraph"><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">Agent 进入企业的真实业务之后，会绕不开数据、口径和知识的问题。结合我们自己的实践，我们总结了三个比较普遍的问题，并在每个问题后面写出我们的思路。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><div data-brushtype="text"><p style="line-height: 1.75em;"><span style="color: rgb(19, 139, 222);"><strong><span leaf="">问题一：数据多模态且分散</span></strong></span></p></div></div></div></div><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">一个 Agent 处理任务时，可能同时访问二维业务表、非结构化文档、图片和向量数据。这些数据往往存在不同的存储介质和系统里，取回之后还要进一步关联分析。这给 AI Agent 系统的搭建带来了难题。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">我们的思路是：多类数据要能在 SQL 中关联。业务表上的数据、湖上的数据、对象存储上的非结构化数据，都能统一检索和查询，查询出来的结果还能继续分析。数据存在不同的地方是常态，但搬迁的代价高，所以让计算去找数据，分散的问题就可以在查询层得到解决。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><div data-brushtype="text"><p style="line-height: 1.75em;"><span style="color: rgb(19, 139, 222);"><strong><span leaf="">问题二：口径需要反复解释</span></strong></span></p></div></div></div></div><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">以数据分析为例，&#34;销售额怎么算&#34;&#34;哪些订单参与计算&#34;，都要先定义清楚。但这些知识往往散落在历史 SQL、文档，甚至分析师的个人经验里。于是同一个问题容易出现不同的答案。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">我们的思路是：把业务口径定义在数据库里。这样的定义可以直接转换成可执行的计算。我们通过 Semantic View 把指标对应到明确的表达式，查询结果可以追溯到对应的公式、统计范围和最终执行的 SQL，方便统一解释口径。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><div data-brushtype="text"><p style="line-height: 1.75em;"><span style="color: rgb(19, 139, 222);"><strong><span leaf="">问题三：搭建过程大量重复</span></strong></span></p></div></div></div></div><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">搭建多个 Agent 时，会面临不同的数据接入，需要重新整理相关的知识和上下文。有修正时，不同 Agent 之间也难以同步，这导致 Agent 建设过程中产生很多重复工作。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">我们的思路是：以数据库承载可复用企业上下文的管理能力，由 MirrorMind 统一组织知识及其关联、版本和访问权限，供多个 Agent 按需使用；会话与任务运行状态由 MirrorPilot 管理。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">三个问题指向同一个根源：数据、口径和上下文，缺少统一的载体。</span></span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">10 月 20 日，镜舟科技产品发布会上，我们正式推出了 MIP——极速统一的企业级 AI 数据平台。以数据库为核心，它的架构设计沿着两个方向展开，向下：为数据库加入 AI 能力，升级数据底座；向上：数据库 for AI ，让企业的知识和 AI Agent 能力，服务更多的业务。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">数据在哪里，理解与计算就应该在哪里。把数据、口径和上下文放进数据库，是因为这三件事缺的能力，恰好都要从数据库里长出来。</span></span></p><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.425531914893617" data-s="300,640" data-type="png" data-w="705" style="width:100%;" type="block" data-backw="568" data-backh="242" data-imgfileid="100154574" src="https://wechat2rss.xlab.app/img-proxy/?k=6a310b43&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FgiamgWvCHDYaibRENKIpvrJ0ibvou5lTTU16whJD4SmDNaia8sXTeE3ic929EXxYeoJqEKsHianUCVPqpTATlbedvRiccuCUbYBHqXrON5EykrF5ibg%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p></div><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">三层架构：MIP 把数据与知识组织成共享能力</span></strong></span></p></div></div></div></div><div data-role="paragraph"><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">MIP 把企业的数据与知识组织成三层，形成一套共享能力。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">底层是 MirrorData，一个以开源 StarRocks 为核心的企业级数据查询引擎，提供极速查询检索和多模态分析能力。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">中间层是 MirrorMind，以 Semantic View 为核心，把相关领域的业务知识和分析师的个人经验关联起来，供 Agent 按需使用。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">上层是 MirrorPilot，业务 Agent 的运行环境。</span></span></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">三层之上，是各类业务应用。企业经营中常用的经营分析、售后诊断、商品选型，都可以用这套统一的底座来搭建。</span></span></p><p style="text-align: center;line-height: 1.75em;" nodeleaf=""><img class="rich_pages wxw-img" data-aistatus="1" data-backh="320" data-backw="568" data-imgfileid="100154575" data-ratio="0.562962962962963" data-s="300,640" type="block" data-type="png" data-w="1080" style="width: 100%;" src="https://wechat2rss.xlab.app/img-proxy/?k=ee745073&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYatrrXU6YHDOtHMic4f2ia7aKDIAFrvuKT9DxMJlz7VJxdKwyiapRn6E9WFkLr86DP5jT9mquOhdnB7BBImY1TfibbHIBhKiaMH9B6Y%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">后面的章节会逐层展开这三层，展示整套底座的使用方式。</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">用“售后图片”展示 MirrorData 多模态检索与业务关联</span></span></p></li><li><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">用“活动预算对照”说明 MirrorMind 中语义定义的作用</span></span></p></li><li><p style="line-height: 1.75em;"><span style="font-size: 15px;color: rgb(62, 62, 62);letter-spacing: normal;font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">以“零售经营分析”串起配置、查询、分析与报告的完整使用流程</span></span></p></li></ul></div><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">MirrorData：统一的数据底座</span></strong></span></p></div></div></div></div><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><div data-brushtype="text"><p style="line-height:1.75em;"><span style="color: #138bde;"><strong><span leaf="">标准 SQL 接入，一套计算能力服务所有应用</span></strong></span></p></div></div></div></div><div data-role="paragraph"><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">MirrorData 是 MIP 的数据底座，核心是一个查询引擎。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">上层的 BI 报表、交互式分析、数据应用和 Agent，都可以通过标准 SQL 接入。同一套计算能力服务不同的应用，MirrorData 作为统一的查询入口。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">查询引擎延续了 StarRocks 的高性能查询能力。在此基础上，我们做了企业级增强：权限管理、资源管控和资源隔离。</span></span></p><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.562962962962963" data-s="300,640" data-type="png" data-w="1080" style="width:100%;" type="block" data-backw="568" data-backh="320" data-imgfileid="100154577" src="https://wechat2rss.xlab.app/img-proxy/?k=384d6dfc&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYbTowO70EGnrAUISibtpunTY5B670ibVSh9CKg1AXwibYvbGkm0ibibofFc0E5ia2J25zkz9iaJA4Tc3nYy4Ufiavl6DNU2qQiaVib75Eh3s%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><div data-brushtype="text"><p style="line-height:1.75em;"><span style="color: #138bde;"><strong><span leaf="">支持统一访问内表、湖表与多模态内容</span></strong></span></p></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">数据侧的接入有三种方式。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">1）传统内表。</span>内表承载业务字段、JSON、文本和向量等可查询数据；对于图片、文档等内容，可通过文件引用和业务对象 ID，与其派生表示及业务记录建立关联。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">2）湖上数据。</span>很多客户的数据已经沉淀在数据湖上。MirrorData 通过外部 Catalog 统一接入，支持 Paimon、Iceberg、Hive 等主流湖表格式，提供高效的湖表访问能力。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">3）未利用的历史文件。</span>企业已有的图片、文档和音视频，往往难以直接参与业务分析。原始文件可以保留在对象存储中，按任务需要完成解析和向量生成后，将文件引用、提取的文本及向量写入表，与业务字段关联。MirrorData 统一组合检索、过滤、关联与聚合。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><div data-brushtype="text"><p style="line-height:1.75em;"><span style="color: #138bde;"><strong><span leaf="">一条 SQL，完成混合检索</span></strong></span></p></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">在极速分析和数据湖查询的基础上，MirrorData 进一步扩展多模态检索与关联分析。同一个业务对象可以同时具有结构化字段、JSON 属性、文本、Embedding 和文件引用，通过业务对象 ID 连接内容与业务事实，使检索结果能够继续参与分析。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">底层是三类查询能力：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">结构化数据：</span>结合分区裁剪和列式扫描，完成极速分析。</span></span></p></li><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">全文检索：</span>基于倒排索引进行词项匹配，例如通过 MATCH_ANY 匹配描述中包含“开箱”或“拆箱”的记录。</span></span></p></li><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">向量检索：</span>按相似度或距离，查找相关内容。</span></span></p></li></ul><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.562962962962963" data-s="300,640" data-type="png" data-w="1080" style="width:100%;" type="block" data-backw="568" data-backh="320" data-imgfileid="100154578" src="https://wechat2rss.xlab.app/img-proxy/?k=674afd9b&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FgiamgWvCHDYZkORnqlekVgP9IkIngpTxicVbpj8SOaLZP4oefibQl6BObz2NuXiaGrwKbk4zEic15WGguq16K2rtt1yPzprokUdWYicCefbIuxMsk%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">一条 SQL 可以把三者串联起来，具体的访问路径，取决于查询方式和索引方式。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><div data-brushtype="text"><p style="line-height:1.75em;"><span style="color: #138bde;"><strong><span leaf="">演示：售后订单查询</span></strong></span></p></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">为了直观展示 SQL 与查询结果，我们制作了一个售后检索操作页。用户上传一张屏幕破损照片，寻找近期破损形态相似的售后记录，再关联订单、批次、承运商和退款信息，为后续分析提供依据。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">先将参考照片转换为查询向量，作为参数供检索 SQL 使用。随后在 SQL 中计算图片相似度，通过售后单和订单明细的关联关系补充批次、承运商与退款信息，并加入时间、品类以及“开箱／拆箱”全文条件。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">这些条件最终组成一条完整的 SQL。也就是说，一条 SQL 就能完成结构化和非结构化数据的统一检索。</span></span></p><p nodeleaf=""></p></div><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">MirrorMind：让 Agent 用对口径</span></strong></span></p></div></div></div></div><div data-role="paragraph"><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">数据能查到之后，下一步：Agent 得理解企业的业务定义和背景知识。MirrorMind 以 Semantic View 为核心，解决的就是这个问题。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">如需详细了解什么是 Semantic View ，可进一步阅读镜舟科技公众号系列文章：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><a class="normal_text_link mp_article_text_link" target="_blank" style="" href="https://mp.weixin.qq.com/s?__biz=Mzg5MTg0NDM2OQ==&amp;mid=2247490188&amp;idx=1&amp;sn=83dd0d6c90fd82872027210d06c147cc&amp;scene=21#wechat_redirect" textvalue="AI 能写 SQL，但它真的理解数据吗？镜舟 Semantic View 如何补齐语义缺口" data-itemshowtype="0" linktype="text" data-linktype="2">Semantic View 技术解析（一）</a></span></span></p></li><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><a class="normal_text_link mp_article_text_link" target="_blank" style="" href="https://mp.weixin.qq.com/s?__biz=Mzg5MTg0NDM2OQ==&amp;mid=2247490263&amp;idx=1&amp;sn=60fdd2e309bacdc641655367f6ae3b98&amp;scene=21#wechat_redirect" textvalue="Semantic View 技术解析（二）：业务口径如何进入数据库执行路径" data-itemshowtype="0" linktype="text" data-linktype="2">Semantic View 技术解析（二）</a></span></span></p></li><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><a class="normal_text_link mp_article_text_link" target="_blank" style="" href="https://mp.weixin.qq.com/s?__biz=Mzg5MTg0NDM2OQ==&amp;mid=2247490272&amp;idx=1&amp;sn=a738404be389451ef96e44187ca544d4&amp;scene=21#wechat_redirect" textvalue="Semantic View技术解析（三）：指标、关系与过滤规则如何约束查询结果" data-itemshowtype="0" linktype="text" data-linktype="2">Semantic View 技术解析（三）</a></span></span></p></li></ul><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><div data-brushtype="text"><p style="line-height:1.75em;"><span style="color: #138bde;"><strong><span leaf="">Semantic View 里定义什么</span></strong></span></p></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">Semantic View 记录 Agent 理解业务所需的结构化定义，包括：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">表和关联：</span>定义数据表的范围，以及表之间的关联关系。</span></span></p></li><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">维度：</span>指标可以按哪些维度上卷、下钻。比如活动预算按渠道、活动类型拆，或按日期汇总。</span></span></p></li><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">指标：</span>每个指标的计算表达式和说明。除了原子指标，也可以定义衍生指标，以及窗口函数这类复杂的计算逻辑。</span></span></p></li><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">同义词：</span>为指标维护业务名称、别名和说明，例如“市场总预算”“促销补贴总额”。Agent 可以结合这些定义识别用户所指的指标，减少不同表达习惯带来的理解偏差。</span></span></p></li></ul><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">Agent 拿到一个问题，先在 Semantic View 里找到适用的定义，再按这个口径转成执行语句，交给数据库执行。</span></span></p><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.7824074074074074" data-s="300,640" data-type="png" data-w="1080" style="width:100%;" type="block" data-backw="568" data-backh="444" data-imgfileid="100154590" src="https://wechat2rss.xlab.app/img-proxy/?k=50b2723b&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYZv2R1PA4EfANTReJLlruo5f5LdNjiaB88iaHVJlOFvWo3oJE5fFAMr2dHc6HD9fv65BewaRHaXk4C9YiccaUAL66Mautf4wVhWxU%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><div data-brushtype="text"><p style="line-height:1.75em;"><span style="color: #138bde;"><strong><span leaf="">对比：有没有 Semantic View</span></strong></span></p></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">用同一个问题做对比：&#34;公司的活动预算是多少？&#34;</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">没有 Semantic View 时，Agent 直接查询底表。表里有四个金额字段，Agent 不理解哪一个才是活动预算，于是把所有金额字段加总，得到约 29,161,800 元。这个结果是错的，不相关的字段也被算了进去。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">在演示使用的 campaign_analytics 中，“活动总预算”对应 total_bbbb_amount，计算表达式为 SUM(bbbb_amount)。Agent 读取这份定义后，选择对应字段求和，得到 1,980,000 元；没有把其他金额字段一并加入。录像中最终执行的仍然是底表 SQL，Semantic View 提供了选择和计算指标的业务依据。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">Semantic View 把业务名称、指标公式和分析维度组织成可复用的定义，让不同 Agent 使用共同的计算依据，减少各自解释字段和拼接口径带来的偏差。查询结果可以结合指标定义与执行 SQL 进行核查。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><div data-brushtype="text"><p style="line-height:1.75em;"><span style="color: #138bde;"><strong><span leaf="">示例：零售客户的订单域</span></strong></span></p></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">以一个零售客户的订单分析为例。在订单域里，需要先区分订单和订单明细。一笔订单可能包含多条明细商品，两者的统计粒度并不相同。Semantic View 按订单与商品明细建立业务主题：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">订单主题定义&#34;订单数&#34;和&#34;取消率&#34;，按门店、月份分析；</span></span></p></li><li><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">销售明细主题定义&#34;折后实收金额&#34;，按渠道、品类、商品分析。</span></span></p></li></ul><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">两个主题的统计边界也在定义里写清楚：销售额统计已支付订单，用销售明细主题的折后实收金额；取消率则是取消订单数除以全部订单数。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">Semantic View 定义指标怎样计算、可以按哪些维度分析；业务规则补充统计边界和例外；业务资料提供政策、事件与原文依据；分析方法规定拆解与核查步骤；任务记忆保留已确认的条件与结论。这些内容可独立维护，由 MirrorMind 统一管理关联、来源、版本和访问权限，再由 Agent 按任务组合使用。这样能够说明 Context 不只有 Semantic View，也能支撑业务上持续的知识迭代。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><div data-brushtype="text"><p style="line-height:1.75em;"><span style="color: #138bde;"><strong><span leaf="">像管理代码一样管理知识</span></strong></span></p></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">Agent 需要的上下文，不止涉及一个 Semantic View。比如分析一次指标异动，往往还要关联业务知识和标准的分析流程。我们把它统称为企业上下文。MirrorMind 把这些上下文统一管理：内容的关联、来源与版本、访问权限。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">管理方式和代码很像，我们借鉴了 Git 的思路：知识可以创建分支，每个分支上有不同的版本；可以按版本回溯，查看任意版本在某个时间的快照；经过业务确认后，正确的版本再上线。业务在迭代，知识也在迭代，但每个 Agent 拿到的，都是经业务确认、已上线的版本。用户的反馈会留下完整的 trace 记录，成为下一轮知识迭代的输入。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">多个任务复用经确认的业务定义与背景知识，减少口径漂移；知识更新经过验证后采纳，并保留版本与修订依据，供后续任务复用和回溯。</span></span></p><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.562962962962963" data-s="300,640" data-type="png" data-w="1080" style="width:100%;" type="block" data-backw="568" data-backh="320" data-imgfileid="100154591" src="https://wechat2rss.xlab.app/img-proxy/?k=a4b6e823&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FgiamgWvCHDYZbdkRlUgicKBA7ICTgtIGyQlRBgwmd56bEVpJbWSmlj2NAejSGIHCLj5Cb4rzs4V4bzSqMmKvwD1ia0AvPWAQZWibT8VupqOXPAY%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p></div><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">MirrorPilot：Agent 的运行与交付环境</span></strong></span></p></div></div></div></div><div data-role="paragraph"><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">数据能查到，口径可信，最后一步是把它们组织成 Agent，交付给业务。这是 MirrorPilot 的职责。它是企业的 Agent 运行和交付环境，向下串联 MirrorData 和 MirrorMind，对外交付结果。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><div data-brushtype="text"><p style="line-height:1.75em;"><span style="color: #138bde;"><strong><span leaf="">四步完成一次任务</span></strong></span></p></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">用户侧有两条使用路径下达任务。一条是直接对话，通过产品工作台完成分析；另一条是通过 API 接入原有的业务系统，复用 Agent 的能力。</span></span></p><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.562962962962963" data-s="300,640" data-type="png" data-w="1080" style="width:100%;" type="block" data-backw="568" data-backh="320" data-imgfileid="100154592" src="https://wechat2rss.xlab.app/img-proxy/?k=2b54e8ad&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYaxxlZQiaH8vl6BtI8n3JXqpetrCWSLYTTKTzkRdoSeATbYJhmz9lmIefUia4Ggrx02TKqtjTL1vzYcXEVkfEKVAWsw3Ql0kibzb4%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">一次任务的执行分为四步。先理解目标；再结合上下文和现有 Skill，组织执行方案；然后调用工具，比如查询 Semantic View 里的具体定义；最后处理结果。简单任务到这里就直接交付，复杂任务会重复检索、多步执行，再把最终结果返回给业务。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">MirrorMind 按任务的需要提供上下文，MirrorData 负责结果的查询和佐证。围绕运行本身的还有一整套周边管理：会话管理、任务状态、资源范围、预算、超时和运行记录，都内置在 MirrorPilot 里。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><div data-brushtype="text"><p style="line-height:1.75em;"><span style="color: #138bde;"><strong><span leaf="">交付的不只是答案</span></strong></span></p></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">MirrorPilot 的交付物，可以是一段回答，也可以是报表和 API。执行过程会严格留痕：这次计算用的是哪条 SQL、口径规则是什么，都清晰可查。用户可以继续追问，也可以对整个任务溯源。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><div data-brushtype="text"><p style="line-height:1.75em;"><span style="color: #138bde;"><strong><span leaf="">开放接入，能力沉淀</span></strong></span></p></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">接入是开放的。MirrorPilot 提供 Agent API，企业可以从已有 BI、经营门户或业务系统发起任务，经服务端鉴权后获取任务结果或会话链接，并按现有应用的交互方式完成集成。自定义 Skill 用于扩展分析步骤，MCP 用于接入外部工具。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">能力是会沉淀的。已有分析逻辑可以沉淀为 SQL 模板，同类问题按时间、维度等参数复用查询逻辑，执行后返回结果，减少重复生成查询的工作。业务知识、SQL 模板和 Skill 都能持续复用与迭代，也支持自定义 Skill 的接入和管理。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">因此，MirrorPilot 既可以独立运行，也可以接入企业原有的应用，逐步扩展分析能力。</span></span></p></div><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">MirrorControl：配套的管理控制后台</span></strong></span></p></div></div></div></div><div data-role="paragraph"><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">与 MirrorPilot 配套的，是 MirrorControl 管理控制后台。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">配置 Agent 时，在这里选择数据范围、知识库，以及要用到的 Semantic View 和 Skill。它还提供知识检索能力，比如&#34;取消率在企业内部是如何定义的&#34;，输入问题就能得到定义和提示。</span></span></p><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.7490740740740741" data-s="300,640" data-type="png" data-w="1080" style="width:100%;" type="block" data-backw="568" data-backh="425" data-imgfileid="100154593" src="https://wechat2rss.xlab.app/img-proxy/?k=54a239d8&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FgiamgWvCHDYYHa49B5PDiaMSInEIWnSwseSDJ7xia6Zv1CMmSxHicbibL1I00d2DU8wia5hr1Lbp91SzT7M3xrl0gZaJUrFVqV2ZAIcDibBCJUjWibU%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p></div><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">示例：一个零售客户的经营分析 Agent</span></strong></span></p></div></div></div></div><div data-role="paragraph"><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">最后用一个脱敏案例，把三层串起来：某客户用 MIP 配置了自己的经营分析 Agent。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><div data-brushtype="text"><p style="line-height:1.75em;"><span style="color: #138bde;"><strong><span leaf="">配置：先圈定范围</span></strong></span></p></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">配置 Agent 的第一步，是定义业务范围：Agent 所需的数据范围是什么，业务域相关的 Semantic View 是哪些，相关知识库在哪里。圈定范围的目的，是缩小 Agent 的检索范围，避免知识混淆，造成错误的答案。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">然后是角色、回答规则和 Skill 的配置。比如追问和下钻时走什么标准流程，输出报告用什么样式，都在这里定义。查询和检索工具内置在 Agent 里，可以直接检索企业内部知识和 Semantic View。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><div data-brushtype="text"><p style="line-height:1.75em;"><span style="color: #138bde;"><strong><span leaf="">演示：从一个问题到一份报告</span></strong></span></p></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">配置完成后，看一次完整的使用过程。</span></span></p><p nodeleaf=""></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">进入平台，先选择 Agent，它的分析范围在配置时已经圈定。直接用自然语言提问，比如让 Agent 按渠道拆分销售额。Agent 会给出每个渠道的分析结果，附带图表和原始 SQL。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">涉及数据查询的回答，用户可以查看相关查询语句、指标与时间范围，并结合计算口径核查结果。保留查询和知识来源，使分析过程更容易追溯。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">接着追问：&#34;这个指标正常吗？按部门拆解合理吗？&#34;Agent 会调用企业上下文里的标准流程和 SOP，比如对订单取消率做异常识别。异常判定规则与分析方法由 MirrorMind 作为企业上下文统一管理，MirrorPilot 在任务中读取相关知识、组织步骤，并调用 MirrorData 执行查询。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">若再追问一句：&#34;为什么会飙升？&#34; Agent 按分析方法继续检查品类、品牌和商品，并检索仓储事件及库存记录。它把这些信息与门店取消率变化结合起来，提出可能原因、相关证据和建议动作，供业务人员进一步核查。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">分析完成后，用户可以继续通过对话要求生成管理层报告。Agent 将当前任务中的数据、图表、业务资料与分析结论整理成可打开、可下载的 HTML 报告，供业务部门讨论和核查。</span></span></p><div data-tools="135编辑器" data-id="86152"><div style="margin-top: 10px;margin-bottom: 10px;display:flex;"><div style="display: inline-block;vertical-align: middle;font-size: 16px;padding-left: 10px;box-sizing:border-box;"><div data-brushtype="text"><p style="line-height:1.75em;"><span style="color: #138bde;"><strong><span leaf="">回到开头的三个问题</span></strong></span></p></div></div></div></div><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">MirrorData 让检索结果能够继续参与 SQL 关联与分析；MirrorMind 集中维护业务口径与企业知识，让多个 Agent 复用共同的定义和依据；MirrorPilot 将数据、Context 与分析方法组织成业务任务，交付可核查、可追溯的答案与报告。</span></span></p><p style="line-height:1.75em;"><span style="font-size: 15px;color: #3e3e3e;letter-spacing: normal;line-height: 1.6em;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">三个问题落在同一个底座上，这个底座就是 MIP。</span></span></p><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.27586206896551724" data-s="300,640" data-type="png" data-w="580" style="width:100%;" type="block" data-backw="568" data-backh="157" data-imgfileid="100154607" src="https://wechat2rss.xlab.app/img-proxy/?k=dbcda8d4&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYZI7dY63Js3cC4Zia33qerBH4QIKKib6CZtMFjkJoCYzm0nQTGbgeXyCbXKZD1icog9gqP9IyElSXcHGfoY1luP1Cw2ESHia2Z7rxg%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></p></div></div></div></div></div></div><p style="display: none;"><mp-style-type data-value="3"></mp-style-type></p>



<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=904485e4&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzkzMjYzNjkzNw%3D%3D%26mid%3D2247638266%26idx%3D1%26sn%3Df9f96c657ae85f739b6d067a0aeb62b5">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Fri, 23 Oct 2026 07:15:00 +0800</pubDate>
    </item>
    <item>
      <title>架构师必备：解决技术问题当从第一性原理开始</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzkzMjYzNjkzNw==&amp;mid=2247638266&amp;idx=2&amp;sn=fb40ec19ab259899bf54cf0662b3029c</link>
      <description>很多所谓的「技术难题」，其实根本不是技术问题。</description>
      <content:encoded><![CDATA[<p><span>潘锦</span> <span>2026-10-23 07:15</span> <span style="display: inline-block;">广东</span></p>




  <p>以下文章来源于：架构和远方</p>
  <strong>架构和远方</strong>
  <p>专注 AIGC SaaS 技术架构和技术团队管理，坚持分享技术架构和技术团队管理上的思考和总结。对于 AIGC 工程架构、研发效能、团队管理和思维、创业过程中的技术选型、大型网站架构、高性能高可用可扩展架构实现也会有所涉及。</p>



  
  <p><img src="https://wechat2rss.xlab.app/img-proxy/?k=a026d436&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FgiamgWvCHDYZrfkRYHEMe5o8PGU2A63twQYqz8LeNkdZrV1vXGYWJY1cfN51ZYk8BeiaS4ibmfxoibdPliaoAx0pfH505VVEQoJeujEwicNApocnU%2F0%3Fwx_fmt%3Djpeg"/></p>
  <p>很多所谓的「技术难题」，其实根本不是技术问题。</p>
  <p class="custom_select_card_wrp mp_profile_iframe_wrp" style="margin-bottom: 0px;" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-service_type="1" data-verify_status="2"></mp-common-profile></p><div data-role="outer" label="edit by 135editor" data-pm-slice="0 0 []"><div data-role="paragraph"><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">前两天系统陆续告警，海外服务器访问图片 CDN 经常会出现异常，连接慢，超时，或者下载到一半了失败，错误日志如下：</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="shell"><code><span leaf=""><span class="code-snippet__meta prompt_">&gt;</span> Connection broken: IncompleteRead(49292 bytes <span class="code-snippet__built_in">read</span>, 2611057 more expected)<span class="code-snippet__string">&#39;,</span> </span></code><br/><code><span leaf=""><span class="code-snippet__meta prompt_">&gt;</span><span class="code-snippet__string">IncompleteRead(49292 bytes read, 2611057 more expected</span></span></code><br/></pre></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">当看到这些，第一个反应就是加重试和延长超时时间，有一些缓解，但是还是会出错。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">当某天下午又有问题出现后，忽然想起，重试和延长超时时间并不是解决本质的问题，只是缓解了问题。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">从第一性原理，尝试脱离业务查找图片 CDN 无法访问的问题，尝试发现直接访问存储的外网地址是正常的，但是通过 CDN 会有问题，ping cdn 的域名，延时还能接受。现在看只能是回源的问题，于是找云服务商来定位日志，最终的原因是回源没有带源站地址，导致海外访问受限（为什么，这点云没有做详细解释，模模糊糊说是跨境的问题，因为在国内，之前的配置是没有问题的）。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">一、什么是第一性原理？</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这个词听起来很高大上，其实道理很简单。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">想象你是个外星人，刚刚来到地球，看到人类在用轮子运输货物。你不会想&#34;轮子就应该是圆的&#34;，而是会问&#34;为什么需要运输？&#34;&#34;什么形状最省力？&#34;通过基础的物理定律，你会发现圆形确实是最优解。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这就是第一性原理的精髓——<span textstyle="" style="font-weight: bold">抛开所有的经验、惯例和「理所当然」，回到最基础的事实和逻辑，重新推导解决方案。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">在技术领域，我们太容易被各种「最佳实践」、「业界标准」、「大厂方案」所影响。遇到问题，第一反应往往是去搜索现成的解决方案，或者套用以前的经验。这本身没错，但当这些方法都不管用时，就需要回到问题的本质了。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">二、为什么我们需要第一性原理？</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">做技术久了，你会发现一个有趣的现象：很多所谓的「技术难题」，其实根本不是技术问题。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">比如，系统性能差，大家就想着优化代码、加缓存、扩容。但如果从第一性原理出发，先问问「用户真正的需求是什么？」，可能会发现某些功能根本没人用，直接下线就解决了性能问题。（有些问题不用解决，解决问题本身就行）</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">再比如，团队总是出线上故障，常规思路是加强测试、完善监控、制定流程。但深入分析会发现，80%的故障都源于某个老旧模块，与其不断打补丁，不如花时间重构它。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">技术圈有个词叫「过度工程」，说的就是用复杂的方案解决简单的问题。为什么会这样？<span textstyle="" style="font-weight: bold">因为我们太习惯于在既有框架内思考，忘记了问题的本质可能很简单。</span></span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">三、技术思维的三个陷阱</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">在日常工作中，有三种思维陷阱特别容易让我们偏离问题的本质：</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">1. 经验主义陷阱</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">&#34;上次遇到类似问题就是这么解决的。&#34;</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">经验是财富，但也可能是枷锁。技术在变，业务在变，用户在变，昨天的解决方案未必适合今天的问题。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">曾经见过一个案例，某电商网站的订单系统经常超时。后台小哥凭经验判断是数据库性能问题，花了大量时间优化 SQL、加索引、分库分表。结果呢？问题有所减轻，但是还是会出现。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">后来从头分析才发现，真正的瓶颈是订单生成时要调用外部服务做各种校验和预处理，其中一个服务响应特别慢。如果一开始就从基础事实出发——「订单生成需要多长时间？时间都花在哪里？」——问题早就解决了。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">2. 权威崇拜陷阱</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">「Google是这么做的，肯定没错。」</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">大厂的方案确实值得学习，但照搬往往水土不服。Google 的解决方案是基于它的业务规模、技术栈、团队能力设计的，这些前提条件你都具备吗？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">记得有个创业公司，看到大厂都在搞微服务，也把自己不到 10 人的团队、日活 1 万左右的产品拆成了十几个服务。结果呢？运维成本暴增，开发效率直线下降，最后不得不重新合并服务。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">3. 工具依赖陷阱</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">「用了最新的框架，一定能解决问题。」</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">技术圈总是充满各种新工具、新框架、新概念。但工具只是工具，关键是要解决什么问题。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">曾经见一个项目，前端框架从 jQuery 升级到 Angular，又换成 React。每次重构都说是为了「提升开发效率」和「改善用户体验」。可实际上，用户的核心诉求——&#34;页面加载太慢&#34;——从来没有被真正解决过。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">如果从第一性原理思考：用户要的是什么？快速加载。为什么慢？图片太大、请求太多。怎么解决？压缩图片、合并请求。这跟用什么框架其实关系不大。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">当然，框架升级并不是一个一定不对的事情，技术的升级也是有必要的，但是需要看其本质是想改变什么。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">四、第一性原理的实战应用</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">说了这么多理论，来看看在实际技术问题中如何应用第一性原理。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">案例一：神秘的数据库连接池爆满</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">有个项目突然开始频繁报数据库连接池满的错误。常规思路是什么？加大连接池、优化慢查询、增加数据库实例。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">但我们决定从基础事实开始：</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">第一步：确认基础事实</span></span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">连接池大小：100</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">平均活跃连接数：20-30</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">报错时连接数：100</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">每个请求的数据库操作：2-3次</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">第二步：分解问题</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">既然平时只用20-30个连接，为什么会突然用满100个？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">通过监控发现，每天下午3点左右连接数会激增。这个时间点有什么特殊的？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">第三步：追踪本质</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">深入代码发现，有个定时任务在下午3点执行，它会并发处理大量数据。关键是，这个任务的事务没有正确关闭，导致连接无法释放。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">第四步：简单解决</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">修复事务管理的bug，问题彻底解决。连接池大小维持在50就足够了。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">如果一开始就盲目扩大连接池，不仅掩盖了真正的问题，还会增加数据库的负担。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">案例二：永远优化不完的首页</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">另一个经典案例是首页性能优化。产品经理总是抱怨首页加载慢，技术团队已经做了各种优化：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">静态资源上CDN ✓</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">图片懒加载 ✓</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">接口合并 ✓</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">服务端缓存 ✓</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">数据库索引优化 ✓</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">但用户还是觉得慢。怎么办？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">回到基础问题：用户说的「慢」到底是什么？</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">通过用户访谈发现，他们说的「慢」不是首页加载慢，而是「找到想要的商品慢」。原来首页堆积了太多内容，用户需要不断滚动、寻找，体验自然不好。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">真正的解决方案：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">简化首页内容</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">改进搜索和分类</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">个性化推荐</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">技术优化做到极致，不如产品设计的一个小改进。这就是第一性原理的力量——让你跳出技术视角，看到问题的全貌。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">案例三：微服务还是单体？</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这可能是近几年最容易引发争论的架构问题。很多团队一上来就要搞微服务，理由通常是：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">大家都在用微服务</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">微服务更先进</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">方便团队协作和扩展</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">容易扩展</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">但如果用第一性原理思考：</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">基础问题是什么？</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">我们要构建一个满足业务需求的系统。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">核心约束是什么？</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">团队规模：5 个人还是 50 个人？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">业务复杂度：简单 CRUD 还是复杂业务逻辑？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">性能要求：日活千万还是几万或几千？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">开发效率：快速迭代还是稳定运行？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">从零思考架构：</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">如果你的团队只有 5 个人，业务逻辑也不复杂，那么单体应用可能是最优选择：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">部署简单</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">调试方便</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">没有网络开销</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">事务处理简单</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">随着业务增长，当单体应用真的成为瓶颈时，再考虑拆分也不迟。这时你会更清楚哪些模块需要独立，哪些可以保持在一起。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">记住，微服务不是目标，解决业务问题才是。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">五、如何培养第一性原理思维？</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">知道第一性原理重要是一回事，真正在工作中应用又是另一回事。这里分享一些我的实践经验：</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">1. 养成追问「为什么」的习惯</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">遇到问题不要急着动手，先问几个为什么：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">为什么会出现这个问题？</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">为什么以前没有这个问题？</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">为什么是现在出现？</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">为什么影响的是这些用户？</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">每个「为什么」都可能让你更接近问题的本质。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">2. 区分表象和原因</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">医生看病会区分症状和病因，技术问题也一样。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">用户说「系统很卡」是症状，真正的原因可能是：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">网络延迟高</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">服务器 CPU 占用率高</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">数据库死锁</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">前端渲染性能差</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">甚至可能是用户电脑太老... （之前工业互联网创业时就遇到过这种情况）</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">不要被症状迷惑，要找到真正的病因。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">3. 建立度量和验证机制</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">第一性原理强调基于事实，而不是猜测。所以要学会度量和验证：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">性能问题：先测量，找到瓶颈在哪</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">稳定性问题：收集数据，分析故障模式</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">用户体验问题：做用户调研，理解真实需求</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">数据会告诉你真相，而不是你的直觉。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">4. 练习「从零开始」思考</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">定期做这样的思维练习：</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">「如果让我从零开始设计这个系统/解决这个问题，我会怎么做？」</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这能帮你跳出现有框架的限制，找到更优解。</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">5. 保持谦逊和好奇</span></strong></span></p></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">技术发展太快，昨天的真理可能今天就过时了。保持开放的心态，随时准备推翻自己的认知。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">同时，不要羞于承认「我不知道」。正是这种诚实，才能让你回到基础事实，而不是基于错误的假设做决策。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">六、什么时候用第一性原理？</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">需要说明的是，不是所有问题都需要用第一性原理。如果每个问题都从零开始思考，效率会非常低。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">适合使用第一性原理的场景：</span></span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">常规方法失效时：</span>试过各种方案都不管用，说明可能方向就错了</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">面对全新问题时：</span>没有先例可循，必须从基础原理推导</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">需要创新突破时：</span>想要 10 倍改进而不是 10% 优化</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">资源极度受限时：</span>必须找到最本质、最经济的解决方案</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">存在重大分歧时：</span>团队争论不休，需要回到基础事实达成共识</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">不适合的场景：</span></span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">有成熟解决方案的常规问题：</span>比如做个登录功能，不需要重新发明轮子</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">时间紧急的情况：</span>先用已知方案解决燃眉之急，后续再优化</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">成本敏感的场景：</span>从零开始的成本可能远高于使用现成方案</span></span></p></li></ul><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">七、第一性原理与工程实践</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">有人可能会问：强调第一性原理，是不是意味着否定所有的最佳实践和设计模式？</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">并不是。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">第一性原理是一种思维方式，不是要你抛弃所有经验。正确的做法是：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">理解原理：</span>知道最佳实践背后的原理是什么</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">判断适用性：</span>这个原理在当前场景下是否依然成立</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">灵活应用：</span>根据实际情况调整，而不是生搬硬套</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">举个例子，「数据库索引可以提升查询性能」是个最佳实践。但背后的原理是什么？索引通过空间换时间，用额外的存储来加速查找。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">那么在什么情况下这个实践可能不适用？</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">表很小，全表扫描比使用索引更快</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">写入频繁，索引维护成本太高</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">查询模式复杂，单个索引无法覆盖</span></span></p></li></ul><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">理解了原理，你就能做出正确的判断。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">八、一个思维框架</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">最后，分享一个我常用的思维框架，帮助在实际工作中应用第一性原理：</span></span></p><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">第一步：定义问题</span></strong></span></p></div></div></div><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">问题的表象是什么？</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">影响范围有多大？</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">什么时候开始的？</span></span></p></li></ul><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">第二步：收集事实</span></strong></span></p></div></div></div><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">哪些是可以测量的数据？</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">哪些是已经验证的事实？</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">哪些是推测和假设？</span></span></p></li></ul><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">第三步：分解结构</span></strong></span></p></div></div></div><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">系统由哪些部分组成？</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">各部分如何相互作用？</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">问题可能出在哪个环节？</span></span></p></li></ul><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">第四步：追溯原理</span></strong></span></p></div></div></div><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这个环节的基本原理是什么？</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">在当前场景下原理是否成立？</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">有什么隐含的假设？</span></span></p></li></ul><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">第五步：重构方案</span></strong></span></p></div></div></div><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">基于原理，最简单的解决方案是什么？</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这个方案的风险和成本如何？</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">如何验证方案的有效性？</span></span></p></li></ul><div data-tools="135编辑器" data-id="86152" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;border: 0px none;z-index: 0;"><div style="max-inline-size: 100%;margin: 10px 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: flex;"><div style="max-inline-size: 100%;margin: 0px;padding: 0px 0px 0px 10px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;display: inline-block;vertical-align: middle;font-size: 16px;"><p data-brushtype="text" style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;color: #138bde;"><strong style="max-inline-size: 100%;margin: 0px;padding: 0px;box-sizing: border-box !important;overflow-wrap: break-word !important;outline: none 0px !important;cursor: text;"><span leaf="">第六步：迭代优化</span></strong></span></p></div></div></div><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">实施后效果如何？</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">是否还有改进空间？</span></span></p></li><li><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">学到了什么新的认知？</span></span></p></li></ul><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">九、写在最后</span></strong></span></p></div></div></div></div><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">技术圈有句话：「没有银弹」。意思是没有一种技术或方法能解决所有问题。第一性原理也不是银弹，但它是一种强大的思维工具。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">在这个技术快速迭代、框架层出不穷的时代，掌握第一性原理思维尤其重要。它能帮你在纷繁复杂的技术选择中保持清醒，找到问题的本质，做出正确的决策。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">下次遇到棘手的技术问题时，不妨停下来问问自己：</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">「如果我是第一个遇到这个问题的人，没有任何前人经验可以借鉴，我会怎么思考？」</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">答案可能会让你惊喜。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">真正的高手不是掌握了多少技术，而是掌握了技术背后的原理。当你能够从第一性原理出发思考问题时，你就真正理解了技术的本质。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">这条路可能不太好走，需要不断质疑、思考、验证。但相信我，这是成为技术专家的必经之路。</span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><span textstyle="" style="font-weight: bold">与其做一个熟练的技术工人，不如做一个会思考的问题解决者。</span></span></span></p><p style="line-height:1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">以上。</span></span></p></div><div data-role="paragraph" style="font-family:sans-serif;"><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">作者丨潘锦</span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;text-align: left;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">来源丨公众号：架构和远方（ID：ArchMoreFuture）</span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">dbaplus社群欢迎广大技术人员投稿，投稿邮箱：</span></span><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">editor@dbaplus.cn</span></span></p><p class="custom_select_card_wrp mp_profile_iframe_wrp" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-servicetype="0" data-verify_status="2"></mp-common-profile></p><p style="text-align: center;" nodeleaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.07777777777777778" data-s="300,640" data-w="1080" type="block" data-imgfileid="100130225" src="https://wechat2rss.xlab.app/img-proxy/?k=f32823a4&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FufWcjcomw8Zf2jiaBBH3vdgfP4A2rem5YEAHYH074dc4GibhojA5B3lLZrXLDRciaVnficveaHcAUCiaIPoDsTkAduA%2F640%3Fwx_fmt%3Dpng"/></p></div></div><p style="display: none;"><mp-style-type data-value="3"></mp-style-type></p>



<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=0c0f9862&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzkzMjYzNjkzNw%3D%3D%26mid%3D2247638266%26idx%3D2%26sn%3Dfb40ec19ab259899bf54cf0662b3029c">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Fri, 23 Oct 2026 07:15:00 +0800</pubDate>
    </item>
    <item>
      <title>文件路径简史：从 &gt; 到 / 与 \ ，斜杠家族为何能胜出？</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzkzMjYzNjkzNw==&amp;mid=2247638207&amp;idx=1&amp;sn=9e74d5de08980950445639c4d0ec1f53</link>
      <description>回顾文件路径演变历程，侧面窥见操作系统的发展史，以及不同操作系统间的相互影响。</description>
      <content:encoded><![CDATA[<p><span>dbaplus社群</span> <span>2026-10-22 07:15</span> <span style="display: inline-block;">广东</span></p>






  
  <p><img src="https://wechat2rss.xlab.app/img-proxy/?k=ccd3cf64&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYYCpYqmk6V3eyYBmVITckYtc42qYib9fiajJqwSblDm1pcB7IjxcmA4ss11ajKHPErGcXAQHzAnwoH2YO0ewIcHa16KUJv5ESGHU%2F0%3Fwx_fmt%3Djpeg"/></p>
  <p>回顾文件路径演变历程，侧面窥见操作系统的发展史，以及不同操作系统间的相互影响。</p>
  <p class="mp_profile_iframe_wrp" style="margin-bottom: 0px;" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-service_type="1" data-verify_status="2"></mp-common-profile></p><div data-role="outer" label="edit by 135editor" data-pm-slice="0 0 []"><div data-role="paragraph"><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">文件路径（file path）广泛用于表示操作系统中的目录/文件关系，也是用于确定系统中文件位置的方式之一。</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">现如今，常用的文件路径表示方式有两种：Unix &amp; 类 Unix 使用<span textstyle="" style="font-weight: bold;">“/（正斜杠/撇斜杠）</span>”分隔路径，DOS[1] 以及后来的 Windows 则默认使用“<span textstyle="" style="font-weight: bold;">\（反斜杠/捺斜杠）</span>”。</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">然而疑问就来了：</span></span></p><ul style="list-style-type: disc;" class="list-paddingleft-1"><li><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">DOS &amp; Windows 与 Unix 并非“师出同门”，为何也选择了“斜杠”？</span></span></p></li><li><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">许多情况下 Windows 也支持“/”分隔路径，那么一开始选择“\”的目的何在？</span></span></p></li><li><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">除了斜杠，历史上有没有出现过使用其他符号的路径表示方式呢？</span></span></p></li></ul><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">带着这些疑问，下文就来回顾文件路径的演变历程，也算是从一个侧面窥见操作系统的发展史以及不同操作系统间的相互影响。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">一、Multics：“&gt;”</span></strong></span></p></div></div></div></div><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">一般认为第一个引入分层文件系统的操作系统是 20 世纪 60 年代的 <span textstyle="" style="font-weight: bold;">Multics</span>，它由麻省理工学院、贝尔实验室和通用电气公司设计。</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Multics 选用了“&gt;”表示（相对工作目录的）下一级目录，“&lt;”用于表示（相对工作目录的）上一级目录（常用于表示相对路径），模拟箭头的形状（→/←）（在我看来是最形象的），如：</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="bash"><code><span leaf="">假设工作目录为：&gt;udd&gt;Demo&gt;JQUser</span></code><br/><code><span leaf="">绝对路径：&gt;udd&gt;Demo&gt;JQUser&gt;subdir&gt;myfile；&gt;udd&gt;NewDemo&gt;JQUser</span></code><br/><code><span leaf="">相对路径：subdir&gt;myfile；&lt;&lt;<span class="code-snippet__string">NewDemo&gt;JQUser</span></span></code><br/></pre></p><p><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.19789473684210526" data-type="png" data-w="1425" style="width:100%;" data-backw="578" data-backh="114" data-imgfileid="100154274" src="https://wechat2rss.xlab.app/img-proxy/?k=4b73ba86&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYYALKzQflcnIlDsBrs67d2wHJN4RSXv2hd23R1xVMjHKqD2Doh1dJhZ0Tb9QCSCVZdMXJQDSLXKoetnfd66gNibBWlqrMolh8mQ%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></p><p style="line-height: 1.75;text-align: center;margin-top: 0px;margin-bottom: 0px;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">Multics</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img class="rich_pages wxw-img" data-aistatus="1" data-backh="167" data-backw="578" data-imgfileid="100154276" data-ratio="0.2889963724304716" style="width:100%;" data-type="png" data-w="827" src="https://wechat2rss.xlab.app/img-proxy/?k=5b682ff0&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FgiamgWvCHDYZnW26ic0oxOQsNzLvlVHYHefVsxBOtdUNFohwdZOBW1PlVhmTibicPSsAGhqglIwiakgzaWwvUG2muxtjZ8eWG0FIfDy2gEXnTXE8%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;margin-top: 0px;margin-bottom: 0px;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">事实上，尽管现在大小于号已不再是常用的路径分隔符，但一些程序在设计路径栏的时候依然会选择它们</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">同时，也有资料（参考资料4）显示，在开发早期，Multics 曾选用过“:（冒号）”作为路径分隔符。</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">（巧合的是，现在常用于表示路径的&#34;/&#34;&#34;\&#34;正好像是把&#34;&gt;&#34;分成了两半，也算是对前辈的一种致敬吧）</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">二、Unix：“/”</span></strong></span></p></div></div></div></div><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">1969年，<span textstyle="" style="font-weight: normal;">在贝尔实验室工作的 Ken Thompson 和 Dennis Ritchie</span><span textstyle="" style="font-weight: bold;"> 在一台 DEC 小型计算机 PDP-7 上编写了 Multics 的改编版</span>，这就是后来的 <span textstyle="" style="font-weight: bold;">Unix</span>。</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Unix 继承了 Multics 包括分层文件系统在内的许多设计，但在路径表示上，Unix 把 Multics 的“&lt;”“&gt;”换成了“/”。</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">替换“&lt;”“&gt;”的原因是“&lt;”“&gt;”在 Unix 中作为输入/输出重定向（将命令的输入和输出从默认的设备（通常是键盘和显示器）重定向到其他地方）字符。</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">而换成“/”的原因可能是因为在 20 世纪 70 年代常用的 Lear-Siegler ADM-3A 终端键盘（以及现在的许多键盘）中，“/”就在“&lt;”“&gt;”的旁边，且不需要按住“Shift”，可直接打出。</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">Unix 以“~”表示当前用户的主目录也与键盘有关，因为终端键盘的波浪线符号和“Home（位于键盘右上角）”一词恰好位于同一个按键上。</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img class="rich_pages wxw-img" data-aistatus="1" data-backh="195" data-backw="578" data-imgfileid="100154278" data-ratio="0.3368421052631579" style="width:100%;" data-type="png" data-w="950" src="https://wechat2rss.xlab.app/img-proxy/?k=4f92246a&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FgiamgWvCHDYaI9TOSCWIuIvC1841eqek4mic7yE5b28buVDSu3Qjouk5XRmTHTDRs7nT3icuQ6pibGuUC8MiamWP8eN2wUAt90vNC0TBxaOLiabSw%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;margin-top: 0px;margin-bottom: 0px;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">Lear-Siegler ADM-3A 终端键盘</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">文件路径分隔符的一个重要特点（或者说，原则）是：该符号能保证不需按下“Shift”键，可直接打出。</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">那可能有人会问了：那上文说的 Multics 呢？我看键盘上“&lt;”“&gt;”在按键上位，需要按下“Shift”键才能打出啊？</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">针对这个问题我去查了一下，结果发现，Multics 第一个采用的打字机 Teletype Model 37，长这样：</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.75" data-type="jpeg" data-w="1024" data-imgfileid="100154280" src="https://wechat2rss.xlab.app/img-proxy/?k=2bd380e1&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FgiamgWvCHDYYZ5l0Fbic8UtPWvEMatNCgG3v5OGzK1Z30ANllQzq9Eia9ic8ISkLFJZq9TMzibJEK8dZklC4JJOB6WPm9xOY94kIxiaGLQCib0j1h4%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;margin-top: 0px;margin-bottom: 0px;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">Teletype Model 37</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">“&lt;”“&gt;”分别在键盘左上角和“TAB”键旁，且都独占一个键位，不需按下“Shift”键才能打出。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">三、&lt;DEC&gt;[VMS]:Mac……</span></strong></span></p></div></div></div></div><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">在介绍 DOS&amp;Windows 前，先来看看其他操作系统的路径表示方式。</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">除了 Unix 的“/”之外，当时的其他操作系统也有自己独特的路径表示方式。</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">与 Unix 相比，DEC 操作系统的路径表示略显复杂。1967 年 DEC（Digital Equipment Corporation，数字设备公司）推出的 TOPS-10 使用 [] 包裹目录，以“,”分隔目录，且目录标在文件名后面（个人觉得这有点不太符合人的操作习惯，毕竟操作系统中目录与文件的关系应是“目录→文件”），如：</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="apache"><code><span leaf=""><span class="code-snippet__attribute">DSKC</span>:MYFILE.TXT[<span class="code-snippet__number">21</span>,<span class="code-snippet__number">589</span>]&lt;<span class="code-snippet__number">055</span>&gt;（依次为：设备名:文件名.文件扩展名[目录]&lt;保护代码&gt;）</span></code></pre></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">后来的 DEC TOPS-20（虽然都叫 TOPS，但其与 TOPS-10 几乎无关）则采用 &lt;&gt; 包裹目录，以“.”分隔目录，如：</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="ruby"><code><span leaf=""><span class="code-snippet__variable">PS</span><span class="code-snippet__symbol">:&lt;USER</span>.<span class="code-snippet__variable">DOCS</span>&gt;<span class="code-snippet__variable">LETTER</span>.<span class="code-snippet__variable">TXT</span>,<span class="code-snippet__number">4</span>（依次为：盘符<span class="code-snippet__symbol">:&lt;</span>目录.子目录…&gt;文件名.文件扩展名,文件版本）</span></code></pre></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">OpenVMS 使用 [] 包裹目录，以“.”分隔目录，如：</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="css"><code><span leaf="">Stromasys001::dka100:[sys0.main]abc.txt;<span class="code-snippet__number">1</span>（依次为：主机名::盘符:[目录.子目录…]文件名.文件扩展名;文件版本）</span></code></pre></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">苹果曾尝试过多种路径表示方式。Lisa OS（1983 年）使用“-”分隔路径，ProDOS（1983年推出，在 Apple II 上运行）使用“/”，Classic Mac OS 则使用“:”，GS/OS（1988年推出，在 Apple IIGS 上运行）同时支持“/”和“:”。</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.5297560975609756" data-type="png" data-w="1025" style="width:100%;" data-backw="578" data-backh="306" data-imgfileid="100154282" src="https://wechat2rss.xlab.app/img-proxy/?k=34591c14&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FgiamgWvCHDYbQg8DFWr9ha7ic5jqMxmw7UGtpoUlMpicdqmscGzXwoyC7xRFwQS2s221yspSjxt7Tl01w6aTo4t5kc1iaicJtgjzJLsSCHe3xicYY%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;margin-top: 0px;margin-bottom: 0px;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">Lisa OS 的文件路径表示方式</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.5343383584589615" data-type="png" data-w="1194" style="width:100%;" data-backw="578" data-backh="309" data-imgfileid="100154284" src="https://wechat2rss.xlab.app/img-proxy/?k=b787360a&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FgiamgWvCHDYYXCplhPwuicEZW7sHZkoXG5KQzSH1UW0S4rEgpNPKO5gibyEZN77Uw7x9OT84HaATNWOxgsSzIaAmcbniaj3DeC1MiaicDrBNoR8go%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;margin-top: 0px;margin-bottom: 0px;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">Apple GS/OS 的路径表示方式</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">后来苹果推出的 Mac OS X（2000年）尽管类似 Unix，采用了“/”的表示方式，但为了保证与 Classic Mac OS 的兼容性，一些情况下文件系统会将文件名中的“:”替换为“/”。</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">1987 年推出的 RISC OS（在 ARM 芯片上运行）则采用如下方式[2]：</span></span></p><p class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"></ul><pre class="code-snippet__js" data-lang="ruby"><code><span leaf="">[文件系统<span class="code-snippet__symbol">:</span>][<span class="code-snippet__symbol">:</span>驱动器号或磁盘名称.]<span class="code-snippet__variable">$.</span>[目录].[文件名]/[文件扩展名]</span></code><br/><code><span leaf="">如：<span class="code-snippet__variable">ADFS</span>::<span class="code-snippet__title">MyRisc</span>PC.<span class="code-snippet__variable">$.</span><span class="code-snippet__title">Documents</span>.<span class="code-snippet__title">Letter</span> (filetyped to text)</span></code><br/><code><span leaf=""><span class="code-snippet__title">LanMan</span>::<span class="code-snippet__title">Windows</span>C.<span class="code-snippet__variable">$.</span><span class="code-snippet__title">Pictures</span>.<span class="code-snippet__title">Example</span>/gif</span></code><br/></pre></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">四、DOS[3] &amp; Windows：“\”</span></strong></span></p></div></div></div></div><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">随着 MS-DOS 2.0 的推出，微软在为 MS-DOS 引入目录设计的同时，<span textstyle="" style="font-weight: bold;">选用了一个不一样的路径分隔符：“\”</span>。</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">既然选了“斜杠”，为什么不用“/”？因为“/”在 DOS 中已被用于选项字符（switch character，用于分隔命令选项参数的字符，如 dir /s，而 Unix 则采用“-”（这也是源于 Multics））</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">那为什么 DOS 的选项字符用的是“/”呢？这一点有不同的说法。</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">微软软件工程师 Larry Osterman 在文章中写到，这与当时 DEC 操作系统的操作习惯有关。</span></span></p><div data-role="paragraph" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="color: #7f7f7f;font-size: 15px;letter-spacing: 0.544px;text-decoration: inherit;caret-color: red;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">许多 DOS 实用程序都是由 IBM 编写的，它们使用“/”字符作为实用程序的选项字符（这是用于分隔命令行参数的字符，在 *nix 上是“-”字符，在大多数 DEC 操作系统（包括 VMS、DECSystem-20 和 DECSystem-10）上是“/”（注：我不确定“/”字符是来自 IBM 还是来自微软——最初的 MS-DOS 开发人员中有几个是 DEC-20 的老手，所以他们可能是从 DEC 中继承的）。</span></span></p><p style="line-height: 1.75;"><span style="color: #7f7f7f;font-size: 15px;letter-spacing: 0.544px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">下图为 Microsoft BASIC-80 的部分命令，其使用“/”作为选项字符。</span></span></p></div></div></div></div><p style="line-height: 1.75;text-align: center;"><span style="font-size: 15px;color: rgb(62, 62, 62);"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="1.1807909604519775" data-type="png" data-w="354" style="width:405px;height:478px;" data-backw="354" data-backh="418" data-imgfileid="100154286" src="https://wechat2rss.xlab.app/img-proxy/?k=e492a996&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYZDsyjX0t76DSq9HicGNoEtpDr3icUoibFfibzHc1VUIqXQ9Tu1ibovp2qx0DpTospv4BQ14ERbric4j3zUtIPdeFviaw4KtSPiczlFuzE%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;margin-top: 0px;margin-bottom: 0px;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">Microsoft BASIC-80 部分命令选项</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">微软的《MS-DOS 百科全书（1988 年）》也提到，微软早期员工 Marc McDonald 开发了一种名为 M-DOS 的 8 位多任务操作系统，该操作系统“以 DEC TOPS-10 操作系统为蓝本”。此外，该书还明确指出：</span></span></p><div data-role="paragraph" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="color: #7f7f7f;font-size: 15px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">MS-DOS 1.x 版借鉴了 DEC 操作系统的传统，在命令行中使用了“/”作为选项字符。</span></span></p></div></div></div></div><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.3617200674536256" data-type="png" data-w="1186" data-imgfileid="100154288" src="https://wechat2rss.xlab.app/img-proxy/?k=8784aa39&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYYuynIszYTGPQx5ialw7VYgKiagI794cian0p805p0RrzOB7wLQSMSYGRfSBu3nk97d0q8MXcic756TuMlPR33nNAZKw4r2y3JkEQ8%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;margin-top: 0px;margin-bottom: 0px;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">DEC TOPS-10 命令</span></span></p><p style="line-height: 1.75;text-align: center;"><span style="font-size: 15px;color: rgb(62, 62, 62);"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.714" data-type="jpeg" data-w="500" style="width: 100%;" data-backw="500" data-backh="357" data-imgfileid="100154291" src="https://wechat2rss.xlab.app/img-proxy/?k=adedb722&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FgiamgWvCHDYbbeO95BNJWJuHMfxACbu2ywVAqroNoNBicyyktUafVIZcb7Jiasldvqmsa2la3hZdknWUvEbx3QkH9Be2I6WpiaicBFPdALajAhu0%2F640%3Fwx_fmt%3Djpeg%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;margin-top: 0px;margin-bottom: 0px;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">微软员工在 DECSystem 2020 设备上进行测试（1979 年）</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">此外，还有人认为，这与 CP/M 有关。对此程序员 John Elliott 做出了澄清。</span></span></p><div data-role="paragraph" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="color: #7f7f7f;font-size: 15px;letter-spacing: 0.544px;text-decoration: inherit;caret-color: red;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">1）CP/M 本身没有“选项字符”的概念。</span>与 DOS 不同，没有系统调用来获取要使用的正确字符（参见 INT 21h/AX=3700h）。每个程序使用的字符由该程序定义。UNIX 也是如此。但与 UNIX 不同的是，CP/M 中不同程序的作者选择了不同的字符。</span></span></p><p style="line-height: 1.75;"><span style="color: #7f7f7f;font-size: 15px;letter-spacing: 0.544px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">2）与 DOS 不同的是，系统不会强制执行文件名是否有效。</span>在 CP/M 2 中，没有调用将文件名转换为 FCB，因此每个程序必须执行自己的操作；CCP 将两个解析后的文件名传递给程序，但程序无法调用其解析器，因此任何其他名称都必须由它们完成 - 不一定遵循相同的规则。</span></span></p><p style="line-height: 1.75;"><span style="color: #7f7f7f;font-size: 15px;letter-spacing: 0.544px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf=""><span textstyle="" style="font-weight: bold;">3）由于不同程序对哪些字符可以/不可以出现在文件名中没有一致的规定</span>，因此选项字符也是不一致的（因为选项字符不能出现在文件名中是有意义的） 。</span></span></p></div></div></div></div><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">然而，有人在 CP/M 3（通常称为 CP/M Plus）用户手册上发现，“/”被规定为“选项分隔符”。然而，CP/M Plus 于 1983 年发布，而在 MS-DOS 最初开发时（1981年）对应 CP/M 最新版本是 CP/M 2，而我并未找到 CP/M 2 及之前版本“/”被规定为“选项分隔符”或“/”不能用于文件名的相关信息。</span></span></p><div data-role="paragraph" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="color: #7f7f7f;font-size: 15px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">CP/M 2.2 用户手册确实有“/”不能用于文件名的说明。然而，该手册在 1982 和 83 年做过更新，所以无法确定在 82 年前 CP/M 2.2 是否也遵循这一规定。而且，根据 John Elliott 的分析，即使有这一规定，程序本身也并不一定遵守。</span></span></p></div></div></div></div><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.4817150063051702" data-type="png" data-w="793" style="width:100%;" data-backw="578" data-backh="278" data-imgfileid="100154293" src="https://wechat2rss.xlab.app/img-proxy/?k=362a455d&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYZkqC7U9X8VuqVOzmwovoMTXawvag7dbnuyIxia0sMUBhqcw5Dlx6CvOcNHichTa8q61FKWEJCqfqB0IILDwyNbwtxCLmAULSbgI%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;margin-top: 0px;margin-bottom: 0px;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">CP/M Plus 手册(1983)</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.1900610287707062" data-type="png" data-w="1147" style="width:100%;" data-backw="578" data-backh="110" data-imgfileid="100154295" src="https://wechat2rss.xlab.app/img-proxy/?k=b38f1200&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FgiamgWvCHDYbFQmpYxib2N4nrdCbNaQAWPVI1RLIcxs2mSHECTe2j7cvRyqTBx7MliaJEIrqrQEnF4X8TicwG5Nux3u9qgKTTFh82ZO8sk90W3Y%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;margin-top: 0px;margin-bottom: 0px;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">CP/M 1.3 手册(1976)</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.1906392694063927" data-type="png" data-w="876" style="width:100%;" data-backw="578" data-backh="110" data-imgfileid="100154297" src="https://wechat2rss.xlab.app/img-proxy/?k=d0b84aca&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYYINMg3nmOa0sw66ArZfuDKxEFbDmDzcGhxaTXnfHg8RQb9R5KejZ2C1fzkINVTOreW64xQg2gIUbic4VYwV96qGZXVvmhick5JQ%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;margin-top: 0px;margin-bottom: 0px;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">CP/M 1.4 &amp; 2.0 摘要(1980)</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">那么问题又来了：<span textstyle="" style="font-weight: bold;">既然微软与 DEC 有这么多的联系，那为什么文件目录没有依照 DEC 操作系统的风格，而是采用了 Unix 的路径表示风格呢？</span></span></span></p><div data-role="paragraph" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="color: #7f7f7f;font-size: 15px;letter-spacing: 0.544px;text-decoration: inherit;caret-color: red;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">对于 MS-DOS 2.0，DOS 的设计者选择了混合版本 - 他们已经支持 DOS 1.0 的驱动器号，因此他们需要继续使用它。他们选择使用 *nix 风格的方法来指定层次结构 - 而不是（如 VMS 和 DEC-20）在文件名中调用目录。</span></span></p><p style="line-height: 1.75;"><span style="color: #7f7f7f;font-size: 15px;letter-spacing: 0.544px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">下图是微软于 1980 年发布的 Unix 操作系统：Xenix。在 20 世纪 80 年代中后期，Xenix 已是最常见的 Unix 系统（根据安装它的机器数量来衡量）。就连当时微软的 DOS 开发人员平时用的也是 Xenix 机器，也因此他们对 Unix 命令和语法十分熟悉。</span></span></p></div></div></div></div><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.5926640926640927" data-type="png" data-w="1036" style="width:100%;" data-backw="578" data-backh="343" data-imgfileid="100154299" src="https://wechat2rss.xlab.app/img-proxy/?k=3899c21b&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYYsCc8fNScwiaCLC6VuQ8EOIoryHkHuvnQGsgy4QMxcRUAaicOpK6pVhgsqA3lbBR2BQiaRxGdJwcibtNE84KMWAPIELzzYUGUjnqk%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;margin-top: 0px;margin-bottom: 0px;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">Xenix</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">当时的微软对 Xenix 也寄予厚望，希望它能成为自己的主要产品之一。而对于 MS-DOS 2.x ，微软也希望它能与自家的 Xenix（Unix）相兼容。于是，MS-DOS 很多方面都借鉴了 Unix，也包括分层文件系统的设计。微软在宣传海报中是这么写的：</span></span></p><div data-role="paragraph" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="color: #7f7f7f;font-size: 15px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">MS-DOS 和 XENIX 共享分层文件结构和 I/O 重定向，包括简单的管道操作。</span></span></p></div></div></div></div><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="1.375" data-type="png" data-w="720" style="width:100%;" data-backw="578" data-backh="795" data-imgfileid="100154302" src="https://wechat2rss.xlab.app/img-proxy/?k=c1b79899&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYb0CU2ziah5aicvPSk4KAk6jxejWxicS0ZNMftSYZsAMjGCR9JFkRJoy4ZTXvKDQ1h5VUkXQ4QkcNcnRYVfvib66lbqbVElfRYZeEE%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;margin-top: 0px;margin-bottom: 0px;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">微软宣传 MS-DOS 和 Xenix 的海报</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">而微软本来希望直接使用 Unix 形式的“/”作为路径分隔符，<span textstyle="" style="font-weight: bold;">但 IBM 不同意，因为这会导致与已采用“/”作为选项字符的 DOS 1.x 的不兼容。</span></span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">当然微软还有其他的选择，比如 DEC 风格的“.”形式，然而这又与分隔文件扩展名的“.”冲突（要么就得像后来的 RISC OS 那样替换“.”）</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">综合考虑了键盘布局（比如，要保证这个符号不需按 Shift 键才能打出）等因素，也可能带有与 Unix 分庭抗礼的意味，微软最终选用与“/”形态相似的“\”作为路径分隔符。</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.37851851851851853" data-type="png" data-w="1350" style="width:100%;" data-backw="578" data-backh="219" data-imgfileid="100154305" src="https://wechat2rss.xlab.app/img-proxy/?k=fcc8c17f&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FgiamgWvCHDYagib2zvxRdW4YM883D4aribL6Ticvews7sI9DV0961lEjqpY0EaTbLBlUIAXEFjzYsMhEnPbIT1rIV2mRSrNZqxzoB9kHu4DaNso%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;margin-top: 0px;margin-bottom: 0px;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">综合考虑了键盘布局等因素，微软最终选用与“/”形态相似的“\”作为路径分隔符。图为 IBM F型键盘(XT)</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">不仅如此，为了兼容 Unix 语法，微软不仅对操作系统进行编码以同时接受 / \ 作为路径字符，甚至还在 config.sys 添加了一个配置选项 SWITCHAR，可以将选项字符更改为“-”。</span></span></p><div data-role="paragraph" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="color: #7f7f7f;font-size: 15px;letter-spacing: 0.544px;text-decoration: inherit;caret-color: red;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">不过，微软可能并没有经过深思熟虑就选择了 \，因为根据现有资料看，微软当时就是想选择 / 作为路径分隔符的，后来是根据 IBM 的要求才进行了修改，改的时候也比较匆忙，因为当时用户手册等配套文件都写好了，突然说要改，连用户手册都来不及修改，只能临时加了一条注释（可参见MS-DOS 发行说明 - GitHub）。如果是这样仓促的情况，很可能当时微软并没有考虑很多，只是看 \ 长得像 / 就选择了 \ 。</span></span></p><p style="line-height: 1.75;"><span style="color: #7f7f7f;font-size: 15px;letter-spacing: 0.544px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">（附注释原文节选：用户手册包含一些重大错误。其中大部分是由于最后一刻的更改而导致的，目的是实现与 IBM 的 MS-DOS（PC-DOS）的更高程度的兼容性。这包括使用“\”而不是“/”作为路径分隔符，以及使用“/”而不是“-”作为选项字符。对于跨机器传输批处理文件，微软鼓励在美国市场分别使用“\”和“/”。）</span></span></p></div></div></div></div><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">目前，Windows 仍支持 / \ 两者作为路径分隔符，但仍有一些情况只支持 \。</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">而现在看来，微软最初选择 \ 也并不十分高明。因为 \ 也用于转义字符，因此在编程等使用环境下可能会导致一些不必要的麻烦。但换个角度看，选其他符号（尤其是已经出现在键盘上的这些符号）也还是会有其他的冲突，所以也很难评价选其他符号就会比 \ 来的更好。</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">五、关于“\”</span></strong></span></p></div></div></div></div><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">其实在当时，“\”算是一个比较新的符号，在 20 世纪 60 年代前还十分少见。</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">直到 1960 年 6 月，IBM 发布了“扩展字符集标准”，其中才有了“\”的影子（位于 0x19 处）。1961 年 9 月，IBM 的 Bob Bemer 向 X3.2 标准委员会提议将“\”纳入拟议标准，以支持 ALGOL 编程语言的逻辑运算符（/\，表示“与”）和（\/，表示“或”）。该提议后来得到了采纳，“\”进入了 ASCII，Bob Bemer 也因此被称为“反斜杠之父”。</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.9405797101449276" data-type="png" data-w="690" style="width:100%;" data-backw="578" data-backh="544" data-imgfileid="100154307" src="https://wechat2rss.xlab.app/img-proxy/?k=d1fcf2be&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FgiamgWvCHDYYybXnBQXn9HibiaYnA7YT1pw3dS6mQrhB0S0icMzk2t6FTEB84L6KOWRaAvrBPUKOiatSu02SAMjXnwWN8ZBJPiaibbOoMqxJicywjrk%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;margin-top: 0px;margin-bottom: 0px;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">IBM 的拓展字符集标准，1960 年 6 月</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.9499323410013532" data-type="png" data-w="739" style="width:100%;" data-backw="578" data-backh="549" data-imgfileid="100154309" src="https://wechat2rss.xlab.app/img-proxy/?k=441e9e84&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FgiamgWvCHDYY5rEroOq0xyHkk6Fn3yjHy2ZaIQYJzIOhAIOJej2iaRl8WohSPLibs74p5aAKmsaeKsCzxdlHPTk7omtE3xkXHDwu8frWT8geLs%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;margin-top: 0px;margin-bottom: 0px;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">ASCII，1963 年</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">“\”进入标准字符集后，为了与出现时间较早的“/（slash，斜杠）”做区分，“\”被称为“后斜斜杠（backslash）”或“反向斜杠（reverse slash）”，国内为了更好区分两者也有用“撇(/)捺(\)斜杠”称谓的。</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.5859728506787331" data-type="png" data-w="1326" style="width:100%;" data-backw="578" data-backh="339" data-imgfileid="100154311" src="https://wechat2rss.xlab.app/img-proxy/?k=9068992f&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYaric4IASMQ6nh1NuCia4bRvGOX6rXvM6uG4ycNgibUAAFPSzzeg0XuYUlliaNxbrics96M38oPwCuTJgmJ5gReViarfDrlAf0NhwuW8%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;margin-top: 0px;margin-bottom: 0px;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">ASCII 与 Unicode 对“\”的命名</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">而在日文/韩文版的 Windows 中，“\”会显示为各自的货币符号（￥/ ₩）。这是因为，ASCII 制定后的 ISO-646 标准将 0x5c 定义为“可本地化”代码点之一，顾名思义，这个点位可以<span textstyle="" style="font-weight: bold;">由不同国家或地区根据需要显示为不同的字形</span>。于是，在 Shift_JIS 中，0x5C 用于表示日元符号；在韩语字符集中则是韩元符号。即使到后来系统已经支持 Unicode 编码，为了保证兼容性，微软依然选择货币符号作为 0x5c 的日韩文字符映射。</span></span></p><div data-role="paragraph" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div label="Copyright © 2015 Yead All Rights Reserved." style="margin: 5px auto;padding: 0px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;font-weight: normal;letter-spacing: 0.544px;text-align: justify;background-color: #ffffff;font-size: 14px;color: #3e3e3e;line-height: 25.6px;font-family:微软雅黑;"><div style="margin: 0px;padding: 5px 0px;max-width: 100%;width: 100%;text-decoration: inherit;word-wrap: break-word !important;box-sizing:border-box;" data-width="100%"><div style="margin: 0px;padding: 0px 0px 5px 20px;max-width: 100%;box-sizing: border-box;word-wrap: break-word !important;border-left: 3px solid #999999;"><p style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;clear: both;min-height: 1em;"><span style="color: #7f7f7f;font-size: 15px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><span leaf="">Shift_JIS 最初基于的 JIS X 0201 早在 1969 年制定，那时候的电脑尚不具备处理双字节文字的能力，所以只能先引入半角的片假名（参考 PC-88 早期、夏普 MZ 等日系机），但代价就是，单字节码位不够了，于是就替换了一些当时还不常用的符号，比如日元符号 ￥ 就取代了 \。</span></span></p></div></div></div></div><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img data-aistatus="1" class="rich_pages wxw-img" data-ratio="0.4342258440046566" data-type="png" data-w="859" style="width:100%;" data-backw="578" data-backh="251" data-imgfileid="100154313" src="https://wechat2rss.xlab.app/img-proxy/?k=c22975b8&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FgiamgWvCHDYZ6I097wibYzcCicHdq34AWNNPiac28PNZeWGfnV2mzK2RaQcM3RXmbzEwzaZMuSW0diaBAbleM16cNDnXmEQJmxvV5Htt9V7pdt1A%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;margin-top: 0px;margin-bottom: 0px;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">日文 Windows 的文件路径</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img class="rich_pages wxw-img" data-aistatus="1" data-backh="183" data-backw="578" data-imgfileid="100154315" data-ratio="0.3161094224924012" style="width:100%;" data-type="png" data-w="658" src="https://wechat2rss.xlab.app/img-proxy/?k=0eb305a3&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FgiamgWvCHDYbcNeC5ibVcqbXJnsR90y7FAfWpR72J5CW7PMoLjyYiaIHnrjvKlWexvcYdia2FtHVxqiaJyiaLskeLjXQPY4iawel1Fj3SXpxJyPD48%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;margin-top: 0px;margin-bottom: 0px;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">韩文 Windows 的文件路径</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf=""><img class="rich_pages wxw-img" data-aistatus="1" data-backh="325" data-backw="578" data-imgfileid="100154318" data-ratio="0.5625" style="width:100%;" data-type="png" data-w="1440" src="https://wechat2rss.xlab.app/img-proxy/?k=5a7542e8&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FgiamgWvCHDYaz56RlLR8BKfnW7NzWyQPKRxAEU7YKeLrF6xib6xfHT0cibUnkIS2JQPPib3wLAJjHgv6WawpaVfpRUf5IvlVUwoiaZ89Z9QUToEo%2F640%3Fwx_fmt%3Dpng%26from%3Dappmsg"/></span></span></p><p style="line-height: 1.75;text-align: center;margin-top: 0px;margin-bottom: 0px;"><span leaf="" style="font-size: 15px;color: rgb(62, 62, 62);"><span textstyle="" style="font-size: 12px;color: rgb(127, 127, 127);">Windows 的字符映射</span></span></p><div data-tools="135编辑器" data-id="86122" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="margin:0.5em 0;"><div style="padding: 0px 0px 2px;text-align: center;color: #ffffff;background-color: #138bde;box-sizing:border-box;"><div style="border-bottom: 1px solid #fefefe;border-top-color: #138bde;border-right-color: #138bde;border-left-color: #138bde;padding: 0.5em 1.5em;box-sizing:border-box;"><p style="color: #ffffff;line-height: 20px;" data-brushtype="text"><span style="font-size: 17px;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">六、总结</span></strong></span></p></div></div></div></div><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">文件路径分隔符的选择看似简单，但其中需要综合考虑<span textstyle="" style="font-weight: bold;">字符本身的特性、键盘布局、该字符的其他功能是否与路径表示冲突</span>等因素，操作系统设计的复杂程度可见一斑。而且，从路径表示的发展历程中，我们也可以窥见不同的操作系统是如何互相影响的。</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">或许现在看来，Unix/Windows 等选用的单字符路径表示方式是最简单的。虽然不能说这样的路径表示是他们得以普及的原因，然而这背后体现出的易用性和较低的学习成本，在计算机向大众普及的过程中也显得不可或缺。</span></span></p><p style="line-height: 1.75;"><span style="font-size: 15px;color: #3e3e3e;"><span leaf="">试想一下，如果 Windows 采用的是 DEC 的路径表示，结果又会如何？</span></span></p><div data-tools="135编辑器" data-id="85988" data-color="#138bde" data-custom="#138bde" style="font-family:sans-serif;"><div style="max-width:100% !important;margin:0 auto;padding: 0;border:none;display:inline-block;width:100%;box-sizing:border-box;" data-width="100%"><p style="margin:0;padding:0;font-size:18px;letter-spacing:-2px;display: inline-block;box-sizing:border-box;"><span style="font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span style="color: #138bde;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: #138bde;opacity: 0.7;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: #138bde;opacity: 0.5;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span><span style="color: #138bde;opacity: 0.3;font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">&gt;</span></strong></span></strong></span></p><div style="margin-left: 10px;color: #138bde;display: inline-block;"><p data-brushtype="text" style="font-size:16px;color:inherit;margin-top:0;margin-bottom:0;"><span style="font-family:&#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Apple Color Emoji&#34;, &#34;Emoji Symbols Font&#34;, &#34;Segoe UI Symbol&#34;, Arial, sans-serif;"><strong><span leaf="">参考资料</span></strong></span></p></div></div></div><p data-role="list"><ul style="list-style-type: disc;margin:0px;padding:0 0 0 30px;list-style-position:outside;" class="list-paddingleft-2"><li><p style="line-height: 1.75;"><span style="font-size: 12px;color: #3e3e3e;"><span leaf="">en.wikipedia.org/wiki/Path_(computing)</span></span></p></li><li><p style="line-height: 1.75;"><span style="font-size: 12px;color: #3e3e3e;"><span leaf="">betawiki.net/wiki/Multics</span></span></p></li><li><p style="line-height: 1.75;"><span style="font-size: 12px;color: #3e3e3e;"><span leaf="">web.mit.edu/multics-history/source/Multics/doc/info_segments/pathname.gi.info</span></span></p></li><li><p style="line-height: 1.75;"><span style="font-size: 12px;color: #3e3e3e;"><span leaf="">www.multicians.org/fjcc4.html</span></span></p></li><li><p style="line-height: 1.75;"><span style="font-size: 12px;color: #3e3e3e;"><span leaf="">multicians.org/mgt.html</span></span></p></li><li><p style="line-height: 1.75;"><span style="font-size: 12px;color: #3e3e3e;"><span leaf="">StackExchange - Why is the root directory denoted by a / sign?</span></span></p></li><li><p style="line-height: 1.75;"><span style="font-size: 12px;color: #3e3e3e;"><span leaf="">StackExchange - Why did Unix use slash as the directory separator?</span></span></p></li><li><p style="line-height: 1.75;"><span style="font-size: 12px;color: #3e3e3e;"><span leaf="">TOPS-10 Operating System Commands Manual</span></span></p></li><li><p style="line-height: 1.75;"><span style="font-size: 12px;color: #3e3e3e;"><span leaf="">TOPS-20_User&#39;s_Guide</span></span></p></li><li><p style="line-height: 1.75;"><span style="font-size: 12px;color: #3e3e3e;"><span leaf="">StackExchange - Why did MacOS Classic choose the colon as a path separator?</span></span></p></li><li><p style="line-height: 1.75;"><span style="font-size: 12px;color: #3e3e3e;"><span leaf="">Apple Lisa Operating System Reference Manual (PDF, 1983)</span></span></p></li><li><p style="line-height: 1.75;"><span style="font-size: 12px;color: #3e3e3e;"><span leaf="">Apple II GSOS Reference Volume 1.pdf</span></span></p></li><li><p style="line-height: 1.75;"><span style="font-size: 12px;color: #3e3e3e;"><span leaf="">RISC OS Filename Translation</span></span></p></li><li><p style="line-height: 1.75;"><span style="font-size: 12px;color: #3e3e3e;"><span leaf="">Larry Osterman - Why is the DOS path character 「\」?</span></span></p></li><li><p style="line-height: 1.75;"><span style="font-size: 12px;color: #3e3e3e;"><span leaf="">OS/2 Museum - Why Does Windows Really Use Backslash as Path Separator?</span></span></p></li><li><p style="line-height: 1.75;"><span style="font-size: 12px;color: #3e3e3e;"><span leaf="">www.seasip.info/Cpm/optchar.html</span></span></p></li><li><p style="line-height: 1.75;"><span style="font-size: 12px;color: #3e3e3e;"><span leaf="">www.cpm.z80.de/manuals/cpm13int.pdf</span></span></p></li><li><p style="line-height: 1.75;"><span style="font-size: 12px;color: #3e3e3e;"><span leaf="">www.cpm.z80.de/manuals/CPM_SummaryGuide.pdf</span></span></p></li><li><p style="line-height: 1.75;"><span style="font-size: 12px;color: #3e3e3e;"><span leaf="">en.wikipedia.org/wiki/Xenix</span></span></p></li><li><p style="line-height: 1.75;"><span style="font-size: 12px;color: #3e3e3e;"><span leaf="">HOW ASCII GOT ITS BACKSLASH - By Bob Bemer</span></span></p></li><li><p style="line-height: 1.75;"><span style="font-size: 12px;color: #3e3e3e;"><span leaf="">StackExchange - Why is backslash called BACK slash when arguably it points forward?</span></span></p></li><li><p style="line-height: 1.75;"><span style="font-size: 12px;color: #3e3e3e;"><span leaf="">At long last, explaining the yen/won/backslash bug plausibly</span></span></p></li></ul></p></div><div data-role="paragraph" style="font-family:sans-serif;"><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">作者丨</span></span><span style="margin: 0px;padding: 0px;max-width: 100%;font-size: 14px;color: #888888;box-sizing: border-box !important;overflow-wrap: break-word !important;letter-spacing: 0.5px;font-family:Helvetica, Arial, sans-serif;"><span leaf="">SUNTRISE</span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;text-align: left;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">来源丨网址：<a href="https://zhuanlan.zhihu.com/p/687399673?share_code=VKAyT0cKZnLO&amp;utm_psn=2083959393670976939" target="_blank">https://zhuanlan.zhihu.com/p/687399673?share_code=VKAyT0cKZnLO&amp;utm_psn=2083959393670976939</a></span></span></p><p style="margin: 0px;padding: 0px 0.5em;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;color: #333333;text-align: justify;background-color: #ffffff;font-size: 16px;line-height: 1.5em;letter-spacing: 0.5px;font-family:sans-serif;"><span style="margin: 0px;padding: 0px;max-width: 100%;font-size: 14px;color: rgb(136, 136, 136);box-sizing: border-box !important;overflow-wrap: break-word !important;letter-spacing: 0.5px;font-family:Helvetica, Arial, sans-serif;"><span leaf="">dbaplus社群欢迎广大技术人员投稿，投稿邮箱：</span></span><span style="margin: 0px;padding: 0px;max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;font-size: 14px;color: #888888;font-family:Helvetica, Arial, sans-serif;"><span leaf="">editor@dbaplus.cn</span></span></p><p class="mp_profile_iframe_wrp" nodeleaf=""><mp-common-profile class="js_uneditable custom_select_card mp_profile_iframe" data-pluginname="mpprofile" data-nickname="dbaplus社群" data-alias="dbaplus" data-from="0" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/vCTfE5pGMr8pFGVmB2epK9WNd2nw12tq5dpiasP1hXGI1QQZ56ty5mqCopPo6MYxv1fZpiaENx0zfEKZhFTMsRiaA/0?wx_fmt=png" data-signature="围绕Database、BigData、AlOps的企业级专业社群。资深大咖、技术干货，每天精品原创文章推送，每周线上技术分享，每月线下技术沙龙，每季度XCOPS&amp;DAMS行业大会。" data-id="MzkzMjYzNjkzNw==" data-is_biz_ban="0" data-service_type="1" data-verify_status="2"></mp-common-profile></p><p style="text-align: center;" nodeleaf=""><img class="rich_pages wxw-img" data-aistatus="1" data-imgfileid="100130225" data-ratio="0.07777777777777778" data-s="300,640" type="block" data-w="1080" src="https://wechat2rss.xlab.app/img-proxy/?k=f32823a4&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FufWcjcomw8Zf2jiaBBH3vdgfP4A2rem5YEAHYH074dc4GibhojA5B3lLZrXLDRciaVnficveaHcAUCiaIPoDsTkAduA%2F640%3Fwx_fmt%3Dpng"/></p></div></div><p style="display: none;"><mp-style-type data-value="3"></mp-style-type></p>



<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=a2414ed8&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzkzMjYzNjkzNw%3D%3D%26mid%3D2247638207%26idx%3D1%26sn%3D9e74d5de08980950445639c4d0ec1f53">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Thu, 22 Oct 2026 07:15:00 +0800</pubDate>
    </item>
  </channel>
</rss>