Files
slide/decks/gen2D/pages/request-journey.md
T
wonder f0245e926d
Deploy Slides / build-and-deploy (push) Successful in 1m13s
feat: add 3 creative slides — tech decisions, request tracing, lessons learned
- why-not-x.md: Engineering decision rationale (Go vs Python, SQLite vs PG, etc.)
- request-journey.md: Full HTTP-to-pixel request tracing with timing breakdown
- lessons.md: 4 real engineering pitfalls and how they were solved
- Wire all 3 new pages into slides.md in logical positions
2026-05-30 22:46:23 +08:00

40 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 一次请求的完整旅程
从 HTTP 到像素 — 追踪一个生成请求的全链路
<div class="text-sm mt-2">
```
POST /api/v1/generate {prompt: "像素风骑士", assetType: "sprite", style: {artStyle: "pixel"}}
```
</div>
<v-clicks>
<Item title="① Middleware 层(~1ms)">
JWT 认证 → 解析 userID → 用户级限流检查(Redis Lua)→ 全局限流检查 → 放行
</Item>
<Item title="② Handler 层(~5ms)">
参数绑定 + 校验 → 去重检查 `hash(prompt+type+params)` → 创建 Task(DB 写入)→ 入队 TaskQueue → 返回 `taskId`
</Item>
<Item title="③ Pipeline 执行(~30s)">
goroutine 取出任务 → PromptOptimizer(风格合并 + LLM)→ AssetGenerator(文生图 API)→ QualitySupervisor(视觉模型质检,可能重试)→ FormatAdapter(精灵表拆分 + GIF)
</Item>
<Item title="④ 收尾(~2s)">
上传素材到七牛云 Kodo → 写入 Asset 表 → 更新 Task status=completed → WebSocket 推送完成通知
</Item>
</v-clicks>
<div v-click class="mt-2 text-center text-gray-400 text-sm">
全程异步:前端拿到 taskId 后通过 WebSocket 实时监听进度变化
</div>
<!--
这就是一个请求的完整生命周期。注意看耗时分布:管线占了 95% 的时间,这就是为什么要做异步。
-->