Production Latency Is Too High(生产延迟过高)
知识库位置:
FDE Knowledge Base/03 Engineering/Troubleshooting/Production-Latency-Is-Too-High.md
Problem(问题)
Section titled “Problem(问题)”用户反馈系统响应时间太长。
First Principle(第一原则)
Section titled “First Principle(第一原则)”不要直接:
换更快模型。
先拆时间。
Latency Breakdown(延迟拆解)
Section titled “Latency Breakdown(延迟拆解)”例如总时间:
18.2s(18.2 秒)拆成:
Frontend(前端) 0.3sAPI(接口) 0.2sAuthentication(认证) 0.1sRetrieval(检索) 0.8sLLM(大语言模型) 4.5sCRM API(客户关系管理接口) 11.7sFormatting(格式化) 0.6s真正瓶颈显然是 CRM。
Use Distributed Trace(使用分布式链路追踪)
Section titled “Use Distributed Trace(使用分布式链路追踪)”推荐:
Request(请求)├─ Auth(认证)├─ Retrieval(检索)├─ LLM(大语言模型)├─ Tool A(工具 A)└─ Tool B(工具 B)每一步都有 Duration(耗时)。
Common Causes(常见原因)
Section titled “Common Causes(常见原因)”Serial Calls(串行调用)
Section titled “Serial Calls(串行调用)”例如:
Call A → Call B → Call C(调用 A → 调用 B → 调用 C)其实 A、B、C 可以并行。
Large Prompt(提示词过大)
Section titled “Large Prompt(提示词过大)”Context(上下文)太长。
Slow Model(模型过慢)
Section titled “Slow Model(模型过慢)”选择模型与任务不匹配。
External API(外部接口慢)
Section titled “External API(外部接口慢)”客户系统本身慢。
Cold Start(冷启动)
Section titled “Cold Start(冷启动)”Container / Function(容器/函数)冷启动。
Database Query(数据库查询慢)
Section titled “Database Query(数据库查询慢)”缺少 Index(索引)。
Fixes(修复)
Section titled “Fixes(修复)”Parallelization(并行化)
Section titled “Parallelization(并行化)”如果操作独立:
A ─┐B ─┼→ Combine(合并)C ─┘Cache(缓存)
Section titled “Cache(缓存)”对稳定数据使用 Cache。
Context Reduction(上下文缩减)
Section titled “Context Reduction(上下文缩减)”减少无关 Retrieval Context(检索上下文)。
Async(异步)
Section titled “Async(异步)”长任务改为 Job(异步任务)模式。
Streaming Response(流式响应)
Section titled “Streaming Response(流式响应)”如果适合,可以让用户更早看到输出。
Define SLO(定义服务等级目标)
Section titled “Define SLO(定义服务等级目标)”不要只说:
越快越好。
应该定义:
P50(第 50 百分位)P95(第 95 百分位)P99(第 99 百分位)例如:
P95 < 5s(P95 小于 5 秒)