Varnish (software)

Last updated
Varnish
Developer(s) Poul-Henning Kamp, Redpill-Linpro, Varnish Software
Stable release
7.4.1 [1]   OOjs UI icon edit-ltr-progressive.svg / 20 September 2023;32 days ago (20 September 2023)
Repository
Written in C
Operating system BSD, Linux, Unix
Type HTTP accelerator
License two-clause BSD license
Website varnish-cache.org   OOjs UI icon edit-ltr-progressive.svg

Varnish is a reverse caching proxy [2] used as HTTP accelerator for content-heavy dynamic web sites as well as APIs. In contrast to other web accelerators, such as Squid, which began life as a client-side cache, or Apache and nginx, which are primarily origin servers, Varnish was designed as an HTTP accelerator. Varnish is focused exclusively on HTTP, unlike other proxy servers that often support FTP, SMTP, and other network protocols.

Contents

History

The project was initiated by the online branch of the Norwegian tabloid newspaper Verdens Gang . The architect and lead developer is Danish independent consultant Poul-Henning Kamp [2] (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, 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, [3] [4] Varnish 2.0 in 2008, [5] Varnish 3.0 in 2011, [6] Varnish 4.0 in 2014, [7] Varnish 5.0 in 2016, [8] Varnish 6.0 in March 2018, [9] and Varnish 7.0 in September 2021. [10]

Architecture

Varnish stores data in virtual memory and leaves the task of deciding what is stored in memory and what gets paged out to disk to the operating system. 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.[ citation needed ] 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: [11]

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. [12]

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. [13] 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 running with a Wikimedia backend Varnishlog Example.png
Varnishlog running with a Wikimedia backend

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. [14]

Other features

Varnish Cache also features:

See also

Related Research Articles

<span class="mw-page-title-main">Apache HTTP Server</span> Open-source web server software

The Apache HTTP Server is a free and open-source cross-platform web server software, released under the terms of Apache License 2.0. It is developed and maintained by a community of developers under the auspices of the Apache Software Foundation.

<span class="mw-page-title-main">HTTP</span> Application protocol for distributed, collaborative, hypermedia information systems

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 Web, where hypertext documents include hyperlinks to other resources that the user can easily access, for example by a mouse click or by tapping the screen in a web browser.

<span class="mw-page-title-main">Web server</span> Computer software that distributes web pages

A web server is computer software and underlying hardware that accepts requests via HTTP or its secure variant HTTPS. A user agent, commonly a web browser or web crawler, initiates communication by making a request for a web page or other resource using HTTP, and the server responds with the content of that resource or an error message. A web server can also accept and store resources sent from the user agent if configured to do so.

<span class="mw-page-title-main">Proxy server</span> Computer server that makes and receives requests on behalf of a user

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. It improves privacy, security, and performance in the process.

<span class="mw-page-title-main">Squid (software)</span> Caching and forwarding HTTP web proxy

Squid is a caching and forwarding HTTP web proxy. It has a wide variety of uses, including speeding up a web server by caching repeated requests, caching World Wide Web (WWW), Domain Name System (DNS), and other computer network lookups for a group of people sharing network resources, and aiding security by filtering traffic. Although used for mainly HTTP and File Transfer Protocol (FTP), Squid includes limited support for several other protocols including Internet Gopher, Secure Sockets Layer (SSL), Transport Layer Security (TLS), and Hypertext Transfer Protocol Secure (HTTPS). Squid does not support the SOCKS protocol, unlike Privoxy, with which Squid can be used in order to provide SOCKS support.

SOCKS is an Internet protocol that exchanges network packets between a client and server through a proxy server. SOCKS5 optionally provides authentication so only authorized users may access a server. Practically, a SOCKS server proxies TCP connections to an arbitrary IP address, and provides a means for UDP packets to be forwarded.

NaviServer is a high performance web server written in C and Tcl. It can be easily extended in either language to create web sites and services; there are over 35 modules available

PowerDNS is a DNS server program, written in C++ and licensed under the GPL. It runs on most Unix derivatives. PowerDNS features a large number of different backends ranging from simple BIND style zonefiles to relational databases and load balancing/failover algorithms. A DNS recursor is provided as a separate program.

lighttpd

lighttpd is an open-source web server optimized for speed-critical environments while remaining standards-compliant, secure and flexible. It was originally written by Jan Kneschke as a proof-of-concept of the c10k problem – how to handle 10,000 connections in parallel on one server, but has gained worldwide popularity. Its name is a portmanteau of "light" and "httpd".

A web accelerator is a proxy server that reduces website access time. They can be a self-contained hardware appliance or installable software.

<span class="mw-page-title-main">Poul-Henning Kamp</span> Danish software developer

Poul-Henning Kamp is a Danish computer software developer known for work on various projects including FreeBSD and Varnish. He currently resides in Slagelse, Denmark.

Google Web Accelerator was a web accelerator produced by Google. It used client software installed on the user's computer, as well as data caching on Google's servers, to speed up page load times by means of data compression, prefetching of content, and sharing cached data between users. The beta, released on May 4, 2005, works with Mozilla Firefox 1.0+ and Internet Explorer 5.5+ on Windows 2000 SP3+, Windows XP, Windows Server 2003, Windows Vista and Windows 7 machines.

<span class="mw-page-title-main">Oracle iPlanet Web Proxy Server</span>

The Oracle iPlanet Web Proxy Server (OiWPS), formerly known as Sun Java System Web Proxy Server (SJSWPS), is a proxy server software developed by Sun Microsystems.

Pound is a lightweight open source reverse proxy program and application firewall suitable to be used as a web server load balancing solution. Originally developed by an IT security company, it has a strong emphasis on security. The original intent on developing Pound was to allow distributing the load among several Zope servers running on top of ZEO. However, Pound is not limited to Zope-based installations. Using regular expression matching on the requested URLs, Pound can pass different kinds of requests to different backend server groups. A few more of its most important features:

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 Igor Sysoev and publicly released in 2004. Nginx is free and open-source software, released under the terms of the 2-clause BSD license. A large fraction of web servers use Nginx, often as a load balancer.

libtorrent

libtorrent is an open-source implementation of the BitTorrent protocol. It is written in and has its main library interface in C++. Its most notable features are support for Mainline DHT, IPv6, HTTP seeds and μTorrent's peer exchange. libtorrent uses Boost, specifically Boost.Asio to gain its platform independence. It is known to build on Windows and most Unix-like operating systems.

<span class="mw-page-title-main">WebSocket</span> Computer network protocol

WebSocket is a computer communications protocol, providing full-duplex communication channels over a single TCP connection. The WebSocket protocol was standardized by the IETF as RFC 6455 in 2011. The current API specification allowing web applications to use this protocol is known as WebSockets. It is a living standard maintained by the WHATWG and a successor to The WebSocket API from the W3C.

A B-heap is a binary heap implemented to keep subtrees in a single page. This reduces the number of pages accessed by up to a factor of ten for big heaps when using virtual memory, compared with the traditional implementation. The traditional mapping of elements to locations in an array puts almost every level in a different page.

HTTP/2 is a major revision of the HTTP network protocol used by the World Wide Web. It was derived from the earlier experimental SPDY protocol, originally developed by Google. HTTP/2 was developed by the HTTP Working Group of the Internet Engineering Task Force (IETF). HTTP/2 is the first new version of HTTP since HTTP/1.1, which was standardized in RFC 2068 in 1997. The Working Group presented HTTP/2 to the Internet Engineering Steering Group (IESG) for consideration as a Proposed Standard in December 2014, and IESG approved it to publish as Proposed Standard on February 17, 2015. The HTTP/2 specification was published as RFC 7540 on May 14, 2015.

Elliptics is a distributed key–value data storage with open source code. By default it is a classic distributed hash table (DHT) with multiple replicas put in different groups. Elliptics was created to meet requirements of multi-datacenter and physically distributed storage locations when storing huge amount of medium and large files.

References

  1. "Release varnish-7.4.1". 20 September 2023.
  2. 1 2 Feryn, Thijs. "1. What Is Varnish Cache? - Getting Started with Varnish Cache [Book]". O'Reilly Media . Retrieved 2023-10-22.
  3. "Catalyst Advent Calendar - Day 14". www.catalystframework.org. Retrieved Sep 4, 2020.
  4. Smørgrav, Dag-Erling (Sep 20, 2006). "Varnish 1.0 released" . Retrieved Sep 4, 2020.
  5. Heen, Tollef Fog (Oct 15, 2008). "Varnish 2.0 released!" . Retrieved Sep 4, 2020.
  6. Heen, Tollef Fog (Jun 17, 2011). "Varnish 3.0.0 released" . Retrieved Sep 4, 2020.
  7. Karstensen, Lasse (Apr 10, 2014). "Varnish 4.0.0 released" . Retrieved Sep 4, 2020.
  8. "Varnish Cache 5.0.0 — Varnish HTTP Cache". varnish-cache.org. Retrieved Sep 4, 2020.
  9. Poul-Henning Kamp (15 March 2018). "Varnish 6.0 Released" . Retrieved 15 May 2018.
  10. Poul-Henning Kamp (9 August 2022). "Varnish Cache 7.0.0 released" . Retrieved 9 August 2022.
  11. "Top Varnish performance metrics". Top Varnish performance metrics. Jul 28, 2015. Retrieved Sep 4, 2020.
  12. "How to collect Varnish metrics". How to collect Varnish metrics. Jul 28, 2015. Retrieved Sep 4, 2020.
  13. "varnishstat(1): HTTP accelerator statistics - Linux man page". linux.die.net. Retrieved Sep 4, 2020.
  14. "BackendPolling – Varnish". Varnish-cache.org. Archived from the original on 2010-08-21. Retrieved 2014-07-18.
  15. "VMODs Directory (Varnish Modules and Extensions) | Varnish Community". Varnish-cache.org. Retrieved 2014-07-18.
  16. "Saint Mode". Varnish. Archived from the original on 7 May 2011.
  17. "Grace Mode". Varnish. Archived from the original on 9 May 2011.
  18. Feryn, Thijs (2017). Getting Started with Varnish Cache: Accelerate Your Web Applications. O'Reilly Media, Inc. p. 85. ISBN   9781491972229.