【问题标题】:Heroku H12 Request timeout on Django applicationDjango应用程序上的Heroku H12请求超时
【发布时间】:2021-12-07 00:47:47
【问题描述】:

我正在 Heroku 上运行一个 Django 应用程序。

当我发出超过 30 秒的请求时,它会停止并且请求返回 503 Service Unavailable。

这些是heroku日志

2021-10-20T07:11:14.726613+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/ajax/download_yt/" host=yeti-mp3.herokuapp.com request_id=293289be-6484-4f11-a62d-bda6d0819351 fwd="79.3.90.79" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https

我尝试对此进行一些研究,发现我可以在 Procfile 中增加 gunicorn(我使用的是 gunicorn 版本 20.0.4)超时。我尝试增加到 60 秒,但请求在 30 秒后仍然停止。

这是我当前的 Procfile:

web: gunicorn yetiMP3.wsgi --timeout 60 --log-file -

这些是我在 Heroku 应用中使用的构建包:

如何增加请求超时? 我错过了一些heroku配置吗?

【问题讨论】:

  • 为什么你有超过 30 秒的响应时间?好像有点过分了
  • 这是对下载 youtube 视频的控制器的请求。我应该将其作为后台进程进行,但我想了解我在使用 heroku 配置时做错了什么

标签: django heroku gunicorn


【解决方案1】:

最终我发现这是一个 Heroku dyno 配置。 Heroku 路由器将在 30 秒后丢弃任何请求,无论您将 gunicorn 计时器设置多高。

这个官方heroku的更多细节article

【讨论】:

    猜你喜欢
    • 2020-01-26
    • 2019-12-15
    • 2012-06-14
    • 1970-01-01
    • 1970-01-01
    • 2021-06-07
    • 2019-09-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多