VARNISH

varnish cache

By virtue of being open source software, Varnish was primarily designed as an HTTP accelerator focussing on content dynamic websites. It is exclusively focussed on HTTP against any other network protocols. It is often used by high-traffic websites including online newspapers. Installing Varnish can speed up a website while reducing the load on the web server. In other words, it stands as an intermediate between the web server and the client.

In real time, web requests don’t simply mean receiving HTTP requests and returning responses. As every server is different, a typical web server has to go through a potentially long sequence of steps to service each request. Sometimes, new processes will have to be created or it may have to load required files and handle extensive database queries. Now multiply thousands of such queries and then it will be clear what a herculean task it is..! To make matters worse, many requests are simply repeats, because of which the web server has to repeat the entire process so as to handle the same request again.

If varnish cache is installed, the initial requests will be handled by varnish instead of the web server. Varnish will first verify what request is being received and then forward it to the web server. The web server will then perform its regular process and return with a response. It is Varnish, which gives the response to the client who sent the original request. The positive feature, which helps to speed up requests, is that Varnish can store responses from backend in its cache (not on disk) for future use. Hence, the forthcoming requests can be served quickly without causing any load on the web server and this enables the server to handle more requests per second. Sites with minimal user interaction and more static websites are best suited for installing varnish cache.

Overview of configuration files:

The configuration files of varnish are /etc/sysconfig/varnish and /etc/varnish/varnish.vcl.

The file /etc/sysconfig/varnish contains all the environment variables that are required for the varnish to work properly and also the global configuration such as which port it should run on and where it should store is its cache.

The file /etc/varnish/varnish.vcl contains the values for the caching policy of varnish. In this file, we specify when to cache, when not to cache and how long to cache.

We can configure varnish by using custom Varnish Configuration Language.

Varnish is a fantastic way of caching anything that the web server responds to. It can dramatically reduce the workload your web server actually takes. The greatest advantage is that without making any changes on the code, you can improve the performance of the website. So why not choose Varnish instead of wasting the server resources, while regenerating the same content each time?

 

 

Written by admin

Leave a Reply

Your email address will not be published. Required fields are marked *