<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>花开的地方 &#187; nginx</title>
	<atom:link href="http://www.bsdmap.com/tag/nginx/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bsdmap.com</link>
	<description>花开，没有声音……</description>
	<lastBuildDate>Wed, 08 Feb 2012 13:39:21 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4-alpha-19814</generator>
		<item>
		<title>nginx的http session管理</title>
		<link>http://www.bsdmap.com/2009/05/16/nginx-http-session/</link>
		<comments>http://www.bsdmap.com/2009/05/16/nginx-http-session/#comments</comments>
		<pubDate>Sat, 16 May 2009 08:27:45 +0000</pubDate>
		<dc:creator>洪川</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[fastcgi集群]]></category>
		<category><![CDATA[nginx集群]]></category>
		<category><![CDATA[撞车效应]]></category>

		<guid isPermaLink="false">http://www.bsdmap.com/?p=1342</guid>
		<description><![CDATA[http session，基本上可以认为就是我们平常所理解的完成GET或者POST请求的HTTP应用的TCP Session。 从自已的使用经验、以及归纳、总结网上各类关于Nginx的文章，个人觉得Nginx最擅长的是对静态内容提供HTTP服务，以及Session管理（HTTP任务管理）。Nginx使用了epoll的模式来管理TCP session，所以，性能高，系统资源消耗低。 实事上，Nginx提供动态内容需要通过FastCGI方式（也支持内置的对perl的支持），当觉得Nginx慢时，实际上是FastCGI慢（而FastCGI慢，大多数时候，又是因为数据库读写慢&#8212;-高并发的请求导致的阻塞属于不常见的原因之一，比如在遭遇DDos攻击的时候）。 大量的并发FastCGI请求，会使FastCGI管理器应接不暇（暂不去管后台数据库的因素，我们要解决的是FastCGI任务调度慢的情况），从而引起阻塞，引发系统上的“撞车效应”。所以瓶颈在FastCGI处理。 不少关于使用Nginx做负载均衡的例子，实际上就是利用Nginx的 session 管理能力。将处理较慢、花时间较多的FastCGI处理任务分发到多台系统上，这样可以提高系统的负载能力，提高系统发生阻塞的阈值。 Nginx的upstream模块，对“负载均衡”提供了良好的支持，详见： http://wiki.nginx.org/NginxHttpUpstreamModule 例： upstream app_group1 { server 192.168.1.111:9000 weight=5 ; server 192.168.1.112:9000 weight=5 ; server 192.168.1.113:9000 weight=3 ; server 192.168.1.114:9000 weight=5 ; } ………… location ~ \.php$ { fastcgi_pass   app_group_01; fastcgi_index  index.php; fastcgi_param  SCRIPT_FILENAME  $fastcgi_script_name; include        extra/fastcgi_params.conf; } 之前，是将Nginx分别放在四台FastCGI服务器上，然后使用LVS来作负载调度，运行良好。为了给系统构架分层，使架构清晰，更易于管理和扩展，降低维护难度，试着使用Nginx来调度负载。 一个较明显的效果是四个FastCGI的系统负载下降（原来有Nginx运行在同一系统上）。 Nginx系统的负载很低，活动连接1.7k左右，负载系统不超过1，用掉不到50M的物理内存。相对于LVS复杂的实施以及背后的管理成本，Nginx在低于100M流量的应用中相当有优势。]]></description>
			<content:encoded><![CDATA[<p>http session，基本上可以认为就是我们平常所理解的完成GET或者POST请求的HTTP应用的TCP Session。</p>
<p>从自已的使用经验、以及归纳、总结网上各类关于Nginx的文章，个人觉得Nginx最擅长的是对静态内容提供HTTP服务，以及Session管理（HTTP任务管理）。Nginx使用了epoll的模式来管理TCP session，所以，性能高，系统资源消耗低。</p>
<p>实事上，Nginx提供动态内容需要通过FastCGI方式（也支持内置的对perl的支持），当觉得Nginx慢时，实际上是FastCGI慢（而FastCGI慢，大多数时候，又是因为数据库读写慢&#8212;-高并发的请求导致的阻塞属于不常见的原因之一，比如在遭遇DDos攻击的时候）。</p>
<p>大量的并发FastCGI请求，会使FastCGI管理器应接不暇（暂不去管后台数据库的因素，我们要解决的是FastCGI任务调度慢的情况），从而引起阻塞，引发系统上的“撞车效应”。所以瓶颈在FastCGI处理。</p>
<p>不少关于使用Nginx做负载均衡的例子，实际上就是利用Nginx的 session 管理能力。将处理较慢、花时间较多的FastCGI处理任务分发到多台系统上，这样可以提高系统的负载能力，提高系统发生阻塞的阈值。</p>
<p>Nginx的upstream模块，对“负载均衡”提供了良好的支持，详见：</p>
<p>http://wiki.nginx.org/NginxHttpUpstreamModule</p>
<p>例：<br />
upstream app_group1 {<br />
server 192.168.1.111:9000 weight=5 ;<br />
server 192.168.1.112:9000 weight=5 ;<br />
server 192.168.1.113:9000 weight=3 ;<br />
server 192.168.1.114:9000 weight=5 ;<br />
}</p>
<p>…………</p>
<p>location ~ \.php$ {<br />
fastcgi_pass   app_group_01;<br />
fastcgi_index  index.php;<br />
fastcgi_param  SCRIPT_FILENAME  $fastcgi_script_name;<br />
include        extra/fastcgi_params.conf;<br />
}</p>
<p>之前，是将Nginx分别放在四台FastCGI服务器上，然后使用LVS来作负载调度，运行良好。为了给系统构架分层，使架构清晰，更易于管理和扩展，降低维护难度，试着使用Nginx来调度负载。</p>
<p>一个较明显的效果是四个FastCGI的系统负载下降（原来有Nginx运行在同一系统上）。</p>
<p>Nginx系统的负载很低，活动连接1.7k左右，负载系统不超过1，用掉不到50M的物理内存。相对于LVS复杂的实施以及背后的管理成本，Nginx在低于100M流量的应用中相当有优势。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bsdmap.com/2009/05/16/nginx-http-session/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>给cacti添加对nginx的统计</title>
		<link>http://www.bsdmap.com/2009/05/15/cacti-nginx/</link>
		<comments>http://www.bsdmap.com/2009/05/15/cacti-nginx/#comments</comments>
		<pubDate>Fri, 15 May 2009 05:23:51 +0000</pubDate>
		<dc:creator>洪川</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[cacti]]></category>
		<category><![CDATA[cacti-nginx]]></category>
		<category><![CDATA[libwww]]></category>
		<category><![CDATA[LWP]]></category>
		<category><![CDATA[perl-libwww-perl]]></category>

		<guid isPermaLink="false">http://www.bsdmap.com/?p=1339</guid>
		<description><![CDATA[官方论坛上有详细说明 http://forums.cacti.net/about26458.html 需要说明的是，本地系统可能没有安装perl的LWP模块，对于CentOS系统来说： yum -y install perl-libwww-perl 即可。 另一个，便是编译nginx时增加 &#8211;with-http_stub_status_module 选项 然后，在Server容器里增加如下配置： location /status { stub_status             on; access_log              off; allow   192.168.0.0/16; deny    all; }]]></description>
			<content:encoded><![CDATA[<p>官方论坛上有详细说明</p>
<p>http://forums.cacti.net/about26458.html</p>
<p>需要说明的是，本地系统可能没有安装perl的LWP模块，对于CentOS系统来说：</p>
<p>yum -y install perl-libwww-perl</p>
<p>即可。</p>
<p>另一个，便是编译nginx时增加 &#8211;with-http_stub_status_module 选项</p>
<p>然后，在Server容器里增加如下配置：</p>
<p>location /status {<br />
stub_status             on;<br />
access_log              off;<br />
allow   192.168.0.0/16;<br />
deny    all;<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bsdmap.com/2009/05/15/cacti-nginx/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>nginxctl</title>
		<link>http://www.bsdmap.com/2008/09/10/nginxct/</link>
		<comments>http://www.bsdmap.com/2008/09/10/nginxct/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 18:30:57 +0000</pubDate>
		<dc:creator>洪川</dc:creator>
				<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://www.bsdmap.com/?p=496</guid>
		<description><![CDATA[自已仿照写了一个nginx的控制角本，运行在我们的CentOS Linux系统上，使用良好。代码如下： #!/bin/bash # Author  : Cao Yuwei # MSN     : # QQ       : # E-Mail   : # master process # TERM,INT  shutdown fast # QUIT         shutdown graceful # HUP           reload config # USR1          reopen log file # USR2          update nginx bin file graceful # WINCH       shutdown worke prcess graceful # work process # TERM,INT   shutdown [...]]]></description>
			<content:encoded><![CDATA[<p>自已仿照写了一个nginx的控制角本，运行在我们的CentOS Linux系统上，使用良好。代码如下：</p>
<p>#!/bin/bash<br />
# Author  : Cao Yuwei<br />
# MSN     :<br />
# QQ       :<br />
# E-Mail   :</p>
<p># master process<br />
# TERM,INT  shutdown fast<br />
# QUIT         shutdown graceful<br />
# HUP           reload config<br />
# USR1          reopen log file<br />
# USR2          update nginx bin file graceful<br />
# WINCH       shutdown worke prcess graceful</p>
<p># work process<br />
# TERM,INT   shutdown fast<br />
# QUIT          shutdown graceful<br />
# USR1          reopen log file</p>
<p>PATH=/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin</p>
<p># Source function library.<br />
. /etc/rc.d/init.d/functions</p>
<p># Source networking configuration.<br />
. /etc/sysconfig/network</p>
<p># Check that networking is up.<br />
if [[ $NETWORKING == [Nn][Oo] ]]; then exit 0; fi</p>
<p>start() {</p>
<p>echo -n &#8216;Starting Nginx: &#8216;<br />
#这里要指定你的nginx的路径: /opt/nginx/sbin/nginx<br />
daemon /opt/nginx/sbin/nginx &#8220;$EXTRAOPTIONS&#8221;<br />
local RETVAL=$?<br />
echo<br />
if [ $RETVAL -eq 0 ]; then touch /var/lock/subsys/nginx ; fi<br />
return $RETVAL<br />
}</p>
<p>stop() {<br />
echo -n &#8216;Shutting down Nginx: &#8216;<br />
killproc nginx<br />
local RETVAL=$?<br />
case nptl in<br />
[Ll]inux[Tt]hreads*|lt*)<br />
# Wait until all threads have terminated.<br />
local -i count=20<br />
while [[ count -gt 0 ]] &amp;&amp; pidof nginx &gt; /dev/null<br />
do<br />
usleep 200000<br />
let &#8211;count<br />
done<br />
;;<br />
esac<br />
echo<br />
if [ $RETVAL -eq 0 ]; then rm -f /var/lock/subsys/nginx; fi<br />
return $RETVAL<br />
}</p>
<p>restart() {<br />
stop<br />
start<br />
}</p>
<p>relog() {<br />
echo -n &#8216;Relog Nginx: &#8216;<br />
killproc nginx -USR1<br />
local RETVAL=$?<br />
echo<br />
return $RETVAL<br />
}</p>
<p>reload() {<br />
echo -n &#8216;Reload Nginx: &#8216;<br />
killproc nginx -HUP<br />
local RETVAL=$?<br />
echo<br />
return $RETVAL<br />
}</p>
<p>check() {<br />
/opt/nginx/sbin/nginx -t<br />
}</p>
<p>#<br />
#       See how we were called.<br />
#<br />
case &#8220;$1&#8243; in<br />
start)<br />
start<br />
;;<br />
stop)<br />
stop<br />
;;<br />
reload)<br />
reload<br />
;;<br />
restart)<br />
restart<br />
;;<br />
relog)<br />
relog<br />
;;<br />
check)<br />
check<br />
;;<br />
*)<br />
echo $&#8221;Usage: nginxctl {start|stop|restart|reload|relog|check}&#8221;<br />
exit 1<br />
esac</p>
<p>exit</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bsdmap.com/2008/09/10/nginxct/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nginx versus Apache</title>
		<link>http://www.bsdmap.com/2008/04/25/nginx-versus-apache/</link>
		<comments>http://www.bsdmap.com/2008/04/25/nginx-versus-apache/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 16:19:54 +0000</pubDate>
		<dc:creator>洪川</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://www.bsdmap.com/~nnix/2008/04/25/nginx-versus-apache/</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<table border="0">
<tbody>
<tr>
<td width="350"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="432" height="380" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="name" value="ssss" /><param name="src" value="http://vhead.blog.sina.com.cn/player/outer_player.swf?auto=0&amp;vid=10894989&amp;uid=1278987704type=" /><embed type="application/x-shockwave-flash" width="432" height="380" src="http://vhead.blog.sina.com.cn/player/outer_player.swf?auto=0&amp;vid=10894989&amp;uid=1278987704type=" name="ssss"></embed></object></td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.bsdmap.com/2008/04/25/nginx-versus-apache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

