我正在运行一个数据库支持的网站,收到很less的stream量。 然而,一天或两天,请求将会超时,我会在Nginx的error.log看到这个(或类似的)错误:
2013/06/13 18:32:40 [error] 16723#0: *27796 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 199.71.215.214, server: app.mypythonwebapp.com, request: "POST /api?submit_staker_response HTTP/1.1", upstream: "uwsgi://unix:/var/run/uwsgi/app.mypythonwebapp.com-uwsgi.sock", host: "app.mypythonwebapp.com", referrer: "https://app.mypythonwebapp.com/survey/5/791/70ea73eb9a489f2dead804a95c400ab2"
我正在运行uWSGI,在它的日志文件中没有任何与此相关的东西(我可以告诉)。 我怀疑它可能是PostgreSQL相关的,但如果我通过pg_stat_activity检查它的状态,我什么都看不到。
这是我的uWSGI YAMLconfiguration文件:
uwsgi: socket: /var/run/uwsgi/%n-uwsgi.sock workers: 5 buffer-size: 32768 callable: app wsgi-file: /opt/sites/app.mypythonwebapp.com/run.py virtualenv: /opt/virtualenv/app.mypythonwebapp.com pythonpath: /opt/sites/app.mypythonwebapp.com
我所在的服务器有两个(虚拟化的)核心,所以我做了1 +核心* 2来确定工作人员的数量。 我也提高了buffer-size参数,试图解决这个问题,但是错误仍然存在。
我不知道从哪里开始debugging。 我几乎没有经验运行uWSGI(或任何Python的WSGI实现)。
触发超时的选项(在nginx中)是
http://wiki.nginx.org/HttpUwsgiModule#uwsgi_read_timeout
它的缺省值是60秒,所以如果你请求的时间片没有产生输出,nginx会closures连接。
如果你没有在uWSGI中看到错误(我认为从nginx断开的“断开的pipe道”的一部分),我会调查为什么这一代是如此之慢