【问题标题】:500 Internal Server Error when downloading huge file through Cloud Run通过 Cloud Run 下载大文件时出现 500 内部服务器错误
【发布时间】:2020-06-16 07:42:36
【问题描述】:

出于测试目的构建了一个包含超过 30GB 单个文件的巨大映像后,我无法在将映像部署到 Cloud Run 后下载相同的文件。

需要澄清的是,该映像确实在 Cloud Run 上构建和运行,但由于某种原因,特定的大文件不可用。

这里是重现此错误的示例 Dockerfile:

FROM python:3
WORKDIR /app
RUN touch test # downloading this file works fine
RUN dd if=/dev/urandom of=file bs=1M count=32768 # this one takes a while to build and to deploy, and won't be downloadable later on.
EXPOSE 8080
CMD python -m http.server 8080 --bind 0.0.0.0

尝试通过 wget 下载文件返回以下内容:

wget https://cloud-run-link-here.app/file
--2020-03-03 17:19:16--  https://cloud-run-link-here.app/file
Loaded CA certificate '/etc/ssl/certs/ca-certificates.crt'
Resolving cloud-run-link-here.app (bigdocker-7k3mrt42la-uc.a.run.app)... :::::0, 0.0.0.0
Connecting to cloud-run-link-here.app (cloud-run-link-here.app)|:::::0|:443... connected.
HTTP request sent, awaiting response... 500 Internal Server Error
2020-03-03 17:19:17 ERROR 500: Internal Server Error.

在本地做同样的事情就可以了。

Cloud Run 的日志中没有有用的信息,如下图所示。

【问题讨论】:

    标签: google-cloud-platform google-cloud-run


    【解决方案1】:

    Python 标准库中的maximum response size for Cloud Run is 32MB 和HTTP 服务器是not recommended for production use。很可能它没有尝试分块非常大的请求并失败。

    您应该考虑使用生产 HTTP 服务器,例如 gunicorn

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-09
      • 1970-01-01
      • 2021-07-24
      • 1970-01-01
      相关资源
      最近更新 更多