免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 6407 | 回复: 12
打印 上一主题 下一主题

[proxy] varnish 2.0 vcl 请教 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-12-08 16:28 |只看该作者 |倒序浏览
我在redhat as4下安装了varnish 2.0 ,使用以下配置.访问varnish.chinarenservice.cn就指向varnish 2.0,再由varnish指向后端的一台apache.可是访问非常慢!

vcl.conf:
backend varnish {
        .host = "10.167.26.3";
        .port = "80";
        }

acl purge {
        "localhost";
        "127.0.0.1";
        "10.167.0.0"/16;
}

sub vcl_recv {
        if (req.request == "PURGE") {
        if (!client.ip ~ purge) {
                error 405 "Not allowed.";
        }
                lookup;
}

        if (req.http.host ~ "^varnish.chinarenservice.cn") {
                set req.backend = varnish;
        if (req.request != "GET" && req.request != "HEAD") {
        pipe;
}
        else {
                lookup;
                }
}
        else {
                error 404 "the server is wrong!";
                lookup;
                }
}

sub vcl_hit {
        if (req.request == "PURGE") {
                set obj.ttl = 0s;
                error 200 "Purged.";
                }
}

sub vcl_miss {
        if (req.request == "PURGE") {
                error 404 "Not in cache.";
                }
}

sub vcl_fetch {
        if (req.request == "GET" && req.url ~ "\.(txt|js|jpg|gif|css|)$") {
                set obj.ttl = 3600s;
                }
        else {
                set obj.ttl = 30d;
                }
}

varnish_error.JPG (82.56 KB, 下载次数: 43)

varnish_error.JPG

论坛徽章:
0
2 [报告]
发表于 2008-12-08 16:42 |只看该作者
现在的现像为打开页面非常的慢,IE的进度条就在38%那里不动了.以下为varnish 日志:

varnish - - [08/Dec/2008:08:22:58 +0000] "GET http://varnish.chinarenservice.cn:88/cacti/index.php HTTP/1.1" 200 1214 "-" "Moz
illa/4.0 (compatible; MSIE 7.0; Windows NT 5.2; Avant Browser; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; C
IBA)"
10.167.26.160 - - [03/Dec/2008:00:24:01 +0800] "GET http://varnish.chinarenservice.cn:88/cacti/index.php HTTP/1.1" 200 1214 "-
" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; Avant Browser; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506
.30; CIBA)"
127.0.0.1 - - [08/Dec/2008:08:23:03 +0000] "GET http://varnish.chinarenservice.cn:88/favicon.ico HTTP/1.1" 404 209 "-" "Avant
Browser (http://www.avantbrowser.com)"
10.167.26.160 - - [03/Dec/2008:00:24:03 +0800] "GET http://varnish.chinarenservice.cn:88/favicon.ico HTTP/1.1" 404 209 "-" "Av
ant Browser (http://www.avantbrowser.com)"
127.0.0.1 - - [00/Jan/1900:00:00:00 +0000] "(null) (null) (null)" (null) - "-" "-"
varnish - - [08/Dec/2008:08:23:25 +0000] "GET http://varnish.chinarenservice.cn:88/cacti/index.php HTTP/1.1" 200 1214 "-" "Moz
illa/4.0 (compatible; MSIE 7.0; Windows NT 5.2; Avant Browser; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; C
IBA)"
10.167.26.160 - - [03/Dec/2008:00:24:17 +0800] "GET http://varnish.chinarenservice.cn:88/cacti/index.php HTTP/1.1" 200 1214 "-
" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; Avant Browser; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506
.30; CIBA)"
127.0.0.1 - - [08/Dec/2008:08:23:27 +0000] "GET http://varnish.chinarenservice.cn:88/cacti/index.php HTTP/1.1" 200 1214 "-" "M
ozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; Avant Browser; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30;
CIBA)"
10.167.26.160 - - [03/Dec/2008:00:24:18 +0800] "GET http://varnish.chinarenservice.cn:88/cacti/index.php HTTP/1.1" 200 1214 "-
" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; Avant Browser; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506
.30; CIBA)"
127.0.0.1 - - [08/Dec/2008:08:23:29 +0000] "GET http://varnish.chinarenservice.cn:88/cacti/index.php HTTP/1.1" 200 1214 "-" "M
ozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; Avant Browser; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30;
CIBA)"
10.167.26.160 - - [03/Dec/2008:00:24:19 +0800] "GET http://varnish.chinarenservice.cn:88/cacti/index.php HTTP/1.1" 200 1214 "-
" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; Avant Browser; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506
.30; CIBA)"
127.0.0.1 - - [00/Jan/1900:00:00:00 +0000] "(null) (null) (null)" (null) - "-" "-"
varnish - - [08/Dec/2008:08:27:13 +0000] "GET http://varnish.chinarenservice.cn:88/cacti/index.php HTTP/1.1" 200 1214 "-" "Moz
illa/4.0 (compatible; MSIE 7.0; Windows NT 5.2; Avant Browser; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; C
IBA)"
10.167.26.160 - - [03/Dec/2008:00:26:37 +0800] "GET http://varnish.chinarenservice.cn:88/cacti/index.php HTTP/1.1" 200 1214 "-
" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; Avant Browser; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506
.30; CIBA)"

论坛徽章:
0
3 [报告]
发表于 2008-12-10 15:59 |只看该作者
有人使用过2.0版本不?

论坛徽章:
0
4 [报告]
发表于 2008-12-10 17:37 |只看该作者
我用了,但我只对静态内容做了缓存,跑着没啥问题。
uptime                 202859          .   Child uptime
client_conn           1268984         6.26 Client connections accepted
client_req            1167675         5.76 Client requests received
cache_hit              927062         4.57 Cache hits
cache_hitpass           32255         0.16 Cache hits for pass
cache_miss             195466         0.96 Cache misses
backend_conn           239170         1.18 Backend connections success
backend_unhealthy            0         0.00 Backend connections not attempted
backend_busy                0         0.00 Backend connections too many
backend_fail               32         0.00 Backend connections failures
backend_reuse          182097         0.90 Backend connections reuses
backend_recycle        195437         0.96 Backend connections recycles
backend_unused              0         0.00 Backend connections unused

或许试试trunk版本?

论坛徽章:
0
5 [报告]
发表于 2008-12-11 10:27 |只看该作者

回复 #4 minuteman 的帖子

呵呵,看来老大天天来这里转转呢,感谢回复啊

论坛徽章:
0
6 [报告]
发表于 2008-12-11 11:10 |只看该作者
我下载了Trunk R3460
然后在执行autogen.sh
再执行configure
再make就一直在那里循环,永远也不完

checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... 64
checking for _LARGE_FILES value needed for large files... no
checking for clock_gettime... yes
checking for epoll_ctl... yes
checking for port_create... no
checking for tclsh... tclsh
checking whether SO_RCVTIMEO works... yes
checking whether SO_SNDTIMEO works... yes
configure: creating ./config.status
/bin/sh ./config.status
config.status: creating Makefile
config.status: creating bin/Makefile
config.status: creating bin/varnishadm/Makefile
config.status: creating bin/varnishd/Makefile
config.status: creating bin/varnishlog/Makefile
config.status: creating bin/varnishhist/Makefile
config.status: creating bin/varnishncsa/Makefile
config.status: creating bin/varnishreplay/Makefile
config.status: creating bin/varnishstat/Makefile
config.status: creating bin/varnishtest/Makefile
config.status: creating bin/varnishtop/Makefile
config.status: creating doc/Makefile
config.status: creating etc/Makefile
config.status: creating include/Makefile
config.status: creating lib/Makefile
config.status: creating lib/libvarnish/Makefile
config.status: creating lib/libvarnishapi/Makefile
config.status: creating lib/libvarnishcompat/Makefile
config.status: creating lib/libvcl/Makefile
config.status: creating lib/libjemalloc/Makefile
config.status: creating man/Makefile
config.status: creating redhat/Makefile
config.status: creating varnishapi.pc
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands
make: Warning: File `Makefile.am' has modification time 5.8e+05 s in the future
cd . && /bin/sh /oracle/varnish-cache/missing --run aclocal-1.9
cd . && /bin/sh /oracle/varnish-cache/missing --run automake-1.9 --foreign
cd . && /bin/sh /oracle/varnish-cache/missing --run autoconf

论坛徽章:
0
7 [报告]
发表于 2008-12-11 11:28 |只看该作者

回复 #4 minuteman 的帖子

果真是版本问题,感谢感谢!不过我在官方下载的那个版本也是有问题的!我使用你博客早前提供的那个R2860版本正常了!

0+00:03:43                                                                                     /usr/local/varnishtrunk/cache/
Hitrate ratio:       10       12       12
Hitrate avg:     0.2617   0.2406   0.2406

        2046         0.00         9.17 Client connections accepted
        2115         0.00         9.48 Client requests received
        1032         0.00         4.63 Cache hits
        1016         0.00         4.56 Cache hits for pass
          46         0.00         0.21 Cache misses
        1081         0.00         4.85 Backend connections success
           2         0.00         0.01 Backend connections failures
          43         0.00         0.19 Backend connections reuses
          66         0.00         0.30 Backend connections recycles
           0         0.00         0.00 Backend connections unused
           2          .            .   N struct srcaddr
           0          .            .   N active struct srcaddr
        1001          .            .   N struct sess_mem
           1          .            .   N struct sess
          46          .            .   N struct object
         188          .            .   N struct objecthead
         100          .            .   N struct smf
           5          .            .   N small free smf
           3          .            .   N large free smf
           0          .            .   N struct vbe_conn
         142          .            .   N struct bereq
           0          .            .   N worker threads
         142         0.00         0.64 N worker threads created
           0         0.00         0.00 N worker threads not created
           0         0.00         0.00 N worker threads limited
           0         0.00         0.00 N queued work requests
           0         0.00         0.00 N overflowed work requests
           0         0.00         0.00 N dropped work requests
           1          .            .   N backends
           0          .            .   N expired objects
           0          .            .   N LRU nuked objects
           0          .            .   N LRU saved objects
          27          .            .   N LRU moved objects
           0          .            .   N objects on deathrow
           0         0.00         0.00 HTTP header overflows
           0         0.00         0.00 Objects sent with sendfile
        2076         0.00         9.31 Objects sent with write
           0         0.00         0.00 Objects overflowing workspace
        2046         0.00         9.17 Total Sessions
        2115         0.00         9.48 Total Requests

论坛徽章:
0
8 [报告]
发表于 2008-12-11 12:55 |只看该作者
看来以后不管在哪个环境部属上,如果遇到问题一下子解决不了,还是多换换几个版本测试一下。

论坛徽章:
0
9 [报告]
发表于 2008-12-11 15:47 |只看该作者
也许可以试试2.02,应该是一个比较稳定的版本了。
trunk3460在我的机器上编译运行都没有问题啊,刚才特地试了一下
uptime                    141          .   Child uptime
client_conn              3720        26.38 Client connections accepted
client_req               3650        25.89 Client requests received
cache_hit                2859        20.28 Cache hits
cache_hitpass              75         0.53 Cache hits for pass
cache_miss                713         5.06 Cache misses
backend_conn              789         5.60 Backend connections success
backend_unhealthy            0         0.00 Backend connections not attempted
backend_busy                0         0.00 Backend connections too many
backend_fail                0         0.00 Backend connections failures
backend_reuse             679         4.82 Backend connections reuses
backend_recycle           713         5.06 Backend connections recycles
backend_unused              0         0.00 Backend connections unused

[ 本帖最后由 minuteman 于 2008-12-11 16:01 编辑 ]

论坛徽章:
0
10 [报告]
发表于 2008-12-12 14:55 |只看该作者
奇怪了,难不成我的小乌龟下载时有问题?对我没有把那个生成的SVN目录删除就开始编译的,不知道是否有影响?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP