java技术研究

统计

留言簿(3)

阅读排行榜

评论排行榜

Varnish研究(转)

麻烦你再研究一下Varnish,我所希望了解的事项是:
1、 能否设置到URL级别。
你可以以针对“2012潮流”页面的这两个链接进行测试:
[IP]:[Port]/trend.html
[IP]:[Port]/trend/findViewHotItemsAjax.html
注意两个链接后面均可能存在参数,
比如[IP]:[Port]/trend/findViewHotItemsAjax.html?ref=1&np=1
这些参数是查询条件。

可以支持,通过正则表达式区分路径,可以通配到URL级别的访问,在定义了路径后设置一些属性。

2、 能否支持通配符
比如
[IP]:[Port]/trend*

支持

3、能否就每一个独立配置设置独立的缓存时间?
我指的每一个独立配置是指比如某个URL。
比如 /trend.html 缓存4分钟,而另外一个/trend/newest.html则缓存2分钟。

如果不行,那么Varnish的缓存时间允许怎么设置?
 
可以做到对于不同路径的缓存时间特性设置,但是需要在VCL语言中编写,类似C的语言,按照业务需求来写配置文件和处理流程……

4、 清除Varnish缓存的命令是?
方便做build后,人工或者通过脚本来调用该命令清除Varnish缓存。
首先是要设置了管理的IP,通过Varnish管理端口,使用正则表达式批量清除缓存:
(1)、例:清除类似
http://www.elain.org/download/111.html的URL地址):
/elain/apps/varnish/bin/varnishadm -T 172.16.2.223:3500 url.purge /download/
(2)、例:清除类似
http://www.elain.org/dl 的URL地址:
/elain/apps/varnish/bin/varnishadm -T 172.16.2.223:3500 url.purge w*$
(3)、例:清除所有缓存:
/elain/apps/varnish/bin/varnishadm -T 172.16.2.223:3500 url.purge *$

5、 如何监控Varnish,有可视化界面查看运行状态,命中率等等吗?
1、查看Varnish服务器连接数与命中率:
/elain/apps/varnish/bin/varnishstat
cache_hit是命中率
2、通过Varnish管理端口进行管理:
用help看看可以使用哪些Varnish命令:
/elain/apps/varnish/bin/varnishadm -T 172.16.2.223:3500 help
[root@vanish ~]# /elain/apps/varnish/bin/varnishadm -T 172.16.2.223:3500 help
help [command]
ping [timestamp]
auth response
quit
banner
status
start
stop
stats
vcl.load <configname> <filename>
vcl.inline <configname> <quoted_VCLstring>
vcl.use <configname>
vcl.discard <configname>
vcl.list
vcl.show <configname>
param.show [-l] [<param>]
param.set <param> <value>
purge.url <regexp>
purge <field> <operator> <arg> [&& <field> <oper> <arg>]...
purge.list

6、 有响应时间统计的报表吗?
比如对某个URL设置了缓存,那么我能否获得该URL的响应时间统计。
可以通过webbench测试URL的相应时间。
root@zhouda webbench-1.5]# webbench -c 100 -t 60 http://10.112.5.219/info.php
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET
http://10.112.5.219/info.php
100 clients, running 60 sec.
Speed=695 pages/min, 612347 bytes/sec.
Requests: 695 susceed, 0 failed.
每秒钟响应请求数:695 pages/min,每秒钟传输数据量612347 bytes/sec.

CRONTAB利做统计然后通过程序汇总成图表

7、 其它的
如果你在研究过程中,发现有比较有用的功能,也整理一下告诉我。

http://www.oschina.net/question/222919_57985
http://www.oschina.net/question/17_6406
http://www.discuz.net/thread-730015-1-1.html
https://www.varnish-cache.org/docs
https://www.varnish-cache.org/docs/3.0/tutorial/vcl.html

另外,目前最新的测试版本在:http://42.121.12.4 

posted on 2012-07-24 17:34 小秦 阅读(915) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: