修复整站502(健康探针被慢请求饿死)+全部模特死链+图片并发限流

- 后端 gunicorn 加 --threads 4:纯 sync worker 下几张图就占满 3 worker,
  健康探针 /api/health/ 拿不到 worker→超时→pod 判不就绪→流量被掐→整站502。
  图片生成 I/O 密集,加线程后慢请求不再饿死探针/其他接口。
- 前端图片生成并发上限 2:每张仍独立短请求,但不再 N 条一起砸单 pod 致 OOM。
- ai-tools 全部模特→ 接成展开/收起全部模特(原为纯 span 死链,模特>6 时第7个起选不到)。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
zyc
2026-06-15 16:15:49 +08:00
co-authored by Claude Opus 4.8
parent 9c3e4e5c8b
commit 3472c3cc9c
3 changed files with 29 additions and 12 deletions
+5 -3
View File
@@ -32,6 +32,8 @@ RUN chmod +x /usr/local/bin/docker-entrypoint.sh
EXPOSE 8000
ENTRYPOINT ["docker-entrypoint.sh"]
# timeout 300:前端已把多图生成拆成「每张一条请求」,单张约 30s;300s 给慢 ARK 留充足余量,
# 不再因一条请求串行出多张而超时(旧 120s 下生成 4 张必被 worker 强杀 → 500)。
CMD ["gunicorn", "airshelf.wsgi:application", "--bind", "0.0.0.0:8000", "--workers", "3", "--timeout", "300"]
# timeout 300:图片生成是慢请求(等 ARK+传 TOS ~30s),300s 给慢 ARK 留充足余量。
# --threads 4:关键!纯 sync worker 下,几张图就能把 3 个 worker 占满,健康探针 /api/health/
# 拿不到 worker → 超时 → pod 被判不就绪 → 流量被掐 → 整站 502(表现:报错但后端在干活、刷新能看到图)。
# 图片生成是 I/O 密集(等 ARK/TOS 时线程让出 GIL),3 worker × 4 线程 = 12 并发,慢请求不再饿死探针。
CMD ["gunicorn", "airshelf.wsgi:application", "--bind", "0.0.0.0:8000", "--workers", "3", "--threads", "4", "--timeout", "300"]