Varnish cache
   HOME

TheInfoList



OR:

Varnish is an HTTP accelerator designed for content-heavy dynamic web sites as well as
API An application programming interface (API) is a way for two or more computer programs to communicate with each other. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how ...
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 ISP servers, on the server ...
s, such as Squid, which began life as a client-side cache, or Apache and
nginx Nginx (pronounced "engine x" ) 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 Igor Sysoev and publicly released in 2004. Nginx is free and open-source software ...
, which are primarily origin servers, Varnish was designed as an HTTP accelerator. Varnish is focused exclusively on
HTTP The Hypertext Transfer Protocol (HTTP) 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 We ...
, unlike other
proxy server In computer networking, a proxy server is a server application that acts as an intermediary between a client requesting a resource and the server providing that resource. Instead of connecting directly to a server that can fulfill a reques ...
s 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 data ...
,
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 ty ...
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 kind of variation of a physical quantity. The protocol defines the rules, syntax, semantics and synchroniza ...
s.


History

The project was initiated by the online branch of the Norwegian tabloid newspaper ''
Verdens Gang ''Verdens Gang'' ("The course of the world"), generally known under the abbreviation ''VG'', is a Norwegian tabloid newspaper. In 2016, circulation numbers stood at 93,883, having declined from a peak circulation of 390,510 in 2002. ''VG'' is n ...
''. The architect and lead developer is Danish independent consultant
Poul-Henning Kamp Poul-Henning Kamp (; born 1966) is a Danish computer software developer known for work on various projects including FreeBSD and Varnish. He currently resides in Slagelse, Denmark. Involvement in the FreeBSD project Poul-Henning Kamp has been c ...
(a well-known FreeBSD 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 a term used to refer to groups of software consisting of both free software and open-source software where anyone is freely licensed to use, copy, study, and change the software in any way, and the source ...
, 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 lice ...
. 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 very ...
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, software resources, and provides common services for computer programs. Time-sharing operating systems schedule tasks for efficient use of the system and may also i ...
. 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 (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 In computer science, shared memory is memory that may be simultaneously accessed by multiple programs with an intent to provide communication among them or avoid redundant copies. Shared memory is an efficient means of passing data between progr ...
, 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 Cache, caching, or caché may refer to: Places United States * Cache, Idaho, an unincorporated community * Cache, Illinois, an unincorporated community * Cache, Oklahoma, a city in Comanche County * Cache, Utah, Cache County, Utah * Cache County ...
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 Round-robin may refer to: Computing * Round-robin DNS, a technique for dealing with redundant Internet Protocol service hosts * Round-robin networks, communications networks made up of radio nodes organized in a mesh topology * Round-robin schedu ...
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 Edge Side Includes (ESI) is a small markup language for edge level dynamic web content assembly. The purpose of ESI is to tackle the problem of web infrastructure scaling. It is an application of edge computing. It is fairly common for websites t ...
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 i ...
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 blacklisted 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 ISP servers, on the server ...
which discusses host-based HTTP acceleration *
Proxy server In computer networking, a proxy server is a server application that acts as an intermediary between a client requesting a resource and the server providing that resource. Instead of connecting directly to a server that can fulfill a reques ...
which discusses client-side proxies *
Reverse proxy In computer networks, a reverse proxy is the application that sits in front of back-end applications and forwards client (e.g. browser) requests to those applications. Reverse proxies help increase scalability, performance, resilience and securi ...
which discusses origin-side proxies *
Comparison of web servers Web server software allows computers to act as web servers. The first web servers supported only static files, such as HTML (and images), but now they commonly allow embedding of server side applications. Some web application frameworks include s ...
* Internet Cache Protocol *
Guru Meditation Guru Meditation started as an error notice displayed by the Amiga computer when it crashes. It is now also used by Varnish, a software component used by many content-heavy websites. This has led to many internet users seeing a "Guru Meditation ...
– an error message used by Varnish


References


External links

* {{official website
Official commercial web site
* /www.varnish-cache.org/trac/wiki/ArchitectNotes Notes from the Architect*
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