安装、测试 Varnish

Varnish的安装依赖pcre
下载获得最新版本的pcre
安装pcre

> tar -xjvf pcre-8.32.tar.bz2
> cd pcre-8.32
> ./configure --prefix=/usr/local/pcre/
> make && make install


为Varnish准备目录

> mkdir data
> mkdir data/varnish
> mkdir data/varnish/cache
> mkdir data/varnish/log


下载Varnish,安装

> wget http://repo.varnish-cache.org/source/varnish-3.0.3.tar.gz
> tar -zxvf varnish-3.0.3.tar.gz
> cd varnish-3.0.3
> export PKG_CONFIG_PATH=/usr/local/pcre/lib/pkgconfig
> ./configure --prefix=/usr/local/varnish --enable-dependency-trackin --enable-debugging-symbols --enable-developer-warnings
> make && make install
> cp redhat/varnish.initrc /etc/init.d/varnish
> cp redhat/varnish.sysconfig /etc/sysconfig/varnish


注:export PKG_CONFIG_PATH=/usr/local/pcre/lib/pkgconfig 为pcre的安装目录,可根据pcre的实际安装目录自定义。

创建简单配置文件
在[varnish path]/etc目录下创建vcl.conf的配置文件,内容如下

backend default {
.host = "127.0.0.1"; // 可用hostname,IP,指向需要代理的web server
.port = "80";
}


启动

./sbin/varnishd -f /usr/local/varnish/etc/vcl.conf -s malloc,2G -w 512


测试
在浏览器上访问Varnish所在机器的IP,如果配置正确,则会跳转到Varnish代理的Web Server。

管理工具
[varnish path]/bin目录下多个实用工具:
1), varnishstat,可查看miss,hit等实施情况。
2), varnishtop,可查看varnish被使用的top。

关闭

pkill varnish


--------------------------------------------------------------------------------
华丽的分割线,下面通过Web Bench对Varnish做压力测试。
--------------------------------------------------------------------------------
Varnish部署的机器
Dell 1950

Web Bench部署的机器
Dell 620

千兆交换机。

---------------------------------------------------------
测试文件大小:288bytes

webbench -c 5000 -t 30

测试结果:
Speed=1904732 pages/min, 18751338 bytes/sec.
Requests: 952366 susceed, 0 failed.

测试分析:
Varnish服务器的CPU达到400%左右
Varnish的监控显示,cache_hit率为100%
Web Bench服务器的网络input达到 57526.0 kbits/sec

说明,varnish服务器的cup跑到极限,Web Bench的网络正常。


----------------------------------------------------------
测试文件大小:33.5KB
webbench -c 5000 -t 30

测试结果:
Speed=225220 pages/min, -24989308 bytes/sec.
Requests: 101581 susceed, 11029 failed.

测试分析:
Varnish服务器的CPU达到70%左右
Varnish的监控显示,cache_hit率为100%
Web Bench服务器的网络input达到 955176.0 kbits/sec

说明,varnish服务器的CUP正常,Web Bench的网络带宽被占满。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值