SlideShare une entreprise Scribd logo
1  sur  48
Télécharger pour lire hors ligne
Varnish Cache
Presented by Ron
1
Prerequisites and Goals
2
—  Prerequisites:
◦  Basic understanding of HTTP and related
internet protocols.
◦  Basic Linux Administration Commands.
—  Goals:
◦  Thorough understanding ofVarnish.
◦  Understanding of howVCL works and how to
use it.
◦  Know how varnish works with Drupal and
Wordpress.
◦  Debug using varnish tools.
Varnish details
—  What isVarnish?
—  Installation and Configuration
—  Demo
—  Varnish log tools
3
4
What is varnish? (from customer point of view)
5
https://www.youtube.com/watch?v=x7t2Sp174eI
What isVarnish?
—  Varnish is a reverse
HTTP proxy.
—  Sometimes referred as
HTTP Accelerator
or Web Accelerator
—  Varnish Configuration
Language (VCL) is
lightning fast and
allows administrators
to set the policy that
they wants.
6
What isVarnish?
7
Varnish with multiple web servers
8
Varnish with multiple web servers
9
Varnish History
2005: Ideas! Verdens Gang (www.vg.no)
2006: Work began.
Redpill Linpro -> Poul-
Henning Kamp.
2006: Varnish 1.0
released
2008: Varnish 2.0
released
2010:
Varnish Software is born as a
spin-off to Redpill Linpro AS.
2011:Varnish 3.0 released
10
Varnish Design Principles
—  Varnish is designed to run on modern
hardware under real work-loads and to
solve real problems.Varnish does not
cater to the “I want to make varnish run
on my 486 just because”-crowd. If it does
work on your 486, then that’s fine, but
that’s not where you will see our focus.
Nor will you see us sacrifice performance
or simplicity for the sake of niche use-
cases that can easily be solved by other
means - like using a 64-bit OS.
11
Varnish Installation
—  To use the varnish-cache.org repository, run
rpm --nosignature -i http://
repo.varnish-cache.org/redhat/
varnish-3.0/el5/noarch/
varnish-
release-3.0-1.noarch.rpm
—  and then run
yum install varnish
—  The --no-signature is only needed on initial
installation, since theVarnish GPG key is not
yet in the yum key ring
12
Varnish Configuration
File Usage
/etc/sysconfig/varnish
Used for parameters and command line arguments.
When you change this, you need to
run service varnishrestart .
For Debian (Ubuntu): /etc/default/varnish instead.
/etc/varnish/default.vcl
TheVCL file.You can change the file name by
editing /etc/default/varnish if you want to, but it’s
normal to use the default name.This contains your
VCL and backend-definitions.After changing this,
you can run eitherservice varnish reload, which will
not restartVarnish, or you can
run service varnish restart, which empties the
cache.
13
Demo
—  Check: apache is running.
—  Change Apache’s ports from 80 to 8081, in httpd.conf
and vhosts.conf.
—  Modify theVarnish configuration file soVarnish listens
on port 80 and uses 127.0.0.1:8081 as the backend.
—  The end result should be:
14
Service Result Related config-files
Apache
Answers on
port 8081
httpd.conf &
vhosts.conf
Varnish Answers on port 80 /etc/sysconfig/varnish
Varnish
Talks to apache
on 127.0.0.1:8081
/etc/varnish/default.vcl
An special case
—  Our dev server has one varnish installed
and multiple applications running.
—  At present, multiple applications shares
the same vcl file.
—  Two devs may need to debug varnish in
two different application at the same
time.
—  Varnishlog or varnishstat will show a
combined statistics for all sites.
15
Solution
—  Use different vcl for different sites.
◦  Varnish loads vcl in compile time.
◦  Combining all sites vcl into one – not a good
solution because varnishlog tools will still
show a combined statistics.
◦  Install varnish in a different machine, a
vbox and point to dev server as
backend.
16
Varnish Log tools
—  varnishlog
—  varnishstat
17
varnishlog
18
varnishlog tag examples
Tag Example value Description
RxURL /index.html
Varnish received a URL, the only scenario where
Varnish receives a URL is from a client, thus: a client
sent us this URL.
TxURL /index.html
Varnish sent a URL, the only scenario whereVarnish
sends a URL is to a backend, thus: this is part of a
backend request.
RxHeader
Host: www.example
.com
A received header. Either a request header or a
response header backend. Since we know the Host-
header is a request header, we can assume it’s from a
client.
TxHeader Host: example.com
A headerVarnish sent. Either a request header or a
response header. Since we know the Host-header is a
request header we can assume it is a headerVarnish
sent to a backend.
RxRequest GET
Received request method.Varnish only receives
requests from clients.
TxStatus 200 Status codeVarnish sent. Only sent to clients.
RxStatus 500 Status codeVarnish received from a backend.
19
varnishlog options
-b only show traffic to backend
-c only show traffic to client
-O do not group by request
-m <tag:filter>
Show requests where the <tag>
matches <filter>. Example: varnishlog -
m TxStatus:500 to show requests
returned to a client with status code
500.
-n <name>
The name of the varnish instance, or
path to the shmlog. Useful for running
multiple instances ofVarnish.
-i <tag[,tag][..]> Only show the specified tags.
-I <regex>
Filter the tag provided by -i, using the
regular expression for -I.
20
varnishlog options
Command Description
varnishlog -c -m RxURL:/specific/url/
Only show client-requests for the url /
specific/url
varnishlog -O -i ReqEnd
Only show the ReqEnd tag. Useful to
spot sporadic slowdown.Watch the
last three values of it.
varnishlog -O -i TxURL
Only show the URLs sent to backend
servers. E.g: Cache misses and content
not cached.
varnishlog -O -i RxHeader -I Accept-
Encoding
Show the Accept-Encoding response
header.
varnishlog -b -m TxRequest:POST
Show backend requests using the
POST method.
varnishlog -O -i TxURL,TxHeader
Only shows the URL sent to a backend
server and all headers sent, either to a
client or backend.
21
varnishstat
—  Representation of the general health of
Varnish.
22
varnishstat
23
varnishstat – cache_hit and
cache_miss
—  Cache-hit
◦  There is a cache-hit when
Varnish returns a page from
its cache instead of
forwarding the request to
the origin server.
—  Cache-miss
◦  There is a cache-miss
whenVarnish has to forward
the request to the origin
server so the page can be
serviced.
24
varnishstat
— Only counters with a value different
from 0 is shown by default.
— Varnishstat –l;
— varnishstat –f field1,
field2;
— Demo
25
varnishstat – some sp. coutners
Counter Description
client_drop This counts clients varnish had to drop due to resource shortage. It should be 0.
cache_hitpass
Hitpass is a special type of cache miss. It will be covered in theVCL chapters, but it can often be
used to indicate if something the backend sent has triggered cache misses.
backend_fail
Counts the number of requests to backends that fail. Should have a low number, ideally 0, but it’s
not unnatural to have backend failures once in a while. Just make sure it doesn’t become the normal
state of operation.
n_object
Counts the number of objects in cache.You can have multiple variants of the same object
depending on your setup.
n_wrk, n_wrk_que
ued, n_wrk_drop
Thread counters. During normal operation, the n_wrk_queued counter should not grow. Once
Varnish is out of threads, it will queue up requests and n_wrk_queued counts how many times this
has happened. Once the queue is full, varnish starts dropping requests without
answering. n_wrk_drop counts how many times a request has been dropped. It should be 0.
n_lru_nuked
Counts the number of objects varnish has had to evict from cache before they expired to make
room for other content. If it is always 0, there is no point increasing the size of the cache since the
cache isn’t full. If it’s climbing steadily a bigger cache could improve cache efficiency.
esi_errors, esi_war
nings
If you use Edge Side Includes (ESI), these somewhat hidden counters can be helpful to determine if
the ESI syntax the web server is sending is valid.
uptime
Varnish’ uptime. Useful to spot ifVarnish has been restarted, either manually or by bugs. Particularly
useful if a monitor tool uses it.
26
varnishadm – the mgmt. interface.
—  Change parameters without restarting
varnish
—  ReloadVCL
—  View the most up-to-date documentation
for parameters
—  varnishadm help
27
HTTP Protocol
—  A request consists of a request method,
headers and an optional request body.
—  A response consists of a response status,
headers and an optional response body.
—  Multiple requests can be sent over a
single connection, in serial.
—  Clients will open multiple connections to
fetch resources in parallel.
28
HTTP Protocol - Requests
—  Standard request methods are: 
GET, POST, HEAD, OPTIONS, PUT, DELETE, TRACE, or CONNECT.
◦  This is followed by a URI, e.g: /img/image.png or /index.html
◦  Usually followed by the HTTP version
◦  A new-line (CRLF), followed by an arbitrary amount of CRLF-separated headers (Accept-
Language, Cookie, Host, User-Agent, etc).
◦  A single empty line, ending in CRLF.
◦  An optional message body, depending on the request method.
—  Each request has the same, strict and fairly simple pattern. A request method
informs the web server what sort of request this is: Is the client trying to
fetch a resource (GET), or update some data(POST)? Or just get the headers of a
resource (HEAD)?
—  There are strict rules that apply to the request methods. For instance,
a GET request can not contain a request body, but a POST request can.
—  Similarly, a web server can not attach a request body to a response to a HEAD body.
29
HTTP Protocol - Requests
30
HTTP Protocol - Response
—  A HTTP response contains the
◦  HTTP versions, response code(e.g: 200) and response message (e.g: OK).
◦  CRLF as line separator
◦  A number of headers
◦  Headers are terminated with a blank line.
◦  Optional response body
—  The HTTP response is similar to the request itself. The response code informs the
browser both whether the request succeeded and what type of response this is. The
response message is a text-representation of the same information, and is often ignored by the
browser itself.
—  Examples of status codes are 200 OK, 404 File Not Found, 304 Not Modified and so fort.They are
all defined in the HTTP standard, and grouped into the following categories:
◦  1xx: Informational - Request received, continuing process
◦  2xx: Success - The action was successfully received, understood, and accepted
◦  3xx: Redirection - Further action must be taken in order to complete the request
◦  4xx: Client Error - The request contains bad syntax or cannot be fulfilled
◦  5xx: Server Error - The server failed to fulfill an apparently valid request
31
HTTP Protocol - Response
32
HTTP request-response flow
33
HTTP Protocol
—  Statelessness
◦  HTTP is by definition a stateless protocol which means that in
theory your browser has to reconnect to the server for every
request. In practice there is a header called Keep-Alive you may
use if you want to keep the connection open between the client
(your browser) and the server.
—  Idempotence
◦  Idempotence means that an operation can be applied multiple
times without changing the result. GET and PUT HTTP request
are expected to be idempotent whereas POST requests are not.
In other words, you can not cache POST HTTP responses.
34
Cache related headers
—  HTTP provides a list of headers dedicated to page caching
and cache invalidation.The most important ones are :
◦  Expires
◦  Cache-Control
◦  Etag
◦  Last-Modified
◦  If-Modified-Since
◦  If-None-Match
◦  Vary
◦  Age
35
VCL Basics
—  The Varnish Configuration Language
allows you to define your caching policy.
You writeVCL code whichVarnish will
parse, translate to C code, compile and
link to.
—  VCL is often described as domain specific
or a state engine.The domain specific
part of it is that some data is only
available in certain states. For example:
You can not access response headers
before you’ve actually started working on
a response.
36
VCL - State Engine
—  Each request is processed separately.
—  Each request is independent of any others
going on at the same time, previously or
later.
—  States are related, but isolated.
—  return(x); exits one state and instructs
Varnish to proceed to the next state.
—  DefaultVCL code is always present,
appended below your ownVCL.
37
VCL - Syntax
—  It is inspired mainly by C and Perl.
◦  //, # and /* foo */ for comments.
◦  sub $name functions.
◦  No loops, limited variables.
◦  Terminating statements, no return values.
◦  Domain-specific.
◦  Add as little or as much as you want.
—  The “return” statement ofVCL returns control from theVCL state engine to
Varnish. If you define your own function and call it from one of the default functions,
typing “return(foo)” will not return execution from your custom function to the
default function, but return execution fromVCL toVarnish.That is why we say that
VCL has terminating statements, not traditional return values.
—  For each domain, you can return control toVarnish using one or more different
return values.These return statements tellVarnish what to do next. Examples
include “look this up in cache”,“do not look this up in the cache” and “generate an
error message”.
38
VCL - Syntax
Comments are 'C', 'C++' or Shell style:
# This is a comment
// So is this
/*
* And this is also a comment
*/
39
VCL - Syntax
Strings are in ”...” and use %-escapes
”Hello World!%0a”
”.jpg$” // notice no  to escape 
”strings”
”can be”
”continued”; // (most places)
40
VCL - Syntax
Can be added between, and in functions.
Requires C-clue.
Can do almost anything.
C {
printf(”Hello Worldn”);
} C
41
VCL - Syntax
Definition of servers to get content from
backend b1 { .host = ”10.0.0.1”; }
backend b2 { .host = ”10.0.0.2”; }
sub vcl_recv {
// Default is first backend
set req.backend b2;
}
42
VCL – request flow (simple)
43
VCL – request flow (complete)
44
VCL – functions()
—  regsub(str, regex, sub)
—  regsuball(str, regex, sub)
—  ban_url(regex)
—  ban(expression)
—  purge;
—  return(restart)
—  return()
—  hash_data()
45
Questions?
46
To be continued ….
—  2nd session
47
Thank you
—  References
—  https://www.varnish-cache.org
—  https://www.varnish-software.com
—  http://en.wikipedia.org/wiki/
Varnish_(software)
—  http://en.wikipedia.org/wiki/
Reverse_proxy
48

Contenu connexe

Tendances

Building your own CDN using Amazon EC2
Building your own CDN using Amazon EC2Building your own CDN using Amazon EC2
Building your own CDN using Amazon EC2SergeyChernyshev
 
Integrated Cache on Netscaler
Integrated Cache on NetscalerIntegrated Cache on Netscaler
Integrated Cache on NetscalerMark Hillick
 
cache concepts and varnish-cache
cache concepts and varnish-cachecache concepts and varnish-cache
cache concepts and varnish-cacheMarc Cortinas Val
 
Installation Openstack Swift
Installation Openstack SwiftInstallation Openstack Swift
Installation Openstack Swiftymtech
 
Docker presentasjon java bin
Docker presentasjon java binDocker presentasjon java bin
Docker presentasjon java binOlve Hansen
 
Introduction to Varnish VCL
Introduction to Varnish VCLIntroduction to Varnish VCL
Introduction to Varnish VCLPax Dickinson
 
Integrating multiple CDN providers at Etsy - Velocity Europe (London) 2013
Integrating multiple CDN providers at Etsy - Velocity Europe (London) 2013Integrating multiple CDN providers at Etsy - Velocity Europe (London) 2013
Integrating multiple CDN providers at Etsy - Velocity Europe (London) 2013Marcus Barczak
 
Usenix LISA 2012 - Choosing a Proxy
Usenix LISA 2012 - Choosing a ProxyUsenix LISA 2012 - Choosing a Proxy
Usenix LISA 2012 - Choosing a ProxyLeif Hedstrom
 
Ansible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less CoffeeAnsible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less CoffeeSarah Z
 
MNPHP Scalable Architecture 101 - Feb 3 2011
MNPHP Scalable Architecture 101 - Feb 3 2011MNPHP Scalable Architecture 101 - Feb 3 2011
MNPHP Scalable Architecture 101 - Feb 3 2011Mike Willbanks
 
Infinit filesystem, Reactor reloaded
Infinit filesystem, Reactor reloadedInfinit filesystem, Reactor reloaded
Infinit filesystem, Reactor reloadedInfinit
 
Apache Traffic Server & Lua
Apache Traffic Server & LuaApache Traffic Server & Lua
Apache Traffic Server & LuaKit Chan
 
WordPress Development Environments
WordPress Development Environments WordPress Development Environments
WordPress Development Environments Ohad Raz
 
Apache Cookbook - TekX Chicago 2010
Apache Cookbook - TekX Chicago 2010Apache Cookbook - TekX Chicago 2010
Apache Cookbook - TekX Chicago 2010Rich Bowen
 
Varnish Cache Plus. Random notes for wise web developers
Varnish Cache Plus. Random notes for wise web developersVarnish Cache Plus. Random notes for wise web developers
Varnish Cache Plus. Random notes for wise web developersCarlos Abalde
 
getting started with varnish
getting started with varnishgetting started with varnish
getting started with varnishVarnish Software
 
Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpec
Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpecTest-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpec
Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpecMartin Etmajer
 

Tendances (20)

Building your own CDN using Amazon EC2
Building your own CDN using Amazon EC2Building your own CDN using Amazon EC2
Building your own CDN using Amazon EC2
 
Integrated Cache on Netscaler
Integrated Cache on NetscalerIntegrated Cache on Netscaler
Integrated Cache on Netscaler
 
cache concepts and varnish-cache
cache concepts and varnish-cachecache concepts and varnish-cache
cache concepts and varnish-cache
 
Installation Openstack Swift
Installation Openstack SwiftInstallation Openstack Swift
Installation Openstack Swift
 
Varnish Cache
Varnish CacheVarnish Cache
Varnish Cache
 
Docker presentasjon java bin
Docker presentasjon java binDocker presentasjon java bin
Docker presentasjon java bin
 
Introduction to Varnish VCL
Introduction to Varnish VCLIntroduction to Varnish VCL
Introduction to Varnish VCL
 
Integrating multiple CDN providers at Etsy - Velocity Europe (London) 2013
Integrating multiple CDN providers at Etsy - Velocity Europe (London) 2013Integrating multiple CDN providers at Etsy - Velocity Europe (London) 2013
Integrating multiple CDN providers at Etsy - Velocity Europe (London) 2013
 
Usenix LISA 2012 - Choosing a Proxy
Usenix LISA 2012 - Choosing a ProxyUsenix LISA 2012 - Choosing a Proxy
Usenix LISA 2012 - Choosing a Proxy
 
Ansible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less CoffeeAnsible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less Coffee
 
MNPHP Scalable Architecture 101 - Feb 3 2011
MNPHP Scalable Architecture 101 - Feb 3 2011MNPHP Scalable Architecture 101 - Feb 3 2011
MNPHP Scalable Architecture 101 - Feb 3 2011
 
Infinit filesystem, Reactor reloaded
Infinit filesystem, Reactor reloadedInfinit filesystem, Reactor reloaded
Infinit filesystem, Reactor reloaded
 
Apache Traffic Server & Lua
Apache Traffic Server & LuaApache Traffic Server & Lua
Apache Traffic Server & Lua
 
WordPress Development Environments
WordPress Development Environments WordPress Development Environments
WordPress Development Environments
 
Tomcatx performance-tuning
Tomcatx performance-tuningTomcatx performance-tuning
Tomcatx performance-tuning
 
Apache Cookbook - TekX Chicago 2010
Apache Cookbook - TekX Chicago 2010Apache Cookbook - TekX Chicago 2010
Apache Cookbook - TekX Chicago 2010
 
Memcached Study
Memcached StudyMemcached Study
Memcached Study
 
Varnish Cache Plus. Random notes for wise web developers
Varnish Cache Plus. Random notes for wise web developersVarnish Cache Plus. Random notes for wise web developers
Varnish Cache Plus. Random notes for wise web developers
 
getting started with varnish
getting started with varnishgetting started with varnish
getting started with varnish
 
Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpec
Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpecTest-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpec
Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpec
 

Similaire à Varnish Cache

Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...
Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...
Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...Ovadiah Myrgorod
 
Web Server and how we can design app in C#
Web Server and how we can design app  in C#Web Server and how we can design app  in C#
Web Server and how we can design app in C#caohansnnuedu
 
Varnish e caching di applicazioni Rails
Varnish e caching di applicazioni RailsVarnish e caching di applicazioni Rails
Varnish e caching di applicazioni RailsAntonio Carpentieri
 
Varnish and Drupal- Accelerating Website Performance and Flexibility with Var...
Varnish and Drupal- Accelerating Website Performance and Flexibility with Var...Varnish and Drupal- Accelerating Website Performance and Flexibility with Var...
Varnish and Drupal- Accelerating Website Performance and Flexibility with Var...Acquia
 
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmenMCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmenVannaSchrader3
 
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docx
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docxMCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docx
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docxalfredacavx97
 
Using aphace-as-proxy-server
Using aphace-as-proxy-serverUsing aphace-as-proxy-server
Using aphace-as-proxy-serverHARRY CHAN PUTRA
 
Supercharging Content Delivery with Varnish
Supercharging Content Delivery with VarnishSupercharging Content Delivery with Varnish
Supercharging Content Delivery with VarnishSamantha Quiñones
 
My Opera meets Varnish, Dec 2009
My Opera meets Varnish, Dec 2009My Opera meets Varnish, Dec 2009
My Opera meets Varnish, Dec 2009Cosimo Streppone
 
Ajp notes-chapter-06
Ajp notes-chapter-06Ajp notes-chapter-06
Ajp notes-chapter-06Ankit Dubey
 
Apache Wizardry - Ohio Linux 2011
Apache Wizardry - Ohio Linux 2011Apache Wizardry - Ohio Linux 2011
Apache Wizardry - Ohio Linux 2011Rich Bowen
 
Accelerate your web app with a layer of Varnish
Accelerate your web app with a layer of VarnishAccelerate your web app with a layer of Varnish
Accelerate your web app with a layer of VarnishJeremy Cook
 
Starting with varnish cache
Starting with varnish cacheStarting with varnish cache
Starting with varnish cacheRobert Richelieu
 
Scale Apache with Nginx
Scale Apache with NginxScale Apache with Nginx
Scale Apache with NginxBud Siddhisena
 
HTTP Acceleration with Varnish
HTTP Acceleration with VarnishHTTP Acceleration with Varnish
HTTP Acceleration with VarnishHarlow Ward
 

Similaire à Varnish Cache (20)

Varnish –Http Accelerator
Varnish –Http AcceleratorVarnish –Http Accelerator
Varnish –Http Accelerator
 
Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...
Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...
Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...
 
Varnish
VarnishVarnish
Varnish
 
Web Server and how we can design app in C#
Web Server and how we can design app  in C#Web Server and how we can design app  in C#
Web Server and how we can design app in C#
 
Varnish e caching di applicazioni Rails
Varnish e caching di applicazioni RailsVarnish e caching di applicazioni Rails
Varnish e caching di applicazioni Rails
 
Varnish and Drupal- Accelerating Website Performance and Flexibility with Var...
Varnish and Drupal- Accelerating Website Performance and Flexibility with Var...Varnish and Drupal- Accelerating Website Performance and Flexibility with Var...
Varnish and Drupal- Accelerating Website Performance and Flexibility with Var...
 
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmenMCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen
 
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docx
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docxMCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docx
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docx
 
Proxy
ProxyProxy
Proxy
 
Varnish qconsp 2011
Varnish qconsp 2011Varnish qconsp 2011
Varnish qconsp 2011
 
Using aphace-as-proxy-server
Using aphace-as-proxy-serverUsing aphace-as-proxy-server
Using aphace-as-proxy-server
 
Supercharging Content Delivery with Varnish
Supercharging Content Delivery with VarnishSupercharging Content Delivery with Varnish
Supercharging Content Delivery with Varnish
 
My Opera meets Varnish, Dec 2009
My Opera meets Varnish, Dec 2009My Opera meets Varnish, Dec 2009
My Opera meets Varnish, Dec 2009
 
Ajp notes-chapter-06
Ajp notes-chapter-06Ajp notes-chapter-06
Ajp notes-chapter-06
 
Apache Wizardry - Ohio Linux 2011
Apache Wizardry - Ohio Linux 2011Apache Wizardry - Ohio Linux 2011
Apache Wizardry - Ohio Linux 2011
 
Accelerate your web app with a layer of Varnish
Accelerate your web app with a layer of VarnishAccelerate your web app with a layer of Varnish
Accelerate your web app with a layer of Varnish
 
Starting with varnish cache
Starting with varnish cacheStarting with varnish cache
Starting with varnish cache
 
Scale Apache with Nginx
Scale Apache with NginxScale Apache with Nginx
Scale Apache with Nginx
 
sveltekit-en.pdf
sveltekit-en.pdfsveltekit-en.pdf
sveltekit-en.pdf
 
HTTP Acceleration with Varnish
HTTP Acceleration with VarnishHTTP Acceleration with Varnish
HTTP Acceleration with Varnish
 

Dernier

Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 

Dernier (20)

Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 

Varnish Cache

  • 2. Prerequisites and Goals 2 —  Prerequisites: ◦  Basic understanding of HTTP and related internet protocols. ◦  Basic Linux Administration Commands. —  Goals: ◦  Thorough understanding ofVarnish. ◦  Understanding of howVCL works and how to use it. ◦  Know how varnish works with Drupal and Wordpress. ◦  Debug using varnish tools.
  • 3. Varnish details —  What isVarnish? —  Installation and Configuration —  Demo —  Varnish log tools 3
  • 4. 4
  • 5. What is varnish? (from customer point of view) 5 https://www.youtube.com/watch?v=x7t2Sp174eI
  • 6. What isVarnish? —  Varnish is a reverse HTTP proxy. —  Sometimes referred as HTTP Accelerator or Web Accelerator —  Varnish Configuration Language (VCL) is lightning fast and allows administrators to set the policy that they wants. 6
  • 8. Varnish with multiple web servers 8
  • 9. Varnish with multiple web servers 9
  • 10. Varnish History 2005: Ideas! Verdens Gang (www.vg.no) 2006: Work began. Redpill Linpro -> Poul- Henning Kamp. 2006: Varnish 1.0 released 2008: Varnish 2.0 released 2010: Varnish Software is born as a spin-off to Redpill Linpro AS. 2011:Varnish 3.0 released 10
  • 11. Varnish Design Principles —  Varnish is designed to run on modern hardware under real work-loads and to solve real problems.Varnish does not cater to the “I want to make varnish run on my 486 just because”-crowd. If it does work on your 486, then that’s fine, but that’s not where you will see our focus. Nor will you see us sacrifice performance or simplicity for the sake of niche use- cases that can easily be solved by other means - like using a 64-bit OS. 11
  • 12. Varnish Installation —  To use the varnish-cache.org repository, run rpm --nosignature -i http:// repo.varnish-cache.org/redhat/ varnish-3.0/el5/noarch/ varnish- release-3.0-1.noarch.rpm —  and then run yum install varnish —  The --no-signature is only needed on initial installation, since theVarnish GPG key is not yet in the yum key ring 12
  • 13. Varnish Configuration File Usage /etc/sysconfig/varnish Used for parameters and command line arguments. When you change this, you need to run service varnishrestart . For Debian (Ubuntu): /etc/default/varnish instead. /etc/varnish/default.vcl TheVCL file.You can change the file name by editing /etc/default/varnish if you want to, but it’s normal to use the default name.This contains your VCL and backend-definitions.After changing this, you can run eitherservice varnish reload, which will not restartVarnish, or you can run service varnish restart, which empties the cache. 13
  • 14. Demo —  Check: apache is running. —  Change Apache’s ports from 80 to 8081, in httpd.conf and vhosts.conf. —  Modify theVarnish configuration file soVarnish listens on port 80 and uses 127.0.0.1:8081 as the backend. —  The end result should be: 14 Service Result Related config-files Apache Answers on port 8081 httpd.conf & vhosts.conf Varnish Answers on port 80 /etc/sysconfig/varnish Varnish Talks to apache on 127.0.0.1:8081 /etc/varnish/default.vcl
  • 15. An special case —  Our dev server has one varnish installed and multiple applications running. —  At present, multiple applications shares the same vcl file. —  Two devs may need to debug varnish in two different application at the same time. —  Varnishlog or varnishstat will show a combined statistics for all sites. 15
  • 16. Solution —  Use different vcl for different sites. ◦  Varnish loads vcl in compile time. ◦  Combining all sites vcl into one – not a good solution because varnishlog tools will still show a combined statistics. ◦  Install varnish in a different machine, a vbox and point to dev server as backend. 16
  • 17. Varnish Log tools —  varnishlog —  varnishstat 17
  • 19. varnishlog tag examples Tag Example value Description RxURL /index.html Varnish received a URL, the only scenario where Varnish receives a URL is from a client, thus: a client sent us this URL. TxURL /index.html Varnish sent a URL, the only scenario whereVarnish sends a URL is to a backend, thus: this is part of a backend request. RxHeader Host: www.example .com A received header. Either a request header or a response header backend. Since we know the Host- header is a request header, we can assume it’s from a client. TxHeader Host: example.com A headerVarnish sent. Either a request header or a response header. Since we know the Host-header is a request header we can assume it is a headerVarnish sent to a backend. RxRequest GET Received request method.Varnish only receives requests from clients. TxStatus 200 Status codeVarnish sent. Only sent to clients. RxStatus 500 Status codeVarnish received from a backend. 19
  • 20. varnishlog options -b only show traffic to backend -c only show traffic to client -O do not group by request -m <tag:filter> Show requests where the <tag> matches <filter>. Example: varnishlog - m TxStatus:500 to show requests returned to a client with status code 500. -n <name> The name of the varnish instance, or path to the shmlog. Useful for running multiple instances ofVarnish. -i <tag[,tag][..]> Only show the specified tags. -I <regex> Filter the tag provided by -i, using the regular expression for -I. 20
  • 21. varnishlog options Command Description varnishlog -c -m RxURL:/specific/url/ Only show client-requests for the url / specific/url varnishlog -O -i ReqEnd Only show the ReqEnd tag. Useful to spot sporadic slowdown.Watch the last three values of it. varnishlog -O -i TxURL Only show the URLs sent to backend servers. E.g: Cache misses and content not cached. varnishlog -O -i RxHeader -I Accept- Encoding Show the Accept-Encoding response header. varnishlog -b -m TxRequest:POST Show backend requests using the POST method. varnishlog -O -i TxURL,TxHeader Only shows the URL sent to a backend server and all headers sent, either to a client or backend. 21
  • 22. varnishstat —  Representation of the general health of Varnish. 22
  • 24. varnishstat – cache_hit and cache_miss —  Cache-hit ◦  There is a cache-hit when Varnish returns a page from its cache instead of forwarding the request to the origin server. —  Cache-miss ◦  There is a cache-miss whenVarnish has to forward the request to the origin server so the page can be serviced. 24
  • 25. varnishstat — Only counters with a value different from 0 is shown by default. — Varnishstat –l; — varnishstat –f field1, field2; — Demo 25
  • 26. varnishstat – some sp. coutners Counter Description client_drop This counts clients varnish had to drop due to resource shortage. It should be 0. cache_hitpass Hitpass is a special type of cache miss. It will be covered in theVCL chapters, but it can often be used to indicate if something the backend sent has triggered cache misses. backend_fail Counts the number of requests to backends that fail. Should have a low number, ideally 0, but it’s not unnatural to have backend failures once in a while. Just make sure it doesn’t become the normal state of operation. n_object Counts the number of objects in cache.You can have multiple variants of the same object depending on your setup. n_wrk, n_wrk_que ued, n_wrk_drop Thread counters. During normal operation, the n_wrk_queued counter should not grow. Once Varnish is out of threads, it will queue up requests and n_wrk_queued counts how many times this has happened. Once the queue is full, varnish starts dropping requests without answering. n_wrk_drop counts how many times a request has been dropped. It should be 0. n_lru_nuked Counts the number of objects varnish has had to evict from cache before they expired to make room for other content. If it is always 0, there is no point increasing the size of the cache since the cache isn’t full. If it’s climbing steadily a bigger cache could improve cache efficiency. esi_errors, esi_war nings If you use Edge Side Includes (ESI), these somewhat hidden counters can be helpful to determine if the ESI syntax the web server is sending is valid. uptime Varnish’ uptime. Useful to spot ifVarnish has been restarted, either manually or by bugs. Particularly useful if a monitor tool uses it. 26
  • 27. varnishadm – the mgmt. interface. —  Change parameters without restarting varnish —  ReloadVCL —  View the most up-to-date documentation for parameters —  varnishadm help 27
  • 28. HTTP Protocol —  A request consists of a request method, headers and an optional request body. —  A response consists of a response status, headers and an optional response body. —  Multiple requests can be sent over a single connection, in serial. —  Clients will open multiple connections to fetch resources in parallel. 28
  • 29. HTTP Protocol - Requests —  Standard request methods are:  GET, POST, HEAD, OPTIONS, PUT, DELETE, TRACE, or CONNECT. ◦  This is followed by a URI, e.g: /img/image.png or /index.html ◦  Usually followed by the HTTP version ◦  A new-line (CRLF), followed by an arbitrary amount of CRLF-separated headers (Accept- Language, Cookie, Host, User-Agent, etc). ◦  A single empty line, ending in CRLF. ◦  An optional message body, depending on the request method. —  Each request has the same, strict and fairly simple pattern. A request method informs the web server what sort of request this is: Is the client trying to fetch a resource (GET), or update some data(POST)? Or just get the headers of a resource (HEAD)? —  There are strict rules that apply to the request methods. For instance, a GET request can not contain a request body, but a POST request can. —  Similarly, a web server can not attach a request body to a response to a HEAD body. 29
  • 30. HTTP Protocol - Requests 30
  • 31. HTTP Protocol - Response —  A HTTP response contains the ◦  HTTP versions, response code(e.g: 200) and response message (e.g: OK). ◦  CRLF as line separator ◦  A number of headers ◦  Headers are terminated with a blank line. ◦  Optional response body —  The HTTP response is similar to the request itself. The response code informs the browser both whether the request succeeded and what type of response this is. The response message is a text-representation of the same information, and is often ignored by the browser itself. —  Examples of status codes are 200 OK, 404 File Not Found, 304 Not Modified and so fort.They are all defined in the HTTP standard, and grouped into the following categories: ◦  1xx: Informational - Request received, continuing process ◦  2xx: Success - The action was successfully received, understood, and accepted ◦  3xx: Redirection - Further action must be taken in order to complete the request ◦  4xx: Client Error - The request contains bad syntax or cannot be fulfilled ◦  5xx: Server Error - The server failed to fulfill an apparently valid request 31
  • 32. HTTP Protocol - Response 32
  • 34. HTTP Protocol —  Statelessness ◦  HTTP is by definition a stateless protocol which means that in theory your browser has to reconnect to the server for every request. In practice there is a header called Keep-Alive you may use if you want to keep the connection open between the client (your browser) and the server. —  Idempotence ◦  Idempotence means that an operation can be applied multiple times without changing the result. GET and PUT HTTP request are expected to be idempotent whereas POST requests are not. In other words, you can not cache POST HTTP responses. 34
  • 35. Cache related headers —  HTTP provides a list of headers dedicated to page caching and cache invalidation.The most important ones are : ◦  Expires ◦  Cache-Control ◦  Etag ◦  Last-Modified ◦  If-Modified-Since ◦  If-None-Match ◦  Vary ◦  Age 35
  • 36. VCL Basics —  The Varnish Configuration Language allows you to define your caching policy. You writeVCL code whichVarnish will parse, translate to C code, compile and link to. —  VCL is often described as domain specific or a state engine.The domain specific part of it is that some data is only available in certain states. For example: You can not access response headers before you’ve actually started working on a response. 36
  • 37. VCL - State Engine —  Each request is processed separately. —  Each request is independent of any others going on at the same time, previously or later. —  States are related, but isolated. —  return(x); exits one state and instructs Varnish to proceed to the next state. —  DefaultVCL code is always present, appended below your ownVCL. 37
  • 38. VCL - Syntax —  It is inspired mainly by C and Perl. ◦  //, # and /* foo */ for comments. ◦  sub $name functions. ◦  No loops, limited variables. ◦  Terminating statements, no return values. ◦  Domain-specific. ◦  Add as little or as much as you want. —  The “return” statement ofVCL returns control from theVCL state engine to Varnish. If you define your own function and call it from one of the default functions, typing “return(foo)” will not return execution from your custom function to the default function, but return execution fromVCL toVarnish.That is why we say that VCL has terminating statements, not traditional return values. —  For each domain, you can return control toVarnish using one or more different return values.These return statements tellVarnish what to do next. Examples include “look this up in cache”,“do not look this up in the cache” and “generate an error message”. 38
  • 39. VCL - Syntax Comments are 'C', 'C++' or Shell style: # This is a comment // So is this /* * And this is also a comment */ 39
  • 40. VCL - Syntax Strings are in ”...” and use %-escapes ”Hello World!%0a” ”.jpg$” // notice no to escape ”strings” ”can be” ”continued”; // (most places) 40
  • 41. VCL - Syntax Can be added between, and in functions. Requires C-clue. Can do almost anything. C { printf(”Hello Worldn”); } C 41
  • 42. VCL - Syntax Definition of servers to get content from backend b1 { .host = ”10.0.0.1”; } backend b2 { .host = ”10.0.0.2”; } sub vcl_recv { // Default is first backend set req.backend b2; } 42
  • 43. VCL – request flow (simple) 43
  • 44. VCL – request flow (complete) 44
  • 45. VCL – functions() —  regsub(str, regex, sub) —  regsuball(str, regex, sub) —  ban_url(regex) —  ban(expression) —  purge; —  return(restart) —  return() —  hash_data() 45
  • 47. To be continued …. —  2nd session 47
  • 48. Thank you —  References —  https://www.varnish-cache.org —  https://www.varnish-software.com —  http://en.wikipedia.org/wiki/ Varnish_(software) —  http://en.wikipedia.org/wiki/ Reverse_proxy 48