Varnish Excellent cache server

Source: Internet
Author: User
Tags varnish haproxy

"Remove interference environment" shutdown: Native Httpd,haproxy,nginx iptables



"Varnish Excellent cache server"

Features reverse proxy, load balancing, health check


Connection is weaker than nginx,nginx varnish reverse proxy good

See

Curl-i Www.sohu.comCache-Control:no-transform, max-age=120


Installation

VARNISH-3.0.4-1.EL6.X86_64.RPMVARNISH-LIBS-3.0.4-1.EL6.X86_64.RPMRPM-IVH varnish-*

"Start Service"

Service Varnish Restart


"Port Monitoring"

[[email protected] home]# netstat -tnlp | grep  "var" tcp         0      0 0.0.0.0:6081                 0.0.0.0:*                    LISTEN       9876/varnishd       tcp         0      0 127.0.0.1:6082               0.0.0.0:*                    LISTEN       9875/varnishd       tcp         0      0 :::6081                      :::*                          LISTEN       9876/varnishd

"Use native-based memory for cache size"

Vim/etc/sysconfig/varnish


Modify

varnish_storage_size=1g## # backend STORAGE specificationvarnish_storage= "File,${varnish_storage_file},${varnish_ Storage_size} "********************* modified to **************************************************varnish_storage_size= 256m## # Backend Storage specificationvarnish_storage= "File,${varnish_storage_file},${varnish_storage_size}" Varnish_storage= "Malloc,${varnish_storage_size}" ************************************************************** ***************

"Restart Services" service varnish restart


"Native cache, background Web service"

Vim/etc/varnish/default.vcl

Modified

Backend default {. Host = "127.0.0.1"; . Port = "80";}  Backend default {. Host = "192.168.3.5"; . Port = "80";} #service Varnish Restart

"Make sure the background Web service is started"

http://172.16.0.102 failure http://172.16.0.102:6081 this is normal.

"Back two when load balancing"

Backup

Cp/etc/varnish/default.vcl/etc/varnish/default.vcl.bak

Modify

Vim/etc/varnish/default.vcl

Random access, plus weights

backend server1 {  .host =  "192.168.3.5";  .port =  "80";} backend server2 {  .host =  "192.168.3.6";  .port =  "80";} director myload random {        {                 .backend = server1;                 .weight =  3;        }        {                 .backend  = server2;                 .weight = 1;        }}sub vcl_recv {       &nbsP; set req.backend = myload;} 

"Remove interference environment" shutdown: Native Httpd,haproxy,nginx iptables

"Test OK" http://172.16.0.102:6081/

"Varnishadm Management"

Varnishadm-t 127.0.0.1:6082-s/etc/varnish/secret

Help, quite quit

"Enable log Management" is not recommended to turn on varnish log, IO operation affects disk

Service Varnishlog Restartservice VARNISHNCSA Restartcat/var/log/varnish/varnishncsa.log

Visit http://172.16.0.102:6081/Test

172.16.0.101--[30/may/2015:09:44:53 +0800] "GET http://172.16.0.102:6081/HTTP/1.1"-"" "mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) gecko/20100101 firefox/38.0 "




---------------------------------------------------------------------




Varnish Excellent cache server

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.