Gunicorn 如何设置一个请求超时时间?

架构图如上所示

没有使用 Nginx,(不想使用 Nginx)

前端有 count 操作,这个 count 操作非常的耗时,短则几分钟,长则无法估量
gunicorn.conf.py

bind = "0.0.0.0:63001"
workers = 2
threads = 64

我需要防止可用的连接资源被耗尽

我查了一下 Gunicorn 的 conf doc

发现和 timeout 相关的只有:

但是这两个参数好像都是说进程不干活,restart 进程的,和我的需求不是一回事

所以。Gunicorn 无法设置一个 request 的 timeout 吗?

比如 10 秒无法 response,就 reponse 一个 504

如果 Gunicorn 无法实现的话?Django 的 ORM 可以设置 timeout 吗?

阅读 3.7k
1 个回答

在 Gunicorn 前再加一个 Nginx,超时在 Nginx 上配置即可。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题