Varnish cache
Encyclopedia
Varnish is an HTTP accelerator designed for content-heavy dynamic web sites. In contrast to other HTTP accelerators, such as Squid, which began life as a client-side cache, or Apache
Apache HTTP Server
The Apache HTTP Server, commonly referred to as Apache , is web server software notable for playing a key role in the initial growth of the World Wide Web. In 2009 it became the first web server software to surpass the 100 million website milestone...

 and nginx
Nginx
nginx is a Web server and a reverse proxy server for HTTP, SMTP, POP3 and IMAP protocols, with a strong focus on high concurrency, performance and low memory usage. It is licensed under a BSD-like license and it runs on Unix, Linux, BSD variants, Mac OS X, Solaris, and Microsoft Windows.- Overview...

, which are primarily origin servers, Varnish was designed from the ground up as an HTTP accelerator. Varnish is focused exclusively on HTTP, unlike other proxy server
Proxy server
In computer networks, a proxy server is a server that acts as an intermediary for requests from clients seeking resources from other servers. A client connects to the proxy server, requesting some service, such as a file, connection, web page, or other resource available from a different server...

s that often support FTP, SMTP and other network protocols.

History

The project was initiated by the online branch of the Norwegian tabloid newspaper Verdens Gang
Verdens Gang
Verdens Gang , generally known under the abbreviation VG, is a Norwegian tabloid newspaper...

. The architect and lead developer is Danish independent consultant Poul-Henning Kamp
Poul-Henning Kamp
Poul-Henning Kamp is a Danish FreeBSD developer, responsible for implementation of the widely used MD5 password hash algorithm, a vast quantity of systems code, including the FreeBSD GEOM storage layer, GBDE cryptographic storage transform, part of the UFS2 file system implementation, FreeBSD...

 (a well known FreeBSD
FreeBSD
FreeBSD is a free Unix-like operating system descended from AT&T UNIX via BSD UNIX. Although for legal reasons FreeBSD cannot be called “UNIX”, as the direct descendant of BSD UNIX , FreeBSD’s internals and system APIs are UNIX-compliant...

 core developer), with management, infrastructure and additional development originally provided by the Norwegian Linux consulting company Linpro
Linpro
Linpro AS is a Linux solutions company from Oslo, Norway, founded in 1995 by Dag Asheim, and mainly owned by its employees. They provide solutions around free and Open Source systems like Linux and FreeBSD, as well as proprietary Unix systems....

. The support, management and development of Varnish was later spun off into a separate company, Varnish Software.

Varnish is open source
Open source
The term open source describes practices in production and development that promote access to the end product's source materials. Some consider open source a philosophy, others consider it a pragmatic methodology...

, available under a two-clause BSD license. Commercial support is available from Varnish Software, amongst others.

Version 1.0 of Varnish was released in 2006. Varnish 2.0 was released in 2008, and Varnish 3.0 was released in 2011.

Architecture

Varnish stores data in virtual memory
Virtual memory
In computing, virtual memory is a memory management technique developed for multitasking kernels. This technique virtualizes a computer architecture's various forms of computer data storage , allowing a program to be designed as though there is only one kind of memory, "virtual" memory, which...

 and leaves the task of deciding what is stored in memory and what gets paged out to disk to the operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

. This helps avoid the situation where the operating system starts caching data while they are moved to disk by the application.

Furthermore, Varnish is heavily threaded
Thread (computer science)
In computer science, a thread of execution is the smallest unit of processing that can be scheduled by an operating system. The implementation of threads and processes differs from one operating system to another, but in most cases, a thread is contained inside a process...

, 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; only when this queue reaches its configured limit will incoming connections be rejected.

The principal configuration mechanism is VCL (Varnish Configuration Language), a domain-specific language (DSL) used to write hooks which are called at critical points in the handling of each request. Most policy decisions are left to VCL code, making Varnish far more configurable and adaptable than most other HTTP accelerators. When a VCL script is loaded, it is translated to C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

, compiled to a shared object by the system compiler, and linked directly into the accelerator.

A number of run-time parameters control things such as the maximum and 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
Shared memory
In computing, shared memory is memory that may be simultaneously accessed by multiple programs with an intent to provide communication among them or avoid redundant copies. Depending on context, programs may run on a single processor or on multiple separate processors...

, and the task of filtering, formatting and writing log data to disk is delegated to a separate application.

Performance

While Varnish is designed to reduce contention between threads to a minimum, its authors claim that its performance will only be as good as that of the system's pthreads
POSIX Threads
POSIX Threads, usually referred to as Pthreads, is a POSIX standard for threads. The standard, POSIX.1c, Threads extensions , defines an API for creating and manipulating threads....

 implementation.

Additionally, a poor malloc
Malloc
C dynamic memory allocation refers to performing dynamic memory allocation in the C via a group of functions in the C standard library, namely malloc, realloc, calloc and free....

 implementation may add unnecessary contention and thereby limit performance.

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
    Edge Side Includes
    Edge Side Includes or 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....

     including stitching together compressed ESI fragments
  • Gzip Compression and Uncompression
  • DNS, Random, Hashing and Client IP based Directors
  • Technology preview for HTTP Streaming Pass & Fetch
  • Experimental support for Persistent Storage with LRU
  • Saint and Grace mode.

See also

  • Web accelerator
    Web accelerator
    A web accelerator is a proxy server that reduces web site access times. They can be a self-contained hardware appliance or installable software....

     which discusses host-based HTTP acceleration
  • Proxy server
    Proxy server
    In computer networks, a proxy server is a server that acts as an intermediary for requests from clients seeking resources from other servers. A client connects to the proxy server, requesting some service, such as a file, connection, web page, or other resource available from a different server...

     which discusses client-side proxies
  • Reverse proxy
    Reverse proxy
    In computer networks, a reverse proxy is a type of proxy server that retrieves resources on behalf of a client from one or more servers. These resources are then returned to the client as though it originated from the reverse proxy itself...

     which discusses origin-side proxies
  • Comparison of web servers
    Comparison of web servers
    -Overview:-Features:- Operating system support :...

  • Comparison of lightweight web servers
    Comparison of lightweight web servers
    Lightweight web servers are web servers which have been designed to run with very small resource overhead because of hardware, environment, or simply for the challenge of it....

  • Internet Cache Protocol
    Internet Cache Protocol
    The Internet Cache Protocol is a protocol used for coordinating web caches. Its purpose is to find out the most appropriate location to retrieve a requested object from in the situation where multiple caches are in use at a single site...


External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK