Boosting your website with Varnish
Posted in: Getting Started   -   August 6, 2012

The team at Varnish Software is very proud of Varnish Cache, our open source web application acceleration software, the world´s best web optimizer if you ask us. Backing us up in this belief is a dedicated community of worldwide users that actively contribute to the continuous development and quality of Varnish.

How can Varnish help you?

Varnish is designed to run on modern hardware under real workloads and to solve real problems while delivering top web site performance. Varnish is a reverse HTTP proxy, sometimes referred to as a HTTP accelerator or a web accelerator. What differentiates Varnish from other web accelerators is its outstanding flexibility that allows you to adopt the software to your needs. The Varnish Configuration Language is lightning fast and gives web administrators the freedom to express their wanted policy rather than being constrained by what the Varnish developers can, have defined or want to cater to. Varnish has proven to work very well both on large (and expensive) servers and tiny appliances.

Varnish is an open source project, or free software. The development process is public and everyone can submit patches, or just take a peek at the code if in doubt about how Varnish works. The Varnish community volunteeringly helps each other and newcomers with challenges they come across. The BSD-like license used by Varnish does not place significant restrictions on reuse of the code, which makes it possible to integrate Varnish in virtually any solution.

With Varnish Cache, Varnish Software can help customers boost the speed and scalability of their website as well as increase sales and customer loyalty while reducing costs and supporting green initiatives.

Who relies on Varnish?

Varnish Cache has been downloaded by over 600,000 users worldwide and is being actively used on 256,380 websites. Its usage is quickly growing and the software is commonly used among the world’s top websites as depicted in the chart below:

 

This chart represents Varnish web usage trends over the past year on a large selection of the world’s most visited websites queried by BuiltWith.

Leading websites all over the world rely on Varnish Cache for optimization, including Facebook, E-bay, Nokia, Vimeo and The New York Times.

How can you get started with Varnish?

Step 1: Install Varnish!

Installing Varnish is pretty straight forward. There are a number of pre-packaged binaries for Varnish (for Red Hat Enterprise Linux, Ubuntu and Debian), or you can get the source code if you like. Varnish is already included in many of the major distributions, but if you prefer the latest version, you will find it here: https://www.varnish-cache.org/releases

For high traffic sites it is usually simpler to install Varnish on a physical server, but it also runs just fine under most virtualization platforms. Varnish does not require a lot of CPU power and the memory usage depends greatly on your site. Some high traffic sites operate with 4GB of memory for Varnish, while others are known to use hundreds of gigabytes. Start with what you have. For operating system, we recommend Ubuntu, Debian or Red Hat Enterprise Linux / CentOS.

Step 2: Configure Varnish and your web server

If you run Varnish on a dedicated server, this is not that hard.

  • You need to modify the startup parameters in either /etc/default/varnish or /etc/sysconfig/varnish (depending on Operating System) and set the listening port to port 80 (-a :80).
  • Then you will want to edit /etc/varnish/default.vcl to reflect what web server you use. (You can read more about this either in the Varnish Book or the tutorial.)
  • Once you’ve configured it, you can restart Varnish with “service varnish restart”.

Step 3: Pointing your browser at the Varnish server

That’s really it! You should now be able to browse through Varnish using http://ip-to-varnish-server/. The cache hit rate might not be all that great in the beginning so head over to https://www.varnish-cache.org/docs/3.0/tutorial/increasing_your_hitrate.html to see how you can improve it. Usually cookies are the main cache killers in a fresh Varnish installation.

Take a look at the “varnishstat” program to see those requests fly by!

 

Resources

The Varnish Book, available here, is used as reference material in professional Varnish training courses and takes you through everything from history and installation to VCL and debugging. You can sign up for Varnish training here.

The reference documentation for Varnish can be found at https://www.varnish-cache.org/docs/3.0/ and includes all manual files provided, upgrade instructions and more.

Varnish Software provides service subscriptions, professional training and more.


Hrafnhildur Smaradottir is International Marketing Manager at Varnish Software and is located in Oslo, Norway. Varnish Software is the world's leading provider of open source web application acceleration software and helps customers make their websites fly.

Tags: , , , , ,