You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Gunicorn间歇性冻结求助:四台不同代码服务器同步故障

Gunicorn部署Django项目间歇性冻结故障排查求助

我用Gunicorn部署了Django项目,但Gunicorn会间歇性冻结,有时运行数天后出现,有时重启数小时内就会触发。奇怪的是,4台配置相同但运行不同代码的服务器会同时出现故障。

系统服务配置文件

Gunicorn Socket配置

[Unit]
Description=Gunicorn Socket

[Socket]
ListenStream=/run/gunicorn.sock

[Install]
WantedBy=sockets.target

Gunicorn Daemon配置

[Unit]
Description=Gunicorn Daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=root
Group=root
WorkingDirectory=/opt/app_repo
Restart=always
ExecStart=/opt/app_repo/venv/bin/gunicorn \
          --access-logfile /opt/app_repo/gunicorn.access.log \
          --error-logfile /opt/app_repo/gunicorn.error.log \
          --timeout 1000 \
          --workers 9 \
          --bind unix:/run/gunicorn.sock \
          --log-level DEBUG \
          --capture-output \
          app_repo.wsgi:application

[Install]
WantedBy=multi-user.target

故障确认命令及结果

$ systemctl status caddy # -> 运行正常,不带斜杠访问URL会返回Caddy重定向
$ systemctl status gunicorn # -> 同样运行正常
$ curl --unix-socket /run/gunicorn.sock http:// # 卡顿2-45分钟后恢复响应

版本信息

gunicorn==19.9.0
Django==2.2.3

已尝试的无效方案

  • 升级Gunicorn至最新版本,问题仍存在后回退
  • 配置每日定时重启Gunicorn
  • 更换反向代理为Nginx/Caddy
  • 检查OOM(内存不足)错误,未发现相关问题

寻求可行的技术排查或解决方法。

内容的提问来源于stack exchange,提问作者Alcher

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.30 09:10:17