Files
KCGL/inventory-backend/gunicorn.conf.py

21 lines
646 B
Python
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.

# inventory-backend/gunicorn.conf.py
import multiprocessing
# 原来的写法:根据 CPU 自动算,容易在强机上算太多
# workers = multiprocessing.cpu_count() * 2 + 1
# --- 优化后的写法 ---
# 我们设置一个上限:如果是开发环境或为了省资源,最多不超过 8 个
# 这样既有并发能力8个分身足够开发测试用了又不会撑爆数据库
cpu_calc = multiprocessing.cpu_count() * 2 + 1
workers = min(cpu_calc, 8)
# 线程数保持不变
threads = 2
bind = "0.0.0.0:8000"
timeout = 120
loglevel = 'info'
accesslog = '-' # 输出到标准输出Docker logs 能看到)
errorlog = '-'