{"id":89436,"date":"2026-08-03T01:56:44","date_gmt":"2026-08-02T17:56:44","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/89436.html"},"modified":"2026-08-03T01:56:44","modified_gmt":"2026-08-02T17:56:44","slug":"ai-%e5%ae%9e%e6%97%b6%e6%8e%a8%e7%90%86%e6%b5%81%e5%bc%8f%e9%a2%84%e7%83%ad%e5%ae%9e%e6%88%98%ef%bc%9a%e9%a6%96%e5%ad%97%e7%ac%a6%e5%bb%b6%e8%bf%9f%e4%bb%8e-800ms-%e7%a0%8d%e5%88%b0-200ms-19","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/89436.html","title":{"rendered":"AI \u5b9e\u65f6\u63a8\u7406\u6d41\u5f0f\u9884\u70ed\u5b9e\u6218\uff1a\u9996\u5b57\u7b26\u5ef6\u8fdf\u4ece 800ms \u780d\u5230 200ms"},"content":{"rendered":"<p>TL;DR&#xff08;\u5148\u770b\u7ed3\u8bba&#xff09;<br \/>\n\u5b9e\u65f6\u5bf9\u8bdd\u573a\u666f\u4e0b\u9996\u5b57\u7b26\u5ef6\u8fdf&#xff08;TTFB \/ TTFT&#xff09;\u7684 4 \u4e2a\u5de5\u7a0b\u4f18\u5316\u70b9&#xff1a;<\/p>\n<p>\u8fde\u63a5\u590d\u7528&#xff1a;HTTPS \u63e1\u624b &#043; TLS \u534f\u5546\u5360 ~150ms&#xff0c;\u5168\u7a0b\u957f\u8fde\u63a5 keep-alive \u53ef\u7701 100ms&#043;<br \/>\nPrompt \u9884\u70ed&#xff1a;\u628a\u56fa\u5b9a system prompt \u63d0\u524d 1-2s \u53d1\u8d77 streaming \u8bf7\u6c42&#xff0c;\u8ba9 KV cache \u547d\u4e2d<br \/>\nToken \u9884\u6d4b\u524d\u7f6e&#xff1a;\u5ba2\u6237\u7aef\u5728\u7528\u6237\u505c\u987f\u524d 200-300ms \u6295\u673a\u5f0f\u53d1\u8d77\u4e00\u6b21&#034;\u8349\u7a3f&#034;\u8bf7\u6c42<\/p>\n<p>https:\/\/www.iqiyi.com\/v_2bt98za6w28.html<br \/>\nhttps:\/\/www.iqiyi.com\/v_1meurbm6tik.html<br \/>\nhttps:\/\/www.iqiyi.com\/v_i4z49as7cw.html<br \/>\n\u6d41\u5f0f UI \u6e32\u67d3&#xff1a;\u62ff\u5230\u7b2c 1 \u4e2a chunk \u5c31\u7acb\u5373 yield&#xff0c;\u4e0d\u8981\u7b49\u5b8c\u6574 sentence<br \/>\n\u5b9e\u6d4b\u4ece\u5e73\u5747 TTFT 800ms \u2192 200ms&#xff08;OpenAI gpt-4o-mini&#xff0c;\u56fd\u5185\u4e2d\u8f6c\u8282\u70b9&#xff09;\u3002\u4e0b\u9762\u662f\u8e29\u5751\u8fc7\u7a0b\u3002<\/p>\n<p>\u4e00\u3001\u4e3a\u4ec0\u4e48\u5b9e\u65f6\u573a\u666f\u5bf9 TTFT \u6781\u5ea6\u654f\u611f<br \/>\n\u975e\u6d41\u5f0f batch \u8c03\u7528 LLM&#xff0c;\u7528\u6237\u80fd\u5bb9\u5fcd 2-3s \u7684\u7b49\u5f85&#xff08;loading \u52a8\u753b\u8865\u507f&#xff09;\u3002\u4f46\u5b9e\u65f6\u97f3\u9891\u573a\u666f\u4e0d\u4e00\u6837&#xff1a;<\/p>\n<p>ASR \u6bcf 200ms \u5c31\u5410\u4e00\u4e2a partial transcript<br \/>\n\u7528\u6237\u8bf4\u5b8c\u6700\u540e\u4e00\u4e2a\u8bcd\u5230\u4ed6\u671f\u5f85&#034;\u7cfb\u7edf\u54cd\u5e94&#034;\u7684\u7a97\u53e3\u5927\u7ea6 300-500ms<br \/>\n\u8d85\u8fc7 600ms \u7528\u6237\u4f1a\u4e3b\u89c2\u611f\u89c9&#034;\u5361\u4e86&#034;&#xff0c;\u8d85\u8fc7 1s \u4f1a\u91cd\u590d\u8bf4\u8bdd<br \/>\n\u6211\u4eec\/\u7b14\u8005\u5728\u505a\u5373\u7b54\u4fa0&#xff08;\u4e00\u6b3e\u9762\u5411\u6c42\u804c\u8005\u7684 AI \u9762\u8bd5 copilot&#xff09;\u65f6\u9047\u5230\u8fd9\u4e2a\u95ee\u9898&#xff1a;\u65e9\u671f\u7248\u672c ASR \u6536\u5230 finalize \u4fe1\u53f7\u540e\u518d\u8c03 LLM&#xff0c;TTFT \u5e73\u5747 850ms&#xff0c;\u7528\u6237\u53cd\u9988&#034;\u53cd\u5e94\u6162&#xff0c;\u50cf Siri&#034;\u3002\u540e\u9762\u62c6\u89e3\u53d1\u73b0&#xff0c;850ms \u91cc\u53ea\u6709 ~200ms \u662f\u6a21\u578b\u672c\u8eab\u7684 inference&#xff0c;\u5269\u4e0b\u90fd\u662f\u5de5\u7a0b\u94fe\u8def\u635f\u8017\u3002\u8fd9\u7bc7\u5c31\u628a\u94fe\u8def\u91cc\u80fd\u780d\u7684\u90e8\u5206\u6328\u4e2a\u62c6\u4e00\u904d\u3002<\/p>\n<p>\u4e8c\u3001\u94fe\u8def\u5206\u89e3&#xff1a;800ms \u5230\u5e95\u82b1\u5728\u54ea\u91cc<br \/>\n\u63a5\u5165 OpenTelemetry trace \u4e4b\u540e&#xff0c;\u5355\u6b21\u8bf7\u6c42\u7684\u8017\u65f6\u5206\u5e03\u5927\u81f4\u662f&#xff1a;<\/p>\n<p>[Client]&#8212;-DNS\u89e3\u6790&#8212;-[CDN]&#8212;-TLS\u63e1\u624b&#8212;-[API\u7f51\u5173]&#8212;-\u6392\u961f&#8212;-[\u6a21\u578b]<br \/>\n\u00a0 \u00a030ms \u00a0 \u00a0 \u00a0 80ms \u00a0 \u00a0 \u00a0 \u00a0 120ms \u00a0 \u00a0 \u00a0 \u00a050ms \u00a0 \u00a0 \u00a0 20ms \u00a0 \u00a0 \u00a0~200ms<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2193<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u9996 token \u8fd4\u56de<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2193<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 [\u6d41\u5f0f chunks \u4e00\u4e2a\u4e2a\u56de\u6765]<br \/>\n\u5408\u8ba1 500ms \u7f51\u7edc &#043; 200ms \u6a21\u578b &#043; ~100ms \u5ba2\u6237\u7aef buffer &#061; 800ms \u8d77\u3002<\/p>\n<p>\u53ef\u780d\u7684\u90e8\u5206&#xff1a;<\/p>\n<p>DNS \/ TLS \/ \u8fde\u63a5\u5efa\u7acb \u2192 \u5171 230ms&#xff08;\u5360\u6bd4 28%&#xff09;<br \/>\nAPI \u7f51\u5173\u6392\u961f \u2192 50ms&#xff08;\u5360\u6bd4 6%&#xff09;<br \/>\n\u5ba2\u6237\u7aef buffer \u2192 100ms&#xff08;\u5360\u6bd4 12%&#xff09;<br \/>\n\u6a21\u578b inference \u90a3 200ms \u6211\u4eec\u6539\u4e0d\u4e86&#xff08;\u9664\u975e\u6362\u6a21\u578b&#xff09;&#xff0c;\u4f46\u524d\u540e\u63a5\u8fd1 400ms \u662f\u5de5\u7a0b\u53ef\u4f18\u5316\u7684\u3002<\/p>\n<p>\u4e09\u3001\u56db\u4e2a\u4f18\u5316\u70b9\u7684\u5177\u4f53\u5b9e\u73b0<br \/>\n3.1 \u957f\u8fde\u63a5\u590d\u7528&#xff08;HTTP\/2 &#043; keep-alive&#xff09;<br \/>\nOpenAI Python SDK \u9ed8\u8ba4 httpx.Client()&#xff0c;\u6bcf\u6b21\u8bf7\u6c42\u7406\u8bba\u4e0a\u4f1a\u590d\u7528\u8fde\u63a5&#xff0c;\u4f46\u5f88\u591a\u4eba\u5728 FastAPI \u91cc\u5199\u6210&#xff1a;<\/p>\n<p>&#064;app.post(&#034;\/chat&#034;)<br \/>\nasync def chat(req: ChatReq):<br \/>\n\u00a0 \u00a0 client &#061; OpenAI() \u00a0# \u274c \u6bcf\u6b21\u65b0\u5efa<br \/>\n\u00a0 \u00a0 return client.chat.completions.create(&#8230;)<br \/>\n\u6bcf\u6b21\u65b0\u5efa client \u610f\u5473\u7740\u6bcf\u6b21\u91cd\u65b0 TLS\u3002\u6539\u6210\u6a21\u5757\u7ea7 singleton&#xff1a;<\/p>\n<p>from openai import AsyncOpenAI<\/p>\n<p>_client &#061; AsyncOpenAI(<br \/>\n\u00a0 \u00a0 timeout&#061;httpx.Timeout(30.0, connect&#061;2.0),<br \/>\n\u00a0 \u00a0 max_retries&#061;0, \u00a0# \u6d41\u5f0f\u573a\u666f\u7981\u7528\u91cd\u8bd5&#xff0c;\u91cd\u8bd5\u4f1a\u53cc\u500d\u5ef6\u8fdf<br \/>\n\u00a0 \u00a0 http_client&#061;httpx.AsyncClient(<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 limits&#061;httpx.Limits(max_keepalive_connections&#061;20, max_connections&#061;50),<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 http2&#061;True,<br \/>\n\u00a0 \u00a0 ),<br \/>\n)<br \/>\n\u5b9e\u6d4b&#xff1a;\u7b2c 2 \u6b21\u8d77 TTFT \u51cf\u5c11\u7ea6 130ms\u3002<\/p>\n<p>3.2 Prompt \u9884\u70ed\u4e0e KV cache \u547d\u4e2d<br \/>\ngpt-4o-mini \u542f\u7528 prompt caching \u540e&#xff0c;\u91cd\u590d\u7684 system prompt &#043; few-shot \u793a\u4f8b\u7b2c\u4e00\u6b21\u540e\u4f1a\u8fdb cache&#xff0c;\u547d\u4e2d\u80fd\u7701\u7ea6 50ms \u7684 prefill\u3002<\/p>\n<p>\u8981\u8ba9 cache \u547d\u4e2d&#xff0c;system prompt \u5fc5\u987b\u524d\u7f00\u7a33\u5b9a\u3002\u6211\u4eec\u628a\u53d8\u5316\u90e8\u5206&#xff08;\u7528\u6237\u7b80\u5386\u3001\u5f53\u524d\u8f6e\u4e0a\u4e0b\u6587&#xff09;\u653e\u6700\u540e&#xff1a;<\/p>\n<p>messages &#061; [<br \/>\n\u00a0 \u00a0 {&#034;role&#034;: &#034;system&#034;, &#034;content&#034;: SYSTEM_PROMPT_FIXED}, \u00a0# \u524d\u7f00\u7a33\u5b9a<br \/>\n\u00a0 \u00a0 {&#034;role&#034;: &#034;system&#034;, &#034;content&#034;: FEWSHOT_EXAMPLES}, \u00a0 \u00a0 # \u4e5f\u7a33\u5b9a<br \/>\n\u00a0 \u00a0 {&#034;role&#034;: &#034;user&#034;, &#034;content&#034;: resume_summary}, \u00a0 \u00a0 \u00a0 \u00a0 \u00a0# \u534a\u7a33\u5b9a&#xff08;\u540c\u4e00\u9762\u8bd5 session \u4e0d\u53d8&#xff09;<br \/>\n\u00a0 \u00a0 {&#034;role&#034;: &#034;user&#034;, &#034;content&#034;: current_question}, \u00a0 \u00a0 \u00a0 \u00a0# \u53d8\u5316<br \/>\n]<br \/>\ncache TTL \u5927\u7ea6 5-10 \u5206\u949f&#xff0c;\u6240\u4ee5\u9762\u8bd5\u4e2d\u6bcf\u9694 4 \u5206\u949f\u6211\u4eec\u4f1a\u53d1\u4e00\u4e2a keep-alive \u7684\u6700\u5c0f\u8bf7\u6c42\u4fdd\u6d3b cache\u3002<\/p>\n<p>3.3 \u6295\u673a\u5f0f\u9884\u53d1\u8bf7\u6c42&#xff08;Speculative Pre-fetch&#xff09;<br \/>\n\u6700\u53cd\u76f4\u89c9\u4f46\u6536\u76ca\u6700\u5927\u7684\u4e00\u4e2a\u3002<\/p>\n<p>\u89c2\u5bdf&#xff1a;\u7528\u6237\u8bb2\u5b8c\u4e00\u6bb5\u8bdd&#xff0c;ASR partial \u5728\u6700\u540e 400ms \u901a\u5e38\u5df2\u7ecf\u57fa\u672c\u7a33\u5b9a&#xff08;\u6700\u540e\u53ea\u662f\u8865\u6807\u70b9\u548c\u786e\u8ba4\u8bcd&#xff09;\u3002\u6211\u4eec\u4e0d\u7b49 ASR finalize&#xff0c;\u800c\u662f\u5728 partial \u6587\u672c\u6ee1\u8db3\u4e0b\u9762\u4efb\u4e00\u6761\u4ef6\u65f6\u5148\u53d1\u4e00\u4efd&#034;\u8349\u7a3f&#034;\u8bf7\u6c42&#xff1a;<\/p>\n<p>\u53e5\u672b\u51fa\u73b0\u660e\u663e\u7ed3\u675f\u8bcd&#xff08;&#034;\u5bf9\u5427&#034;\u3001&#034;\u662f\u8fd9\u6837&#034;\u3001&#034;\u55ef&#034;&#xff09;<br \/>\n\u9759\u97f3\u8d85\u8fc7 250ms<br \/>\npartial \u6587\u672c\u957f\u5ea6 &gt; 30 \u5b57\u4e14\u542b\u95ee\u53f7<br \/>\nasync def speculative_call(partial_text: str):<br \/>\n\u00a0 \u00a0 # \u63d0\u524d\u53d1\u8d77&#xff0c;\u4f46\u4e0d\u7acb\u5373\u8fd4\u56de\u7ed9\u7528\u6237<br \/>\n\u00a0 \u00a0 task &#061; asyncio.create_task(<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 _client.chat.completions.create(<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 model&#061;&#034;gpt-4o-mini&#034;,<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 messages&#061;build_messages(partial_text),<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 stream&#061;True,<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 )<br \/>\n\u00a0 \u00a0 )<br \/>\n\u00a0 \u00a0 return task<\/p>\n<p>async def on_asr_final(final_text: str, spec_task):<br \/>\n\u00a0 \u00a0 # \u6bd4\u5bf9 final \u548c partial \u5dee\u5f02<br \/>\n\u00a0 \u00a0 if text_similarity(final_text, spec_task.partial) &gt; 0.92:<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 # \u76f4\u63a5\u7528\u9884\u53d1\u7684\u7ed3\u679c<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 async for chunk in await spec_task:<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 yield chunk<br \/>\n\u00a0 \u00a0 else:<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 # \u5dee\u5f02\u5927&#xff0c;\u4e22\u5f03\u91cd\u53d1<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 spec_task.cancel()<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 async for chunk in real_call(final_text):<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 yield chunk<br \/>\n\u547d\u4e2d\u7387\u7ea6 70%&#xff0c;\u547d\u4e2d\u65f6 TTFT \u7b49\u4e8e 0&#xff08;\u5df2\u7ecf\u5728\u8def\u4e0a\u4e86&#xff09;\u300225% \u6d6a\u8d39\u7684\u8bf7\u6c42\u662f\u6210\u672c\u4ee3\u4ef7&#xff0c;\u5bf9\u5b9e\u65f6\u573a\u666f\u503c\u5f97\u3002<\/p>\n<p>3.4 \u6d41\u5f0f UI&#xff1a;\u5355 token \u4e5f\u8981 flush<br \/>\n\u5f88\u591a SSE \/ WebSocket \u4e2d\u8f6c\u5c42\u4f1a\u81ea\u5e26 buffer&#xff08;nginx \u9ed8\u8ba4 buffer 8KB&#xff0c;\u610f\u5473\u7740\u524d\u51e0\u5341\u4e2a\u5b57\u7b26\u6839\u672c\u4e0d\u4f1a\u51fa\u53bb&#xff09;\u3002<\/p>\n<p>\u540e\u7aef&#xff1a;<\/p>\n<p>async for chunk in stream:<br \/>\n\u00a0 \u00a0 delta &#061; chunk.choices[0].delta.content or &#034;&#034;<br \/>\n\u00a0 \u00a0 yield f&#034;data: {json.dumps({&#039;t&#039;: delta})}\\\\n\\\\n&#034;<br \/>\n\u7f51\u5173\u4fa7\u52a1\u5fc5\u5173 buffer&#xff1a;<\/p>\n<p>location \/stream {<br \/>\n\u00a0 \u00a0 proxy_buffering off;<br \/>\n\u00a0 \u00a0 proxy_cache off;<br \/>\n\u00a0 \u00a0 proxy_set_header X-Accel-Buffering no;<br \/>\n\u00a0 \u00a0 chunked_transfer_encoding on;<br \/>\n}<br \/>\n\u4e0d\u5173 buffer \u7684\u8bdd&#xff0c;\u540e\u7aef\u6bcf\u4e2a token \u90fd\u5410\u4e86&#xff0c;\u7528\u6237\u4f9d\u7136\u8981\u7b49\u51e0\u767e\u6beb\u79d2\u770b\u5230\u7b2c\u4e00\u5b57\u3002<\/p>\n<p>\u56db\u3001\u8e29\u8fc7\u7684\u5751<br \/>\nHTTP\/2 \u591a\u8def\u590d\u7528\u53cd\u800c\u53d8\u6162&#xff1a;\u5728\u56fd\u5185\u4e2d\u8f6c\u8282\u70b9&#xff0c;HTTP\/2 \u5355\u8fde\u63a5\u6240\u6709\u8bf7\u6c42\u590d\u7528&#xff0c;\u9047\u5230\u4e00\u4e2a\u6162\u8bf7\u6c42\u4f1a head-of-line blocking\u3002\u6539\u56de HTTP\/1.1 &#043; \u957f\u8fde\u63a5\u6c60\u540e\u7a33\u5b9a\u4e86\u3002<br \/>\nSDK retry \u9ed8\u8ba4\u5f00&#xff1a;\u6d41\u5f0f\u5931\u8d25 retry \u4f1a\u8ba9\u7528\u6237\u7b49 2 \u500d\u65f6\u95f4\u3002\u6d41\u5f0f\u573a\u666f\u5fc5\u987b max_retries&#061;0&#xff0c;\u5931\u8d25\u76f4\u63a5\u62a5\u9519\u8ba9\u524d\u7aef\u91cd\u8fde\u3002<br \/>\ntimeout \u4e0d\u80fd\u592a\u5c0f&#xff1a;connect&#061;2.0 \u662f\u5e95\u7ebf&#xff0c;\u7ed9 TLS \u7559\u4f59\u5730&#xff1b;\u603b timeout 30.0 \u4e0d\u8981\u5199\u6210 5.0&#xff0c;\u957f\u7b54\u6848\u4f1a\u88ab\u622a\u65ad\u3002<\/p>\n<p>https:\/\/www.iqiyi.com\/v_bl8behf45k.html<br \/>\nhttps:\/\/www.iqiyi.com\/v_28bt8r51pls.html<br \/>\nhttps:\/\/www.iqiyi.com\/v_t7p5u3vybw.html<br \/>\nhttps:\/\/www.iqiyi.com\/v_1czidpq8i98.html<br \/>\n\u6295\u673a\u5f0f\u8bf7\u6c42\u8d26\u5355\u66b4\u6da8&#xff1a;\u5b9e\u6d4b input tokens \u7528\u91cf &#043;35%\u3002\u5efa\u8bae\u7ed9 spec_call \u52a0\u4e2a\u5f00\u5173&#xff0c;\u4ec5\u5728\u4f4e\u5ef6\u8fdf\u6a21\u5f0f\u542f\u7528\u3002<br \/>\n\u5e38\u89c1\u95ee\u9898<br \/>\nQ1: \u4e3a\u4ec0\u4e48\u4e0d\u76f4\u63a5\u6362\u66f4\u5feb\u7684\u5c0f\u6a21\u578b&#xff1f;<br \/>\nA: \u8bd5\u8fc7 gpt-4o-mini \u2192 claude-3-haiku \u2192 \u963f\u91cc qwen-turbo&#xff0c;TTFT \u4e0a haiku \u7565\u5feb\u4f46\u9996\u5b57\u7b26\u4e4b\u540e\u7684\u5410\u5b57\u901f\u5ea6\u53cd\u800c\u6162&#xff0c;\u6574\u4f53 perceived latency \u6ca1\u6539\u5584\u3002\u74f6\u9888\u4e0d\u5728\u6a21\u578b\u89c4\u6a21\u800c\u5728\u5de5\u7a0b\u94fe\u8def\u3002<\/p>\n<p>Q2: \u6295\u673a\u5f0f\u8bf7\u6c42 30% \u7684\u6d6a\u8d39\u6210\u672c\u80fd\u63a5\u53d7\u5417&#xff1f;<br \/>\nA: \u6211\u4eec\u7b97\u8fc7&#xff1a;gpt-4o-mini input 0.15 \u7f8e\u5143\/1M token&#xff0c;\u5355\u6b21\u9762\u8bd5 session ~5K input token&#xff0c;\u6d6a\u8d39 30% \u5373\u591a\u82b1 ~0.0002 \u7f8e\u5143\/session&#xff0c;\u76f8\u5bf9\u6536\u76ca&#xff08;\u7528\u6237\u4f53\u9a8c\u3001\u7eed\u8d39\u7387&#xff09;\u5212\u7b97\u3002\u5176\u4ed6\u9ad8\u5355\u4ef7\u6a21\u578b\u4e0d\u5efa\u8bae\u8fd9\u4e48\u505a\u3002<\/p>\n<p>Q3: prompt caching \u5728\u56fd\u5185 API \u4e2d\u8f6c\u80fd\u7528\u5417&#xff1f;<br \/>\nA: OpenAI \u5b98\u65b9 endpoint \u662f\u652f\u6301\u7684&#xff0c;\u56fd\u5185\u4e2d\u8f6c\u770b\u5177\u4f53\u670d\u52a1\u5546\u662f\u5426\u900f\u4f20 prompt_cache_key \u5b57\u6bb5\u3002Azure OpenAI \u9ed8\u8ba4\u652f\u6301\u3002<\/p>\n<p>Q4: \u6d41\u5f0f\u54cd\u5e94\u88ab\u4e2d\u95f4\u7f51\u5173\u62e6\u622a\u4e86\u600e\u4e48\u529e&#xff1f;<br \/>\nA: \u68c0\u67e5 nginx \/ cloudflare \/ \u963f\u91cc\u4e91 SLB \u7684 buffer \u8bbe\u7f6e&#xff1b;\u5982\u679c\u662f cloudflare&#xff0c;\u5f00 &#034;Streaming&#034; \u6a21\u5f0f\u6216\u7528 WebSocket \u66ff\u4ee3 SSE\u3002<\/p>\n<p>Q5: \u6295\u673a\u5f0f\u8bf7\u6c42\u4f1a\u4e0d\u4f1a\u5bfc\u81f4\u56de\u7b54\u5185\u5bb9\u8dd1\u504f&#xff1f;<br \/>\nA: \u4f1a\u3002\u8fd9\u662f\u4e3a\u4ec0\u4e48\u9700\u8981 text_similarity &gt; 0.92 \u7684\u76f8\u4f3c\u5ea6\u95e8\u69db\u3002\u4f4e\u4e8e\u95e8\u69db\u76f4\u63a5 cancel \u91cd\u53d1&#xff0c;\u5b81\u53ef\u591a\u82b1\u4e00\u6b21\u8bf7\u6c42&#xff0c;\u4e0d\u80fd\u8ba9\u7528\u6237\u770b\u5230\u9519\u8bef\u56de\u7b54\u3002<br \/>\n\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>TL;DR&#xff08;\u5148\u770b\u7ed3\u8bba&#xff09;<br \/>\n\u5b9e\u65f6\u5bf9\u8bdd\u573a\u666f\u4e0b\u9996\u5b57\u7b26\u5ef6\u8fdf&#xff08;TTFB \/ TTFT&#xff09;\u7684 4 \u4e2a\u5de5\u7a0b\u4f18\u5316\u70b9&#xff1a;\u8fde\u63a5\u590d\u7528&#xff1a;HTTPS \u63e1\u624b  TLS \u534f\u5546\u5360 ~150ms&#xff0c;\u5168\u7a0b\u957f\u8fde\u63a5 keep-alive \u53ef\u7701 100ms<br \/>\nPrompt \u9884\u70ed&#xff1a;\u628a\u56fa\u5b9a system prompt \u63d0\u524d 1-2s \u53d1\u8d77 streaming \u8bf7\u6c42&#xff0c;\u8ba9 KV cache \u547d\u4e2d<br \/>\nToken \u9884<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[50],"topic":[],"class_list":["post-89436","post","type-post","status-publish","format-standard","hentry","category-server","tag-50"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>AI \u5b9e\u65f6\u63a8\u7406\u6d41\u5f0f\u9884\u70ed\u5b9e\u6218\uff1a\u9996\u5b57\u7b26\u5ef6\u8fdf\u4ece 800ms \u780d\u5230 200ms - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/89436.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"AI \u5b9e\u65f6\u63a8\u7406\u6d41\u5f0f\u9884\u70ed\u5b9e\u6218\uff1a\u9996\u5b57\u7b26\u5ef6\u8fdf\u4ece 800ms \u780d\u5230 200ms - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"TL;DR&#xff08;\u5148\u770b\u7ed3\u8bba&#xff09; \u5b9e\u65f6\u5bf9\u8bdd\u573a\u666f\u4e0b\u9996\u5b57\u7b26\u5ef6\u8fdf&#xff08;TTFB \/ TTFT&#xff09;\u7684 4 \u4e2a\u5de5\u7a0b\u4f18\u5316\u70b9&#xff1a;\u8fde\u63a5\u590d\u7528&#xff1a;HTTPS \u63e1\u624b TLS \u534f\u5546\u5360 ~150ms&#xff0c;\u5168\u7a0b\u957f\u8fde\u63a5 keep-alive \u53ef\u7701 100ms Prompt \u9884\u70ed&#xff1a;\u628a\u56fa\u5b9a system prompt \u63d0\u524d 1-2s \u53d1\u8d77 streaming \u8bf7\u6c42&#xff0c;\u8ba9 KV cache \u547d\u4e2d Token \u9884\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/89436.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-02T17:56:44+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/89436.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/89436.html\",\"name\":\"AI \u5b9e\u65f6\u63a8\u7406\u6d41\u5f0f\u9884\u70ed\u5b9e\u6218\uff1a\u9996\u5b57\u7b26\u5ef6\u8fdf\u4ece 800ms \u780d\u5230 200ms - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-02T17:56:44+00:00\",\"dateModified\":\"2026-08-02T17:56:44+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/89436.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/89436.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/89436.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"AI \u5b9e\u65f6\u63a8\u7406\u6d41\u5f0f\u9884\u70ed\u5b9e\u6218\uff1a\u9996\u5b57\u7b26\u5ef6\u8fdf\u4ece 800ms \u780d\u5230 200ms\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"AI \u5b9e\u65f6\u63a8\u7406\u6d41\u5f0f\u9884\u70ed\u5b9e\u6218\uff1a\u9996\u5b57\u7b26\u5ef6\u8fdf\u4ece 800ms \u780d\u5230 200ms - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/89436.html","og_locale":"zh_CN","og_type":"article","og_title":"AI \u5b9e\u65f6\u63a8\u7406\u6d41\u5f0f\u9884\u70ed\u5b9e\u6218\uff1a\u9996\u5b57\u7b26\u5ef6\u8fdf\u4ece 800ms \u780d\u5230 200ms - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"TL;DR&#xff08;\u5148\u770b\u7ed3\u8bba&#xff09; \u5b9e\u65f6\u5bf9\u8bdd\u573a\u666f\u4e0b\u9996\u5b57\u7b26\u5ef6\u8fdf&#xff08;TTFB \/ TTFT&#xff09;\u7684 4 \u4e2a\u5de5\u7a0b\u4f18\u5316\u70b9&#xff1a;\u8fde\u63a5\u590d\u7528&#xff1a;HTTPS \u63e1\u624b TLS \u534f\u5546\u5360 ~150ms&#xff0c;\u5168\u7a0b\u957f\u8fde\u63a5 keep-alive \u53ef\u7701 100ms Prompt \u9884\u70ed&#xff1a;\u628a\u56fa\u5b9a system prompt \u63d0\u524d 1-2s \u53d1\u8d77 streaming \u8bf7\u6c42&#xff0c;\u8ba9 KV cache \u547d\u4e2d Token \u9884","og_url":"https:\/\/www.wsisp.com\/helps\/89436.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-02T17:56:44+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/89436.html","url":"https:\/\/www.wsisp.com\/helps\/89436.html","name":"AI \u5b9e\u65f6\u63a8\u7406\u6d41\u5f0f\u9884\u70ed\u5b9e\u6218\uff1a\u9996\u5b57\u7b26\u5ef6\u8fdf\u4ece 800ms \u780d\u5230 200ms - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-02T17:56:44+00:00","dateModified":"2026-08-02T17:56:44+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/89436.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/89436.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/89436.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"AI \u5b9e\u65f6\u63a8\u7406\u6d41\u5f0f\u9884\u70ed\u5b9e\u6218\uff1a\u9996\u5b57\u7b26\u5ef6\u8fdf\u4ece 800ms \u780d\u5230 200ms"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/89436","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=89436"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/89436\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=89436"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=89436"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=89436"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=89436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}