HOME

TheInfoList



OR:

Varnish is a reverse caching proxy used as HTTP accelerator for content-heavy dynamic web sites as well as
API An application programming interface (API) is a connection between computers or between computer programs. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how to build ...
s. In contrast to other
web accelerator A web accelerator is a proxy server that reduces website access time. They can be a self-contained hardware appliance or installable software. Web accelerators may be installed on the client computer or mobile device, on Internet service provider ...
s, such as
Squid A squid (: squid) is a mollusc with an elongated soft body, large eyes, eight cephalopod limb, arms, and two tentacles in the orders Myopsida, Oegopsida, and Bathyteuthida (though many other molluscs within the broader Neocoleoidea are also ...
, which began life as a client-side cache, or
Apache The Apache ( ) are several Southern Athabaskan language-speaking peoples of the Southwestern United States, Southwest, the Southern Plains and Northern Mexico. They are linguistically related to the Navajo. They migrated from the Athabascan ho ...
and
nginx (pronounced "engine x" , stylized as NGINX or nginx) is a web server that can also be used as a reverse proxy, load balancer, mail proxy and HTTP cache. The software was created by Russian developer Igor Sysoev and publicly released in 20 ...
, which are primarily origin servers, Varnish was designed as an HTTP accelerator. Varnish is focused exclusively on
HTTP HTTP (Hypertext Transfer Protocol) is an application layer protocol in the Internet protocol suite model for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web, wher ...
, unlike other proxy servers that often support
FTP The File Transfer Protocol (FTP) is a standard communication protocol used for the transfer of computer files from a server to a client on a computer network. FTP is built on a client–server model architecture using separate control and dat ...
,
SMTP The Simple Mail Transfer Protocol (SMTP) is an Internet standard communication protocol for electronic mail transmission. Mail servers and other message transfer agents use SMTP to send and receive mail messages. User-level email clients typi ...
, and other
network protocol A communication protocol is a system of rules that allows two or more entities of a communications system to transmit information via any variation of a physical quantity. The protocol defines the rules, syntax, semantics, and synchronization of ...
s.


History

The project was initiated by the online branch of the Norwegian tabloid newspaper ''
Verdens Gang (), generally known under the abbreviation ''VG'', is a Norway, Norwegian Tabloid (newspaper format), tabloid newspaper. In 2016, circulation numbers stood at 93,883, declining from a peak circulation of 390,510 in 2002. Nevertheless, ''VG'' is ...
''. The architect and lead developer is Danish independent consultant Poul-Henning Kamp (a well-known
FreeBSD FreeBSD is a free-software Unix-like operating system descended from the Berkeley Software Distribution (BSD). The first version was released in 1993 developed from 386BSD, one of the first fully functional and free Unix clones on affordable ...
developer), with management, infrastructure and additional development originally provided by the Norwegian Linux consulting company Linpro. The support, management and development of Varnish was later spun off into a separate company, Varnish Software. Varnish is
free and open-source software Free and open-source software (FOSS) is software available under a license that grants users the right to use, modify, and distribute the software modified or not to everyone free of charge. FOSS is an inclusive umbrella term encompassing free ...
, available under a two-clause
BSD license BSD licenses are a family of permissive free software licenses, imposing minimal restrictions on the use and distribution of covered software. This is in contrast to copyleft licenses, which have share-alike requirements. The original BSD lic ...
. Commercial support is available from Varnish Software, amongst others. Version 1.0 of Varnish was released in 2006, Varnish 2.0 in 2008, Varnish 3.0 in 2011, Varnish 4.0 in 2014, Varnish 5.0 in 2016, Varnish 6.0 in March 2018, and Varnish 7.0 in September 2021.


Architecture

Varnish stores data in
virtual memory In computing, virtual memory, or virtual storage, is a memory management technique that provides an "idealized abstraction of the storage resources that are actually available on a given machine" which "creates the illusion to users of a ver ...
and leaves the task of deciding what is stored in memory and what gets paged out to disk to the
operating system An operating system (OS) is system software that manages computer hardware and software resources, and provides common daemon (computing), services for computer programs. Time-sharing operating systems scheduler (computing), schedule tasks for ...
. This helps avoid the situation where the operating system starts caching data while it is moved to disk by the application. Varnish is heavily threaded, with each client connection being handled by a separate worker thread. When the configured limit on the number of active worker threads is reached, incoming connections are placed in an overflow queue; when this queue reaches its configured limit incoming connections will be rejected. The principal configuration mechanism is ''Varnish Configuration Language'' (VCL), a
domain-specific language A domain-specific language (DSL) is a computer language specialized to a particular application domain. This is in contrast to a general-purpose language (GPL), which is broadly applicable across domains. There are a wide variety of DSLs, ranging ...
(DSL) used to write hooks that are called at critical points in the handling of each request. Most policy decisions are left to VCL code, making Varnish more configurable and adaptable than most other HTTP accelerators. When a VCL script is loaded, it is translated to C, compiled to a shared object by the system compiler, and loaded directly into the accelerator which can thus be reconfigured without a restart. A number of run-time parameters control things such as the maximum and the minimum number of worker threads, various timeouts, etc. A command-line management interface allows these parameters to be modified, and new VCL scripts to be compiled, loaded and activated, without restarting the accelerator. In order to reduce the number of system calls in the fast path to a minimum, log data is stored in shared memory, and the task of monitoring, filtering, formatting and writing log data to disk is delegated to a separate application.


Performance metrics

Varnish Cache can speed up information delivery by a factor of several hundred. To ensure proper operation and performance, Varnish exposes metrics that can be monitored in the following areas: * Client metrics: client connections and requests * Cache performance: cache hits, evictions * Thread metrics: thread creation, failures, queues * Backend metrics: success, failure, and health of backend connections


Metric collection

Varnish Cache ships with monitoring and logging tools. One of the most used is varnishstat which gives a detailed snapshot of Varnish's current performance. It provides access to in-memory statistics such as cache hits and misses, resource consumption, threads created, and more.


varnishstat

Running varnishstat from the command line returns a continuously updating list of all available Varnish metrics. If the -1 flag is added, varnishstat will exit after printing the list one time. Varnishstat can be used as a standalone tool to spot-check the health of the cache. In order to graph metrics over time, correlate with other statistics from across an infrastructure, and set up alerts about any problems that may arise, monitoring services can integrate with Varnish and collect varnishstat metrics.


varnishlog

Varnishlog is a tool that can be used to debug or tune Varnish's configuration, as it provides detailed information about each individual request.


Load balancing

Varnish supports load balancing using both a round robin and a random director, both with a per-backend weighting. Basic health-checking of backends is also available.


Other features

Varnish Cache also features: * Plugin support with Varnish Modules, also called VMODs * Support for Edge Side Includes including stitching together compressed ESI fragments *
gzip gzip is a file format and a software application used for file compression and decompression. The program was created by Jean-loup Gailly and Mark Adler as a free software replacement for the compress program used in early Unix systems, and ...
Compression and Decompression * DNS, Random, Hashing and Client IP-based Directors * HTTP Streaming Pass & Fetch * Experimental support for Persistent Storage, without LRU eviction * Saint and Grace modes. ** If a server malfunctions and returns HTTP status code 500, Grace mode will ignore expiry headers and continue to return cached versions. Saint mode is for use when load balancing, where a failing server is blocked for a quarantine period and excluded from the server pool.


See also

*
Web accelerator A web accelerator is a proxy server that reduces website access time. They can be a self-contained hardware appliance or installable software. Web accelerators may be installed on the client computer or mobile device, on Internet service provider ...
which discusses host-based HTTP acceleration * Proxy server which discusses client-side proxies * Reverse proxy which discusses origin-side proxies * Comparison of web server software *
Internet Cache Protocol The Internet Cache Protocol (ICP) is a User Datagram_Protocol, UDP-based protocol (computing), protocol used for coordinating web caches. Its purpose is to find out the most appropriate location to retrieve a requested object in the situation where ...
* Guru Meditation – an error message used by Varnish


References


External links

* {{official website
Official commercial web site


*
You're Doing It Wrong
, June 11, 2010 ''ACM Queue'' article by Varnish developer Poul-Henning Kamp describing the implementation of the LRU list.
Varnish in Layman's Terms

Varnish Cache How-To
Reverse proxy Free proxy servers Proxy server software for Linux Unix network-related software Free software programmed in C Free web server software Cross-platform software Forward proxy Software using the BSD license