perf(gpu): mezzanine relay直传跳过公网OSS(-18s), preset veryfast(-38%), 修复CI staging IP #2063

Merged
auto-approve-bot merged 5 commits from fix/gpu-mezzanine-relay-transport into develop 2026-09-27 14:48:55 +08:00
Owner

核心优化

1. GPU mezzanine relay 直传(短视频GPU真正快起来的关键)

旧流程(慢):CPU ultrafast → 上传公网OSS → P4000下载 → nvenc → relay回传 → worker下载
新流程(快):CPU ultrafast → PUT到relay(:8092 Tailscale内网,~1s) → P4000从relay GET → nvenc → relay回传 → worker下载

跳过公网OSS上传+下载两次往返,节省18-20s固定延迟。relay上传失败自动fallback到OSS。

  • apps/api/app/api/routes/gpu_relay.py:新增 /mezzanine/{key} 4个接口(PUT/GET/HEAD/DELETE),复用token鉴权,原子写入
  • packages/shared/gpu_encoder.py:新增 _upload_file_put() 通过HTTP PUT上传mezzanine到relay;默认transport=relay,失败fallback到OSS
  • packages/config/base.py:新增 GPU_ENCODE_MEZZANINE_TRANSPORT (relay|oss),默认relay

2. CPU编码preset fast→veryfast

  • 实测4核Xeon 60s 720p: 31.7s(1.89x) → 19.5s(3.07x),~38%提速,CRF=23画质损失可接受
  • 修改 packages/shared/ffmpeg_utils.py 默认值

3. 修复CI staging部署打偏

  • 真实staging机是116.62.226.203(DNS解析指向,Watchtower部署),SSH端口22
  • 之前#2057误改成47.98.113.167:22222(实际是prod机),导致CI部署到错误机器
  • 恢复 .gitea/workflows/ci-pipeline.yml 和 scripts/ci_staging_healthcheck.sh 默认值

Benchmark(staging 4vCPU Xeon Platinum, 60s 1280x720, CRF=23)

preset rtime speed
fast(旧) 31.7s 1.89x
veryfast(新) 19.5s 3.07x
GPU路径(relay,预估) ~15-18s 3.3-4x

风险

  • relay mezzanine接口用与result相同的token鉴权+随机hex key,安全模型一致
  • relay上传失败自动fallback到OSS,不会导致GPU路径完全不可用
  • CI SSH IP/端口修正只改默认值,secrets覆盖的场景不受影响
## 核心优化 ### 1. GPU mezzanine relay 直传(短视频GPU真正快起来的关键) **旧流程(慢)**:CPU ultrafast → 上传公网OSS → P4000下载 → nvenc → relay回传 → worker下载 **新流程(快)**:CPU ultrafast → PUT到relay(:8092 Tailscale内网,~1s) → P4000从relay GET → nvenc → relay回传 → worker下载 跳过公网OSS上传+下载两次往返,节省18-20s固定延迟。relay上传失败自动fallback到OSS。 - `apps/api/app/api/routes/gpu_relay.py`:新增 `/mezzanine/{key}` 4个接口(PUT/GET/HEAD/DELETE),复用token鉴权,原子写入 - `packages/shared/gpu_encoder.py`:新增 `_upload_file_put()` 通过HTTP PUT上传mezzanine到relay;默认transport=relay,失败fallback到OSS - `packages/config/base.py`:新增 `GPU_ENCODE_MEZZANINE_TRANSPORT` (relay|oss),默认relay ### 2. CPU编码preset fast→veryfast - 实测4核Xeon 60s 720p: 31.7s(1.89x) → 19.5s(3.07x),~38%提速,CRF=23画质损失可接受 - 修改 `packages/shared/ffmpeg_utils.py` 默认值 ### 3. 修复CI staging部署打偏 - 真实staging机是116.62.226.203(DNS解析指向,Watchtower部署),SSH端口22 - 之前#2057误改成47.98.113.167:22222(实际是prod机),导致CI部署到错误机器 - 恢复 `.gitea/workflows/ci-pipeline.yml` 和 `scripts/ci_staging_healthcheck.sh` 默认值 ## Benchmark(staging 4vCPU Xeon Platinum, 60s 1280x720, CRF=23) | preset | rtime | speed | |---|---|---| | fast(旧) | 31.7s | 1.89x | | veryfast(新) | 19.5s | 3.07x | | GPU路径(relay,预估) | ~15-18s | 3.3-4x | ## 风险 - relay mezzanine接口用与result相同的token鉴权+随机hex key,安全模型一致 - relay上传失败自动fallback到OSS,不会导致GPU路径完全不可用 - CI SSH IP/端口修正只改默认值,secrets覆盖的场景不受影响

🚀 预览环境已部署

项目 详情
PR号 #2063
预览链接 https://pr-2063.preview.xiaoxiajianji.com
API环境 staging

💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。

🔄 每次提交新代码后预览环境会自动更新。

🗑️ PR 关闭或合并后,预览环境会自动清理。

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #2063 | | 预览链接 | [https://pr-2063.preview.xiaoxiajianji.com](https://pr-2063.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
xiaoxia added 1 commit 2026-09-27 14:14:59 +08:00
perf(gpu): mezzanine relay直传跳过公网OSS,CPU preset veryfast,修复CI staging SSH目标
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2s
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 3s
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 52s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 56s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m31s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 2m16s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 2m27s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m16s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 5m46s
AI Code Review / AI Code Review (pull_request) Successful in 6m51s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 8m33s
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Style (pull_request) Has been cancelled
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been cancelled
4416400f16
## GPU mezzanine relay直传(核心优化)
- 新增 relay /mezzanine/{key} 接口(PUT/GET/HEAD/DELETE),复用token鉴权
- gpu_encoder 默认走 relay PUT 上传 mezzanine(Tailscale/Docker内网,~1s完成)
- relay上传失败自动fallback到公网OSS,兼容未配Tailscale的环境
- P4000 从 relay_base_url(:8092) GET mezzanine,跳过OSS下载
- 节省公网OSS上传+下载18-20s固定延迟,短视频(1min)GPU路径终于比CPU快
- 新增 GPU_ENCODE_MEZZANINE_TRANSPORT 配置(relay|oss),默认relay

## CPU编码preset
- FFMPEG_ENCODE_PRESET 默认 fast→veryfast,60s720p CPU编码32s→20s(~38%提速)

## CI staging部署修复
- STAGING_SSH_HOST 默认值恢复为 116.62.226.203(真实staging机,DNS指向的机器)
- STAGING_SSH_PORT 默认值 22222→22
- scripts/ci_staging_healthcheck.sh 同步更新
- 注:47.98.113.167 是prod机,之前误设为staging目标导致部署打偏
xiaoxia force-pushed fix/gpu-mezzanine-relay-transport from e34598aab0 to 4416400f16 2026-09-27 14:14:59 +08:00 Compare
xiaoxia added 1 commit 2026-09-27 14:31:13 +08:00
test(tests/unit/test_gpu_encoder.py): adapt to veryfast preset + gpu mezzanine relay refactor
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 2s
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / Frontend Lint (pull_request) Has been cancelled
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / PR Build API Image (pull_request) Has been cancelled
CI/CD Pipeline / PR Build Web Image (pull_request) Has been cancelled
CI/CD Pipeline / PR Build Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been cancelled
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been cancelled
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been cancelled
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Style (pull_request) Has been cancelled
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2s
AI Code Review / AI Code Review (pull_request) Has been cancelled
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been cancelled
PR Automation / Auto Approve on CI Green (pull_request) Has been cancelled
Preview Deploy / Deploy Preview Environment (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Security (pull_request) Failing after 22s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Failing after 4m39s
b81f5155cf
xiaoxia added 1 commit 2026-09-27 14:31:16 +08:00
test(tests/unit/test_ffmpeg_encoding_optimization.py): adapt to veryfast preset + gpu mezzanine relay refactor
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Has been cancelled
CI/CD Pipeline / Check if frontend-only change (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Style (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Security (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Has been cancelled
CI/CD Pipeline / Unit Tests (pull_request) Blocked by required conditions
CI/CD Pipeline / Integration Tests (pull_request) Blocked by required conditions
CI/CD Pipeline / Frontend Lint (pull_request) Blocked by required conditions
CI/CD Pipeline / Frontend Unit Tests (pull_request) Blocked by required conditions
CI/CD Pipeline / PR Build API Image (pull_request) Blocked by required conditions
CI/CD Pipeline / PR Build Web Image (pull_request) Blocked by required conditions
CI/CD Pipeline / PR Build Worker Image (pull_request) Blocked by required conditions
CI/CD Pipeline / Check push changed paths (pull_request) Waiting to run
CI/CD Pipeline / Build Staging API Image (pull_request) Blocked by required conditions
CI/CD Pipeline / Build Staging Web Image (pull_request) Blocked by required conditions
CI/CD Pipeline / Build Staging Worker Image (pull_request) Blocked by required conditions
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Blocked by required conditions
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Blocked by required conditions
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Blocked by required conditions
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Blocked by required conditions
CI/CD Pipeline / Staging E2E Tests (pull_request) Blocked by required conditions
CI/CD Pipeline / Staging API Integration Tests (pull_request) Blocked by required conditions
CI/CD Pipeline / Build Production API Image (pull_request) Blocked by required conditions
CI/CD Pipeline / Build Production Web Image (pull_request) Blocked by required conditions
CI/CD Pipeline / Build Production Worker Image (pull_request) Blocked by required conditions
CI/CD Pipeline / Deploy Production (pull_request) Blocked by required conditions
CI/CD Pipeline / Production Browser E2E (pull_request) Blocked by required conditions
CI/CD Pipeline / ACR Image Cleanup (pull_request) Blocked by required conditions
CI/CD Pipeline / Canary Release to Production (pull_request) Blocked by required conditions
CI/CD Pipeline / CI Gate (pull_request) Blocked by required conditions
PR Automation / Auto Approve on CI Green (pull_request) Has been cancelled
PR Automation / Auto Merge on CI Green + Approved (pull_request) Blocked by required conditions
Preview Deploy / Deploy Preview Environment (pull_request) Has been cancelled
AI Code Review / AI Code Review (pull_request) Has been cancelled
d13ee7991b
xiaoxia added 1 commit 2026-09-27 14:31:18 +08:00
test(tests/unit/test_1280_preview_speedup.py): adapt to veryfast preset + gpu mezzanine relay refactor
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 2s
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 3s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 46s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 2m1s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 2m12s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 2m44s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m11s
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Style (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Security (pull_request) Has been cancelled
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
AI Code Review / AI Code Review (pull_request) Has been cancelled
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been cancelled
Preview Deploy / Deploy Preview Environment (pull_request) Has been cancelled
dc10f32124
auto-approve-bot added 1 commit 2026-09-27 14:34:53 +08:00
style: auto-format with black + isort + ruff + prettier [skip ci-format-check]
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 3s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 52s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 56s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m22s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 2m10s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 2m18s
CI/CD Pipeline / Validate - Style (pull_request) Successful in 2m36s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m11s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 5m12s
AI Code Review / AI Code Review (pull_request) Successful in 6m49s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 13m15s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Successful in 2s
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 10m41s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 33s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 35s
5e045a14f6
auto-approve-bot merged commit e4723bfb1b into develop 2026-09-27 14:48:55 +08:00
auto-approve-bot deleted branch fix/gpu-mezzanine-relay-transport 2026-09-27 14:48:57 +08:00

🗑️ 预览环境已清理

PR #2063 已关闭或合并,对应的预览环境已被清理。

如有需要,可以重新打开 PR 来重新生成预览环境。

🗑️ **预览环境已清理** PR #2063 已关闭或合并,对应的预览环境已被清理。 > 如有需要,可以重新打开 PR 来重新生成预览环境。
Sign in to join this conversation.