我在 GCP 中部署了一个 Python (3.x) Web 服务。每次 Cloud Run 关闭实例时,尤其是在负载峰值之后,我都会收到许多类似这样的日志Uncaught signal: 6, pid=6, tid=6, fault_addr=0.,并且[CRITICAL] WORKER TIMEOUT (pid:6)它们始终是信号 6。
该服务正在使用 FastAPI 和 Gunicorn 通过此启动命令在 Docker 中运行
CMD gunicorn -w 2 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:8080 app.__main__:app
Run Code Online (Sandbox Code Playgroud)
该服务使用 Terraform 部署,具有 1 GB 内存、2 个 CPU,超时设置为 2 分钟
resource "google_cloud_run_service" <ressource-name> {
name = <name>
location = <location>
template {
spec {
service_account_name = <sa-email>
timeout_seconds = 120
containers {
image = var.image
env {
name = "GCP_PROJECT"
value …Run Code Online (Sandbox Code Playgroud) python-3.x docker google-cloud-platform google-cloud-run fastapi