<s>
Varnish	B-Language
is	O
an	O
HTTP	B-Application
accelerator	I-Application
designed	O
for	O
content-heavy	O
dynamic	O
web	O
sites	O
as	O
well	O
as	O
APIs	B-General_Concept
.	O
</s>
<s>
In	O
contrast	O
to	O
other	O
web	B-Application
accelerators	I-Application
,	O
such	O
as	O
Squid	B-Protocol
,	O
which	O
began	O
life	O
as	O
a	O
client-side	O
cache	B-General_Concept
,	O
or	O
Apache	B-Application
and	O
nginx	B-Operating_System
,	O
which	O
are	O
primarily	O
origin	O
servers	O
,	O
Varnish	B-Language
was	O
designed	O
as	O
an	O
HTTP	B-Application
accelerator	I-Application
.	O
</s>
<s>
Varnish	B-Language
is	O
focused	O
exclusively	O
on	O
HTTP	B-Protocol
,	O
unlike	O
other	O
proxy	B-Application
servers	I-Application
that	O
often	O
support	O
FTP	B-Protocol
,	O
SMTP	B-Protocol
,	O
and	O
other	O
network	O
protocols	O
.	O
</s>
<s>
The	O
architect	O
and	O
lead	O
developer	O
is	O
Danish	O
independent	O
consultant	O
Poul-Henning	O
Kamp	O
(	O
a	O
well-known	O
FreeBSD	B-Operating_System
developer	O
)	O
,	O
with	O
management	O
,	O
infrastructure	O
and	O
additional	O
development	O
originally	O
provided	O
by	O
the	O
Norwegian	O
Linux	B-Application
consulting	O
company	O
Linpro	O
.	O
</s>
<s>
The	O
support	O
,	O
management	O
and	O
development	O
of	O
Varnish	B-Language
was	O
later	O
spun	O
off	O
into	O
a	O
separate	O
company	O
,	O
Varnish	B-Language
Software	O
.	O
</s>
<s>
Varnish	B-Language
is	O
free	B-Application
and	I-Application
open	I-Application
source	I-Application
software	I-Application
,	O
available	O
under	O
a	O
two-clause	B-Operating_System
BSD	I-Operating_System
license	I-Operating_System
.	O
</s>
<s>
Commercial	O
support	O
is	O
available	O
from	O
Varnish	B-Language
Software	O
,	O
amongst	O
others	O
.	O
</s>
<s>
Version	O
1.0	O
of	O
Varnish	B-Language
was	O
released	O
in	O
2006	O
,	O
Varnish	B-Language
2.0	O
in	O
2008	O
,	O
Varnish	B-Language
3.0	O
in	O
2011	O
,	O
Varnish	B-Language
4.0	O
in	O
2014	O
,	O
Varnish	B-Language
5.0	O
in	O
2016	O
,	O
Varnish	B-Language
6.0	O
in	O
March	O
2018	O
,	O
and	O
Varnish	B-Language
7.0	O
in	O
September	O
2021	O
.	O
</s>
<s>
Varnish	B-Language
stores	O
data	O
in	O
virtual	B-Architecture
memory	I-Architecture
and	O
leaves	O
the	O
task	O
of	O
deciding	O
what	O
is	O
stored	O
in	O
memory	O
and	O
what	O
gets	O
paged	O
out	O
to	O
disk	O
to	O
the	O
operating	B-General_Concept
system	I-General_Concept
.	O
</s>
<s>
This	O
helps	O
avoid	O
the	O
situation	O
where	O
the	O
operating	B-General_Concept
system	I-General_Concept
starts	O
caching	B-General_Concept
data	O
while	O
it	O
is	O
moved	O
to	O
disk	O
by	O
the	O
application	O
.	O
</s>
<s>
Varnish	B-Language
is	O
heavily	O
threaded	B-Operating_System
,	O
with	O
each	O
client	O
connection	O
being	O
handled	O
by	O
a	O
separate	O
worker	O
thread	B-Operating_System
.	O
</s>
<s>
When	O
the	O
configured	O
limit	O
on	O
the	O
number	O
of	O
active	O
worker	O
threads	B-Operating_System
is	O
reached	O
,	O
incoming	O
connections	O
are	O
placed	O
in	O
an	O
overflow	O
queue	O
;	O
when	O
this	O
queue	O
reaches	O
its	O
configured	O
limit	O
incoming	O
connections	O
will	O
be	O
rejected	O
.	O
</s>
<s>
The	O
principal	O
configuration	O
mechanism	O
is	O
Varnish	B-Language
Configuration	O
Language	O
(	O
VCL	O
)	O
,	O
a	O
domain-specific	B-Language
language	I-Language
(	O
DSL	O
)	O
used	O
to	O
write	O
hooks	O
that	O
are	O
called	O
at	O
critical	O
points	O
in	O
the	O
handling	O
of	O
each	O
request	O
.	O
</s>
<s>
Most	O
policy	O
decisions	O
are	O
left	O
to	O
VCL	O
code	O
,	O
making	O
Varnish	B-Language
more	O
configurable	O
and	O
adaptable	O
than	O
most	O
other	O
HTTP	B-Application
accelerators	I-Application
.	O
</s>
<s>
When	O
a	O
VCL	O
script	O
is	O
loaded	O
,	O
it	O
is	O
translated	O
to	O
C	B-Language
,	O
compiled	O
to	O
a	O
shared	O
object	O
by	O
the	O
system	O
compiler	O
,	O
and	O
loaded	O
directly	O
into	O
the	O
accelerator	O
which	O
can	O
thus	O
be	O
reconfigured	O
without	O
a	O
restart	O
.	O
</s>
<s>
A	O
number	O
of	O
run-time	O
parameters	O
control	O
things	O
such	O
as	O
the	O
maximum	O
and	O
the	O
minimum	O
number	O
of	O
worker	O
threads	B-Operating_System
,	O
various	O
timeouts	O
,	O
etc	O
.	O
</s>
<s>
In	O
order	O
to	O
reduce	O
the	O
number	O
of	O
system	O
calls	O
in	O
the	O
fast	O
path	O
to	O
a	O
minimum	O
,	O
log	O
data	O
is	O
stored	O
in	O
shared	B-Operating_System
memory	I-Operating_System
,	O
and	O
the	O
task	O
of	O
monitoring	O
,	O
filtering	O
,	O
formatting	O
and	O
writing	O
log	O
data	O
to	O
disk	O
is	O
delegated	O
to	O
a	O
separate	O
application	O
.	O
</s>
<s>
Varnish	B-Language
Cache	I-Language
can	O
speed	O
up	O
information	O
delivery	O
by	O
a	O
factor	O
of	O
several	O
hundred	O
.	O
</s>
<s>
To	O
ensure	O
proper	O
operation	O
and	O
performance	O
,	O
Varnish	B-Language
exposes	O
metrics	O
that	O
can	O
be	O
monitored	O
in	O
the	O
following	O
areas	O
:	O
</s>
<s>
Varnish	B-Language
Cache	I-Language
ships	O
with	O
monitoring	O
and	O
logging	O
tools	O
.	O
</s>
<s>
One	O
of	O
the	O
most	O
used	O
is	O
varnishstat	O
which	O
gives	O
a	O
detailed	O
snapshot	O
of	O
Varnish	B-Language
's	O
current	O
performance	O
.	O
</s>
<s>
It	O
provides	O
access	O
to	O
in-memory	O
statistics	O
such	O
as	O
cache	B-General_Concept
hits	O
and	O
misses	O
,	O
resource	O
consumption	O
,	O
threads	B-Operating_System
created	O
,	O
and	O
more	O
.	O
</s>
<s>
Running	O
varnishstat	O
from	O
the	O
command	O
line	O
returns	O
a	O
continuously	O
updating	O
list	O
of	O
all	O
available	O
Varnish	B-Language
metrics	O
.	O
</s>
<s>
Varnishstat	O
can	O
be	O
used	O
as	O
a	O
standalone	O
tool	O
to	O
spot-check	O
the	O
health	O
of	O
the	O
cache	B-General_Concept
.	O
</s>
<s>
In	O
order	O
to	O
graph	O
metrics	O
over	O
time	O
,	O
correlate	O
with	O
other	O
statistics	O
from	O
across	O
an	O
infrastructure	O
,	O
and	O
set	O
up	O
alerts	O
about	O
any	O
problems	O
that	O
may	O
arise	O
,	O
monitoring	O
services	O
can	O
integrate	O
with	O
Varnish	B-Language
and	O
collect	O
varnishstat	O
metrics	O
.	O
</s>
<s>
Varnishlog	O
is	O
a	O
tool	O
that	O
can	O
be	O
used	O
to	O
debug	O
or	O
tune	O
Varnish	B-Language
's	O
configuration	O
,	O
as	O
it	O
provides	O
detailed	O
information	O
about	O
each	O
individual	O
request	O
.	O
</s>
<s>
Varnish	B-Language
supports	O
load	B-Application
balancing	I-Application
using	O
both	O
a	O
round	B-Algorithm
robin	I-Algorithm
and	O
a	O
random	O
director	O
,	O
both	O
with	O
a	O
per-backend	O
weighting	O
.	O
</s>
<s>
Basic	O
health-checking	O
of	O
backends	B-Architecture
is	O
also	O
available	O
.	O
</s>
<s>
Varnish	B-Language
Cache	I-Language
also	O
features	O
:	O
</s>
<s>
If	O
a	O
server	O
malfunctions	O
and	O
returns	O
HTTP	B-Protocol
status	O
code	O
500	O
,	O
Grace	O
mode	O
will	O
ignore	O
expiry	O
headers	O
and	O
continue	O
to	O
return	O
cached	O
versions	O
.	O
</s>
<s>
Saint	O
mode	O
is	O
for	O
use	O
when	O
load	B-Application
balancing	I-Application
,	O
where	O
a	O
failing	O
server	O
is	O
blacklisted	O
for	O
a	O
quarantine	O
period	O
and	O
excluded	O
from	O
the	O
server	O
pool	O
.	O
</s>
