AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-114095

handsofaten's questions

Martin Hope
handsofaten
Asked: 2016-06-05 18:37:14 +0800 CST

没有 Nginx 的 ELB 后面 Gunicorn 的 Keepalive 设置

  • 19

我们应用程序的 REST API 由运行在 AWS EC2 实例上的 Gunicorn(不在Nginx 后面)提供服务,具有典型的自动扩展/负载平衡设置。负载均衡器的空闲超时为 60 秒,而 Gunicorn 的保活超时为 2 秒。我们一直看到504 Gateway Timeout此配置的零星响应。根据Amazon docs,这可能是因为服务器的保持活动超时低于负载均衡器的空闲超时设置:

原因 2:已注册实例关闭与 Elastic Load Balancing 的连接。

解决方案 2:在您的 EC2 实例上启用 keep-alive 设置,并将 keep-alive 超时设置为大于或等于负载均衡器的空闲超时设置。

使用 Nginx,默认keepalive_timeout值为 75 秒,这显然适用于 ELB 默认设置。但是,Gunicorn 文档建议keepalive设置在 1-5 秒的范围内。

将 Gunicorn 的 keepalive 时间提高到 75 秒是否有意义,或者即使我们没有在它前面使用反向代理,是否有充分的理由将其保持在 5 秒以下?

load-balancing amazon-ec2 python gunicorn
  • 1 个回答
  • 8495 Views
Martin Hope
handsofaten
Asked: 2014-10-29 14:02:55 +0800 CST

uWSGI 无法加载 virtualenv

  • 1

我正在使用 nginx 和 uWSGI 设置 Python 应用程序。我的依赖项位于 virtualenv 中。如果我手动激活 virtualenv,一切都可以通过运行以下命令进行:

uwsgi --ini uwsgi.ini

但是如果我尝试在 virtualenv 停用的情况下运行相同的命令,我会在输出中得到这个(虽然没有特定的权限错误):

*** no app loaded. going in full dynamic mode ***

同理,Emperor加载ini文件时,也无法运行app。我的理解是使用该home选项应该激活 virtualenv,但它似乎没有工作。(wsgi.py加载的模块也会激活 virtualenv,所以我什至不确定为什么我应该在那之前这样做......)

这是我的uwsgi.ini:

[uwsgi]
uid = 1000
socket = 127.0.0.1:8000
workers = 3
master = true
processes = 5
module = wsgi:application
chdir = /home/laststatement/app/laststatement
home = /home/laststatement/.virtualenvs/last
logto = /home/laststatement/log/uwsgi.log

这是uWSGI日志:

machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /etc/uwsgi/apps-enabled
detected binary path: /usr/bin/uwsgi-core
uWSGI running as root, you can use --uid/--gid/--chroot options
setuid() to 1000
your processes number limit is 3750
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 127.0.0.1:8000 fd 3
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 436752 bytes (426 KB) for 5 cores
*** Operational MODE: preforking ***
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!
no request plugin is loaded, you will not be able to manage requests.
you may need to install the package for your language of choice, or simply load it with --plugin.
!!!!!!!!!!! END OF WARNING !!!!!!!!!!
spawned uWSGI master process (pid: 834)
spawned uWSGI worker 1 (pid: 838, cores: 1)
spawned uWSGI worker 2 (pid: 839, cores: 1)
spawned uWSGI worker 3 (pid: 840, cores: 1)
spawned uWSGI worker 4 (pid: 841, cores: 1)
spawned uWSGI worker 5 (pid: 842, cores: 1)
-- unavailable modifier requested: 0 --
announcing my loyalty to the Emperor...
-- unavailable modifier requested: 0 --
announcing my loyalty to the Emperor...
ubuntu
  • 1 个回答
  • 3279 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve