perf: 添加 gunicorn --preload 参数优化内存占用

Worker 进程共享只读内存(代码、常量),可减少约 30-40% 内存占用

Closes #44
This commit is contained in:
fawney19
2025-12-24 01:47:37 +08:00
parent d73a443484
commit 75d7e89cbb
2 changed files with 2 additions and 2 deletions

View File

@@ -105,7 +105,7 @@ RUN printf '%s\n' \
'stderr_logfile=/var/log/nginx/error.log' \ 'stderr_logfile=/var/log/nginx/error.log' \
'' \ '' \
'[program:app]' \ '[program:app]' \
'command=gunicorn src.main:app -w %(ENV_GUNICORN_WORKERS)s -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:%(ENV_PORT)s --timeout 120 --access-logfile - --error-logfile - --log-level info' \ 'command=gunicorn src.main:app --preload -w %(ENV_GUNICORN_WORKERS)s -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:%(ENV_PORT)s --timeout 120 --access-logfile - --error-logfile - --log-level info' \
'directory=/app' \ 'directory=/app' \
'autostart=true' \ 'autostart=true' \
'autorestart=true' \ 'autorestart=true' \

View File

@@ -106,7 +106,7 @@ RUN printf '%s\n' \
'stderr_logfile=/var/log/nginx/error.log' \ 'stderr_logfile=/var/log/nginx/error.log' \
'' \ '' \
'[program:app]' \ '[program:app]' \
'command=gunicorn src.main:app -w %(ENV_GUNICORN_WORKERS)s -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:%(ENV_PORT)s --timeout 120 --access-logfile - --error-logfile - --log-level info' \ 'command=gunicorn src.main:app --preload -w %(ENV_GUNICORN_WORKERS)s -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:%(ENV_PORT)s --timeout 120 --access-logfile - --error-logfile - --log-level info' \
'directory=/app' \ 'directory=/app' \
'autostart=true' \ 'autostart=true' \
'autorestart=true' \ 'autorestart=true' \