Varnish 小記


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
ulimit -HSn 131072
ulimit -HSc unlimited

vim /etc/sysctl.conf

net.ipv4.ip_local_port_range = 1024 65536
net.core.rmem_max=16777216
net.core.wmem_max=16777216
net.ipv4.tcp_rmem=4096 87380 16777216
net.ipv4.tcp_wmem=4096 65536 16777216
net.ipv4.tcp_fin_timeout = 3
net.ipv4.tcp_tw_recycle = 1
net.core.netdev_max_backlog = 30000
net.ipv4.tcp_no_metrics_save=1
net.core.somaxconn = 262144
net.ipv4.tcp_syncookies = 0
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2

sysctl -p

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
./configure --prefix=/usr/local/varnish
make
make install

cp /usr/local/varnish/etc/varnish/default.vcl /usr/local/varnish/etc/varnish/default.vcl.origin
vim /usr/local/varnish/etc/varnish/default.vcl

/usr/local/varnish/sbin/varnishd -u www -g www -f /usr/local/varnish/etc/varnish/default.vcl -s malloc,256m -T 127.0.0.1:6082 -a 0.0.0.0:80