Articles of wsgi

阿帕奇基准testing从公共networking缓慢,本地速度更快。 我做了什么来加快速度?

我正在testing我的Linode Ubuntu 14 64位服务器,这是他们提供的最基本的服务器。 我正在使用Apache Benchmark来testing服务器,以及我用Python编写的multithreading脚本,但稍后会介绍更多。 使用AB我注意到,当从服务器本地运行本地时,每秒约7k个请求,但是从另一个networking/因特网运行时只有约15个请求。 本地1000个并发连接的响应时间也约为150毫秒。 对于100个并发连接,响应时间大约为1.5-2.5秒。 我运行远程testing的networking有很多带宽,而且我运行它的计算机有很多内存和处理器的速度。 这是一个快速的商业networking。 我甚至在美国的其他两台电脑上试了两台,速度都差不多。 在运行我的multithreading脚本时,我注意到只要尝试了超过100个并发请求,就会打嗝,这是来自外部networking。 我还没有在服务器上本地尝试我的脚本,因为我需要将服务器上的Python升级到3+或将脚本更改为2.7兼容。 我在本地进行了testing,在运行1000个multithreading连接的脚本时获得了150毫秒的响应时间,这只是使用urllib2。 我直接对nginx(一个静态文件),nginx后面的pywsgi应用程序以及直接对pywsgi进行testing。 pywsgi应用程序有一个简单的路线,回复一个基本的回应,所以它应该是快速的。 毫不奇怪,nginx-> pywsgi提供了最好的结果,可能是因为它缓冲了请求。 有没有什么是特定的Linode的networking导致这个问题? 内部和外部testing之间的数量级差异使我想知道可能是什么原因。 唯一的办法就是iptables防火墙,只需要在http / s和ssh中进行过滤。 dmesg没有关于我的testing的信息。

Apache mpm worker + wsgi Python / Django工作者被困住了

我们的Apache + Django服务器存在员工卡住的问题。 这是一个mpm工作模型,经过一段时间,每个为十几个工作线程服务的进程都冻结了所有的工作线程: # apache2ctl status Apache Server Status for localhost Server Version: Apache/2.2.14 (Ubuntu) mod_ssl/2.2.14 OpenSSL/0.9.8k mod_wsgi/ 2.8 Python/2.6.5 Server Built: Mar 8 2013 16:46:38 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Current Time: Friday, 05-Apr-2013 15:56:17 CEST Restart Time: Thursday, 04-Apr-2013 11:23:23 CEST Parent Server Generation: 11 Server uptime: 1 day 4 hours 32 minutes 53 seconds Total […]

尝试在Ubuntu Lucid Lynx上启动Apache2 mod_wsgi而无法成功运行Django

我有一个最小安装ubuntu lucid-lynx与约256MB内存的小vps ,它是新安装的没有什么特别的运行。 我试图部署django到它,而我成功地运行服务器使用manage.py,我不能得到Apache与wsgi工作: # service apache2 start && service apache2 status * Starting web server apache2 [ OK ] Apache is NOT running. Erorr日志/var/log/apache2/error.log : [Thu Apr 14 21:17:29 2011] [warn] pid file /var/run/apache2.pid overwritten — Unclean shutdown of previous Apache run? [Thu Apr 14 21:17:29 2011] [notice] Apache/2.2.14 (Ubuntu) mod_wsgi/2.8 Python/2.6.5 configured — […]

Apache + mod_wsgi上的Python Django站点与nginx代理:高度波动的性能

我有一个使用mod_wsgi(embedded模式; 更快的模式 ,如果configuration正确的话)运行几十个Python Django站点的Ubuntu 10.04盒子。 业绩波动很大。 有时很快,有时延迟几秒钟。 吸烟图是在这个地方。 最近,我还为静态内容添加了一个nginx代理,希望它可以治愈高度波动的performance。 但是,尽pipe它减less了Apache必须处理的请求数量,但并没有帮助解决主要问题。 在运行htop时点击网站时,可以看到有时候请求几乎是即时的,而有时则会导致Apache几秒钟内消耗100%的CPU。 我真的不明白这种波动来自哪里。 我已经为Apacheconfiguration了mpm_worker,如下所示: StartServers 1 MinSpareThreads 50 MaxSpareThreads 50 ThreadLimit 64 ThreadsPerChild 50 MaxClients 50 ServerLimit 1 MaxRequestsPerChild 0 MaxMemFree 2048 1个服务器,50个线程,最多50个客户端。 Munin和apache2ctl -t都performance出一致的工人存在; 它们并不是一直被破坏和创造的。 然而,它的行为如此。 这告诉我,一旦一个子解释器被创build,它应该保留在内存中,但似乎网站必须重新加载。 我也有一个nginx + gunicorn框,performance相当好。 我真的想知道为什么Apache是​​如此随机。 这是一个虚拟主机configuration: <VirtualHost *:81> ServerAdmin [email protected] ServerName example.com DocumentRoot /srv/http/site/bla Alias /static/ /srv/http/site/static Alias /media/ […]

Django + Apache + mod_wsgi:为什么多次执行wsgi脚本?

我对所有服务器技术都比较陌生,我遵循本教程,使用mod_wsgi在Apache Web服务器上部署我的django应用程序: http://thecodeship.com/deployment/deploy-django-apache-virtualenv-and-mod_wsgi/ 这是我的虚拟主机文件: <VirtualHost *:80> ServerName www.abcxyz.org ServerAlias abcxyz.org WSGIScriptAlias / /var/www/abcxyz/django/abcxyz/wsgi_prod.py Alias /static/ /var/www/abcxyz/static/ <Location "/static/"> Options -Indexes </Location> </VirtualHost> 据我了解, wsgi_prod.py文件应该只在服务器启动时执行一次(或者当它得到第一个请求 – 我不确定这一点)。 但在我的应用程序中执行多次,发送请求到服务器。 它不是在所有请求上执行,而是在其中一些上执行。 还有一些请求,有时只触发wsgi_prod.py的执行。 这是我的wsgi_prod.py文件: import os import sys import site import thread # Add the site-packages of the chosen virtualenv to work with site.addsitedir('/etc/Envs/abcxyz/local/lib/python2.7/site-packages') # Add the app's directory […]

为什么要在WSGI服务器之前放置一个反向代理?

用于部署WSGI应用程序的典型configuration包括作为逆向代理的通用Web服务器(如nginx)后面的WSGI服务器(如uWSGI或Gunicorn)。 我知道有一个反向代理的一个主要原因是有效地提供静态文件。 还有其他的原因吗? 假设我的应用程序只涉及Python代码,并不关心静态内容。 为什么我要在这种情况下需要反向代理? uWSGI和Gunicorn都已经提供了一个能够与客户端接口的asynchronousHTTP服务器。 有没有什么实际情况可以让WSGI HTTP服务器直接暴露给外部世界呢?

Nginx + Django + FastCGI WSGI错误? (非致命)

我正在用fastcgi在nginx上运行django。 当我做runfcgi时,我看到这些错误: python manage.py runfcgi daemonize=false host=127.0.0.1 port=8000 WSGIServer: missing FastCGI param SERVER_NAME required by WSGI! WSGIServer: missing FastCGI param SERVER_PORT required by WSGI! WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI! 在我的nginx错误日志中,我看到这个: 2011/01/31 10:33:16 [error] 15921#0: *4 FastCGI sent in stderr: "WSGIServer: missing FastCGI param SERVER_NAME required by WSGI! WSGIServer: missing FastCGI param SERVER_PORT […]

如何debugging这个Nginx的uWSGI超时?

我正在运行一个数据库支持的网站,收到很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 +核心* […]

如何为mod_python或mod_wsgiconfigurationISPConfig?

如何configurationISPConfig的mod_python或mod_wsgi的Django的应用程序部署?

UWSGI和NGINX for Ubuntu 11.10上的Python应用程序

我试图find一个最佳的方式来设置我的服务器使用NGINX和UWSGI服务python应用程序。 以下工作到目前为止: 初始设置: sudo apt-get install nginx uwsgi uwsgi-plugin-http uwsgi-plugin-python python-setuptools easy_install pip pip install web.py 在/ etc / nginx的/网站可用/默认: server { listen 80; server_name localhost; location / { include uwsgi_params; uwsgi_pass 127.0.0.1:9090; } } 然后我有一个基本的myapp.py(位置不关心当前的设置): import web urls = ( '/', 'index' ) app = web.application(urls, globals()) class index: def GET(self): return "Hello from […]