dockerized Gunicorn:[错误] Worker 被发送了 SIGKILL

问题描述 投票:0回答:1

我有一个由gunicorn 提供的烧瓶应用程序。 所有这些都在 Docker 容器内运行。 当从主机(ubuntu)机器发送POST请求时,在我的计算机上,服务器响应是正确的

在我的 VPS (debian 10) 上,使用相同的 docker 镜像,我遇到了来自 Gunicorn 的错误(参见标题)

[2024-02-28 17:08:13 +0000] [1] [CRITICAL] WORKER TIMEOUT (pid:538)
[2024-02-28 17:08:14 +0000] [1] [ERROR] Worker (pid:538) was sent SIGKILL! Perhaps out of memory?
[2024-02-28 17:08:14 +0000] [546] [INFO] Booting worker with pid: 546

你能帮我吗,我不知道要检查什么...(也许在docker级别,但我不知道如何)

注意:我在主机上有一个 PostgresSQL 数据库,并且从容器内的访问工作正常(我可以使用

flask db upgrade
从容器内创建表)

我尝试比较来自我的 ubuntu 机器的curl 请求(正确的响应与指示无效密码的 JSON)

curl -b "auth.strategy=local; auth.redirect=%2F; auth._token.local=false; auth._refresh_token.local=false" -d '{"email":"[email protected]","password":"12312312"}' -H "Content-Type: application/json" -X POST http://127.0.0.1:5000/icbf/api/v2/auth/login --verbose
*   Trying 127.0.0.1:5000...
* Connected to 127.0.0.1 (127.0.0.1) port 5000 (#0)
> POST /icbf/api/v2/auth/login HTTP/1.1
> Host: 127.0.0.1:5000
> User-Agent: curl/7.81.0
> Accept: */*
> Cookie: auth.strategy=local; auth.redirect=%2F; auth._token.local=false; auth._refresh_token.local=false
> Content-Type: application/json
> Content-Length: 47
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 401 UNAUTHORIZED
< Server: gunicorn
< Date: Wed, 28 Feb 2024 17:07:28 GMT
< Connection: close
< Content-Type: application/json
< Content-Length: 47
< Access-Control-Allow-Origin: *
< 
{"message": "Email ou mot de passe invalide."}
* Closing connection 0

以及虚拟服务器上的服务器(带有 debian 10 的 VPS),在出现错误之前已挂起 20 秒

curl -b "auth.strategy=local; auth.redirect=%2F; auth._token.local=false; auth._refresh_token.local=false" -d '{"email":"[email protected]","password":"12312312"}' -H "Content-Type: application/json" -X POST http://127.0.0.1:5000/icbf/api/v2/auth/login --verbose
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 5000 (#0)
> POST /icbf/api/v2/auth/login HTTP/1.1
> Host: 127.0.0.1:5000
> User-Agent: curl/7.64.0
> Accept: */*
> Cookie: auth.strategy=local; auth.redirect=%2F; auth._token.local=false; auth._refresh_token.local=false
> Content-Type: application/json
> Content-Length: 47
> 
* upload completely sent off: 47 out of 47 bytes
* Empty reply from server
* Connection #0 to host 127.0.0.1 left intact
curl: (52) Empty reply from server

我尝试使用 VPS 容器内的 free 命令检查服务器内存,但看起来没问题:

               total        used        free      shared  buff/cache   available
Mem:         1996412      441240      522812       34912     1032360     1357380
Swap:              0           0           0

我真的不知道去哪里找...

docker flask gunicorn sigkill
1个回答
0
投票

我也遇到过类似的情况。就我而言,问题在于工作线程启动时消耗的 CPU 功率超出了虚拟机允许的功率。 有两种可能的方法来解决这个问题:

  1. 减少每个工作线程的线程数、每个工作线程的请求数或工作线程本身的数量。 (可能更少的工人就可以了)

    gunicorn -w --线程

  2. 增加VM的CPU核心数量。

© www.soinside.com 2019 - 2024. All rights reserved.