varnish安装与测试
部分内容转自:http://hi.baidu.com/supermfc/blog/item/21e74638f1f576feb311c71b.html
1、Pcre的安装 (PERL兼容正则表达式库)
wget http://cdnetworks-kr-1.dl.sourceforge.net/project/pcre/pcre/8.02/pcre-8.02.tar.bz2tar zxvf pcre-8.02.tar.gzcd pcre-8.02./configure --libdir=/usr/libmake && make install
wget http://cdnetworks-kr-2.dl.sourceforge.net/project/varnish/varnish/2.1.3/varnish-2.1.3.tar.gztar zxvf varnish-2.1.1cd varnish-2.1.1./configure --prefix=/usr/local/varnishmake && make install
usage: varnishd [options] -a address:port # HTTP listen address and port -b address:port # backend address and port # -b <hostname_or_IP> # -b '<hostname_or_IP>:<port_or_service>' -C # print VCL code compiled to C language -d # debug -f file # VCL script -F # Run in foreground -h kind[,hashoptions] # Hash specification # -h simple_list # -h classic [default] # -h classic,<buckets> -i identity # Identity of varnish instance -l bytesize # Size of shared memory log -M address:port # CLI-master to connect to. -n dir # varnishd working directory -P file # PID file -p param=value # set parameter -s kind[,storageoptions] # Backend storage specification # -s malloc # -s file [default: use /tmp] # -s file,<dir_or_file> # -s file,<dir_or_file>,<size> # -s file,<dir_or_file>,<size>,<granularity> -t # Default TTL -S secret-file # Secret file for CLI authentication -T address:port # Telnet listen address and port -V # version -w int[,int[,int]] # Number of worker threads # -w <fixed_count> # -w min,max # -w min,max,timeout [default: -w2,500,300] -u user # Priviledge separation user id
sbin/varnishd -a :8080 -n logs -f etc/varnish/default.vcl -T localhost:6082 -p thread_pools 8 -p first_byte_timeout 20 -p between_bytes_timeout 10m -s malloc,100m
backend test { .host = "102.21011.81.309"; .port = "8080"; .probe = { .url = "/index.jsp"; .interval = 5s; .timeout = 8 s; .window = 5; .threshold = 3; }}director baz1 round-robin{ { .backend = test; }}sub vcl_recv { set req.backend = baz1; /* add x-forwarded-for */ if (req.http.x-forwarded-for) { set req.http.X-Forwarded-For = req.http.X-Forwarded-For ", " client.ip; } else { set req.http.X-Forwarded-For = client.ip; } /* ignore invalid request */ if (req.request != "GET" && req.request != "HEAD" && req.request != "PUT" && req.request != "POST" && req.request != "TRACE" && req.request != "OPTIONS" && req.request != "DELETE") { /* Non-RFC2616 or CONNECT which is weird. */ return (pipe); } if (req.request != "GET" && req.request != "HEAD") { /* We only deal with GET and HEAD by default */ return (pass); } if (req.http.Authorization || req.http.Cookie) { /* Not cacheable by default */ return (pass); } /* // need cache turn on return (lookup);*/ return (pass);}sub vcl_pipe { set req.http.connection = "close"; return (pipe);}sub vcl_deliver { set resp.http.Server = "是"; return (deliver);}Benchmarking 192.168.1.128(be patient)Completed 10000 requestsCompleted 20000 requestsCompleted 30000 requestsCompleted 40000 requestsCompleted 50000 requestsCompleted 60000 requestsCompleted 70000 requestsCompleted 80000 requestsCompleted 90000 requestsCompleted 100000 requestsFinished 100000 requestsServer Software: Apache-Coyote/1.1Server Hostname: 10.210.71.30Server Port: 8080Document Path: /index.jspDocument Length: 8248 bytesConcurrency Level: 1000Time taken for tests: 97.820 secondsComplete requests: 100000Failed requests: 0Write errors: 0Total transferred: 838287304 bytesHTML transferred: 825560634 bytesRequests per second: 1022.28 [#/sec] (mean)Time per request: 978.205 [ms] (mean)Time per request: 0.978 [ms] (mean, across all concurrent requests)Transfer rate: 8368.80 [Kbytes/sec] receivedConnection Times (ms) min mean[+/-sd] median maxConnect: 0 575 1925.0 108 45128Processing: 9 377 624.8 224 13631Waiting: 7 223 501.8 107 13230Total: 12 953 2061.8 339 45373Percentage of the requests served within a certain time (ms) 50% 339 66% 360 75% 415 80% 620 90% 3230 95% 3439 98% 9209 99% 9459 100% 45373 (longest request)