<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[张宴的博客]]></title> 
<link>http://zyan.cc/index.php</link> 
<description><![CDATA[Web系统架构与底层研发]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[张宴的博客]]></copyright>
<item>
<link>http://zyan.cc/post/313/</link>
<title><![CDATA[使用Varnish代替Squid做网站缓存加速器的详细解决方案[原创]]]></title> 
<author>张宴 &lt;net@s135.com&gt;</author>
<category><![CDATA[Cache与存储]]></category>
<pubDate>Thu, 29 Nov 2007 14:11:29 +0000</pubDate> 
<guid>http://zyan.cc/post/313/</guid> 
<description>
<![CDATA[ 
	　　[文章作者：张宴 本文版本：v1.2 最后修改：<span style="color: #FF0000;">2008.01.02</span> 转载请注明出处：<a href="http://blog.zyan.cc" target="_blank">http://blog.zyan.cc</a>]<br/><br/>　　我曾经写过一篇文章──《<a href="read.php/290.htm" target="_blank">初步试用Squid的替代产品──Varnish Cache网站加速器</a>》，但当时仅仅是用着玩，没做深入研究。<br/><br/>　　今天写的这篇关于Varnish的文章，已经是一篇可以完全替代Squid做网站缓存加速器的详细解决方案了。网上关于Varnish的资料很少，中文资料更是微乎其微，希望本文能够吸引更多的人研究、使用Varnish。<br/><br/>　　<strong>在我看来，使用Varnish代替Squid的理由有三点：</strong><br/>　　1、Varnish采用了“Visual Page Cache”技术，在内存的利用上，Varnish比Squid具有优势，它避免了Squid频繁在内存、磁盘中交换文件，性能要比Squid高。<br/>　　2、Varnish的稳定性还不错，我管理的一台图片服务器运行Varnish已经有一个月，没有发生过故障，而进行相同工作的Squid服务器就倒过几次。<br/>　　3、通过Varnish管理端口，可以使用正则表达式快速、批量地清除部分缓存，这一点是Squid不能具备的。<br/><br/>　　<a href="http://zyan.cc/attachment/200711/varnish0.gif" target="_blank"><img src="http://zyan.cc/attachment/200711/varnish0.gif" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/><hr/><br/>　　<strong>下面来安装Varnish网站缓存加速器（Linux系统）：</strong><br/>　　1、创建www用户和组，以及Varnish缓存文件存放目录（/var/vcache）：<br/>............<br/><br/>Tags - <a href="http://zyan.cc/tags/linux/" rel="tag">linux</a> , <a href="http://zyan.cc/tags/squid/" rel="tag">squid</a> , <a href="http://zyan.cc/tags/varnish/" rel="tag">varnish</a> , <a href="http://zyan.cc/tags/cache/" rel="tag">cache</a>
]]>
</description>
</item><item>
<link>http://zyan.cc/post/313/#blogcomment478</link>
<title><![CDATA[[评论] 使用Varnish代替Squid做网站缓存加速器的详细解决方案[原创]]]></title> 
<author>Jacky &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Mon, 03 Dec 2007 02:28:02 +0000</pubDate> 
<guid>http://zyan.cc/post/313/#blogcomment478</guid> 
<description>
<![CDATA[ 
	varnish如何做到在不重启的情况下重新载入配置文件
]]>
</description>
</item><item>
<link>http://zyan.cc/post/313/#blogcomment479</link>
<title><![CDATA[[评论] 使用Varnish代替Squid做网站缓存加速器的详细解决方案[原创]]]></title> 
<author>Jacky &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Mon, 03 Dec 2007 02:29:03 +0000</pubDate> 
<guid>http://zyan.cc/post/313/#blogcomment479</guid> 
<description>
<![CDATA[ 
	用varnish做反向代理的时候，登录一般的网站没有任何问题。登录DZ论坛的后台出现无法登录，没有任何提示。用squid就没有这样的问题，不知道那位老大遇到过这样的问题。
]]>
</description>
</item><item>
<link>http://zyan.cc/post/313/#blogcomment480</link>
<title><![CDATA[[评论] 使用Varnish代替Squid做网站缓存加速器的详细解决方案[原创]]]></title> 
<author>itsea &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Tue, 04 Dec 2007 15:42:16 +0000</pubDate> 
<guid>http://zyan.cc/post/313/#blogcomment480</guid> 
<description>
<![CDATA[ 
	张兄，今天测了一下varnish,原来用nginx+squid ESTAB连接大概在1700的机器换了varnish后连接数只有300多了，访问起来一切正常，cacti查看到流量也是正常的，难道varnish就强在这？配置是按您的配置做的。<br/>另外还有个问题vcache这个目录是用来保存cache文件的是吗？我在ll vcache里什么文件都没有。<br/>还有用varnish这个方法还解决了一直让我头疼的squid不支持iis compress问题，实在太感谢了
]]>
</description>
</item><item>
<link>http://zyan.cc/post/313/#blogcomment481</link>
<title><![CDATA[[评论] 使用Varnish代替Squid做网站缓存加速器的详细解决方案[原创]]]></title> 
<author>itsea &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 05 Dec 2007 02:06:47 +0000</pubDate> 
<guid>http://zyan.cc/post/313/#blogcomment481</guid> 
<description>
<![CDATA[ 
	今天遇到的问题貌似跟楼上说的一样，varnish做反向代理后dvbbs登陆不正常，用户登陆后显示同一个用户名，验证码不变。
]]>
</description>
</item><item>
<link>http://zyan.cc/post/313/#blogcomment483</link>
<title><![CDATA[[评论] 使用Varnish代替Squid做网站缓存加速器的详细解决方案[原创]]]></title> 
<author>minuteman &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 06 Dec 2007 08:20:36 +0000</pubDate> 
<guid>http://zyan.cc/post/313/#blogcomment483</guid> 
<description>
<![CDATA[ 
	正好这两天我在自己的BLOG上也做了varnish缓存的实验<br/>用varnishncsa输出日志，但发现里面有不少日志条目是127.0.0.1来的访问，觉得比较奇怪，是不是varnishd工作时候产生的？上网找也没找到相关的解释。<br/>老大你有没有相关知识分享一下？嘿嘿
]]>
</description>
</item><item>
<link>http://zyan.cc/post/313/#blogcomment486</link>
<title><![CDATA[[评论] 使用Varnish代替Squid做网站缓存加速器的详细解决方案[原创]]]></title> 
<author>leftleg &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 07 Dec 2007 04:50:22 +0000</pubDate> 
<guid>http://zyan.cc/post/313/#blogcomment486</guid> 
<description>
<![CDATA[ 
	discuz 做缓存的话 ,可以试试使用缓存帖子分页。
]]>
</description>
</item><item>
<link>http://zyan.cc/post/313/#blogcomment487</link>
<title><![CDATA[[评论] 使用Varnish代替Squid做网站缓存加速器的详细解决方案[原创]]]></title> 
<author>Jacky &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 07 Dec 2007 06:12:12 +0000</pubDate> 
<guid>http://zyan.cc/post/313/#blogcomment487</guid> 
<description>
<![CDATA[ 
	varnish可以实现类似于squid那样的父子节点关系吗？
]]>
</description>
</item><item>
<link>http://zyan.cc/post/313/#blogcomment488</link>
<title><![CDATA[[评论] 使用Varnish代替Squid做网站缓存加速器的详细解决方案[原创]]]></title> 
<author>itsea &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 07 Dec 2007 06:51:07 +0000</pubDate> 
<guid>http://zyan.cc/post/313/#blogcomment488</guid> 
<description>
<![CDATA[ 
	今天在另外一个平台上使用varnish测试<br/>增加了<br/>if (req.request != &quot;GET&quot; &amp;&amp; req.request != &quot;HEAD&quot;) &#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pipe;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#125;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elseif(req.url ~ &quot;\.(aspx&#124;asp&#124;shtml&#124;vimg)($&#124;\?)&quot;) &#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pass;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#125;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;lookup;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#125;<br/>&#125;<br/>后还是偶尔有用户登陆后显示别人的用户名<br/>而且程序员更新js文件后不能马上看到<br/>/usr/local/varnish/bin/varnishadm -T 127.0.0.1:3500 url.purge *$<br/>purge所有后也不行，还发现一个小问题执行 varnishadm后容易使varnishd父进程吃cpu 100%一直下不来<br/>我的访问量在 350 request/sec<br/>e文的理解能力比较查在man跟官方faq里似乎没看到类似情况
]]>
</description>
</item><item>
<link>http://zyan.cc/post/313/#blogcomment489</link>
<title><![CDATA[[评论] 使用Varnish代替Squid做网站缓存加速器的详细解决方案[原创]]]></title> 
<author>minuteman &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 07 Dec 2007 09:57:21 +0000</pubDate> 
<guid>http://zyan.cc/post/313/#blogcomment489</guid> 
<description>
<![CDATA[ 
	缓存不该缓存的对象的问题<br/>也许可以通过在recv里<br/> &nbsp; &nbsp;if (req.http.Cache-Control ~ &quot;no-cache&quot;) &#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp;pass;<br/> &nbsp; &nbsp;&#125;<br/>在fetch里加<br/> &nbsp; &nbsp;if (obj.http.Pragma ~ &quot;no-cache&quot; &#124;&#124; obj.http.Cache-Control ~ &quot;no-cache&quot; &#124;&#124; obj.http.Cache-Control ~ &quot;private&quot;) &#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp;pass;<br/> &nbsp; &nbsp;&#125;
]]>
</description>
</item><item>
<link>http://zyan.cc/post/313/#blogcomment497</link>
<title><![CDATA[[评论] 使用Varnish代替Squid做网站缓存加速器的详细解决方案[原创]]]></title> 
<author>leftleg &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Mon, 10 Dec 2007 08:00:33 +0000</pubDate> 
<guid>http://zyan.cc/post/313/#blogcomment497</guid> 
<description>
<![CDATA[ 
	ping [timestamp]<br/>status<br/>start<br/>stop<br/>stats<br/>vcl.load &lt;configname&gt; &lt;filename&gt;<br/>vcl.inline &lt;configname&gt; &lt;quoted_VCLstring&gt;<br/>vcl.use &lt;configname&gt;<br/>vcl.discard &lt;configname&gt;<br/>vcl.list<br/>vcl.show &lt;configname&gt;<br/>param.show [-l] [&lt;param&gt;]<br/>param.set &lt;param&gt; &lt;value&gt;<br/>help [command]<br/><br/>telnet 管理有个 vcl.load 应该可以 不重启的情况下重新载入配置文件
]]>
</description>
</item><item>
<link>http://zyan.cc/post/313/#blogcomment521</link>
<title><![CDATA[[评论] 使用Varnish代替Squid做网站缓存加速器的详细解决方案[原创]]]></title> 
<author>小春 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 20 Dec 2007 04:02:51 +0000</pubDate> 
<guid>http://zyan.cc/post/313/#blogcomment521</guid> 
<description>
<![CDATA[ 
	张老师，我装好了，一切正常，只提到的管理这些功能不正常：<br/>[root@linux1 ~]# /usr/local/varnish/bin/varnishadm -T 127.0.0.1:3500<br/>usage: varnishadm -T [address]:port command [...]<br/><br/>上面命令明明没有问题,端口监听也正常.<br/><br/>[root@linux1 ~]# /usr/local/varnish/bin/varnishstat <br/>Cannot open /usr/local/varnish/var/varnish/www.38hao.org/_.vsl: No such file or directory<br/>但是我的，这_.vsl文件明明是在/data/cache目录下，他非到 /usr/local/varnish/var/varnish/下读！
]]>
</description>
</item><item>
<link>http://zyan.cc/post/313/#blogcomment522</link>
<title><![CDATA[[评论] 使用Varnish代替Squid做网站缓存加速器的详细解决方案[原创]]]></title> 
<author>jack &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 21 Dec 2007 01:59:05 +0000</pubDate> 
<guid>http://zyan.cc/post/313/#blogcomment522</guid> 
<description>
<![CDATA[ 
	[root@localhost root]# cat start_cache.sh <br/>ulimit -SHn 51200<br/>/usr/local/varnish/sbin/varnishd -n /home/cache -f /usr/local/varnish/vcl.conf -a 0.0.0.0:81 -s file,/home/cache/varnish_cache.data,1G -g www -u www -w 30000,51200,10 -T 127.0.0.1:3500 -p client_http11=on<br/>/usr/local/varnish/bin/varnishncsa -n /home/cache -w /home/logs/www.log &amp;<br/>[root@localhost root]# sh start_cache.sh <br/>file /home/cache/varnish_cache.data size 1073741824 bytes (262144 fs-blocks, 262144 pages)<br/>Using old SHMFILE<br/>[root@localhost root]# netstat -untl<br/>Active Internet connections (only servers)<br/>Proto Recv-Q Send-Q Local Address &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Foreign Address &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; State &nbsp; &nbsp; &nbsp;<br/>tcp &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp;0 0.0.0.0:199 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0.0.0.0:* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LISTEN &nbsp; &nbsp; &nbsp;<br/>tcp &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp;0 0.0.0.0:80 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0.0.0.0:* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LISTEN &nbsp; &nbsp; &nbsp;<br/>tcp &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp;0 0.0.0.0:21 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0.0.0.0:* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LISTEN &nbsp; &nbsp; &nbsp;<br/>tcp &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp;0 0.0.0.0:22 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0.0.0.0:* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LISTEN &nbsp; &nbsp; &nbsp;<br/>tcp &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp;0 127.0.0.1:25 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0.0.0.0:* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LISTEN &nbsp; &nbsp; &nbsp;<br/>udp &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp;0 0.0.0.0:161 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0.0.0.0:* &nbsp; <br/><br/>服务启动时也不报错，就是看不到varnish监听的端口，如何debug? 实在看不出什么问题，<br/>请张老师指点一下！
]]>
</description>
</item><item>
<link>http://zyan.cc/post/313/#blogcomment525</link>
<title><![CDATA[[评论] 使用Varnish代替Squid做网站缓存加速器的详细解决方案[原创]]]></title> 
<author>coffee &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 21 Dec 2007 08:49:42 +0000</pubDate> 
<guid>http://zyan.cc/post/313/#blogcomment525</guid> 
<description>
<![CDATA[ 
	(1)、Varnish通过反向代理请求后端IP为192.168.0.5，端口为80的web服务器；<br/>backend.host &nbsp;如果有多台的话 是否也可以象 SQUID 那样设置在 hosts文件里面，<br/>(3)、Varnish对域名为blog.s135.com的请求进行处理，非blog.s135.com域名的请求则返回“Zhang Yan Cache Server”； &nbsp; <br/>squid 可以根据到目的IP是否符合在判断是否可以使用 这样就不用判断域名 不知道在 Varnish 也可以这样设置
]]>
</description>
</item><item>
<link>http://zyan.cc/post/313/#blogcomment527</link>
<title><![CDATA[[评论] 使用Varnish代替Squid做网站缓存加速器的详细解决方案[原创]]]></title> 
<author>阿木 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sun, 23 Dec 2007 00:34:33 +0000</pubDate> 
<guid>http://zyan.cc/post/313/#blogcomment527</guid> 
<description>
<![CDATA[ 
	张老师，我服务器上用varnish+nginx在同一台机器上跑，运行没有三分钟的时候，就开始卡，仍后几乎网页打不开。不知道什么原因，而我在本地虚拟环境测试一点问题都没有，只是本地的是varnish+apache,而线上服务器是varnish+nginx，有点不解，请张老师指点一下，有遇到想关问题的朋友指点一下！<br/>原来本地是squid+nginx速度飞快，现在是varnish+nginx就卡得不行...
]]>
</description>
</item><item>
<link>http://zyan.cc/post/313/#blogcomment553</link>
<title><![CDATA[[评论] 使用Varnish代替Squid做网站缓存加速器的详细解决方案[原创]]]></title> 
<author>varnish &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 04 Jan 2008 09:41:29 +0000</pubDate> 
<guid>http://zyan.cc/post/313/#blogcomment553</guid> 
<description>
<![CDATA[ 
	问下varnish 怎么配置 泛域名 的主机，我很很多二级域名，比如 xx.abc.com &nbsp; &nbsp;，一个一个加好麻烦。。。squid 或者nginx 都支持 .abc.com 的
]]>
</description>
</item>
</channel>
</rss>