From ac87ca8126461d53d46ac1fb1e65e4294fe1814b Mon Sep 17 00:00:00 2001 From: zcr Date: Tue, 31 Mar 2026 18:27:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0canvas=203d=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=20,=E4=BD=BF=E7=94=A8=E5=BC=82=E6=AD=A5mq=E9=98=9F=E5=88=97?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gunicorn.conf.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 gunicorn.conf.py diff --git a/gunicorn.conf.py b/gunicorn.conf.py new file mode 100644 index 0000000..dbf2b32 --- /dev/null +++ b/gunicorn.conf.py @@ -0,0 +1,23 @@ +import multiprocessing +import os + +# 基础配置 +bind = "0.0.0.0:80" +worker_class = "uvicorn.workers.UvicornWorker" +loglevel = "info" +accesslog = "-" +errorlog = "-" + +# 关键生产参数 +workers = 2 # 先用 2 个(ML 场景推荐 1~4,根据 CPU 核数和内存调整) +timeout = 300 # 5 分钟,足够模型加载和慢推理 +graceful_timeout = 300 +preload_app = True # ★★★ 必须加!模型只加载一次,内存大幅节省 + +# 防止内存泄漏(ML 服务常见问题) +max_requests = 1000 +max_requests_jitter = 100 + +# 其他优化 +keepalive = 5 +worker_connections = 1000 \ No newline at end of file