Boost your website’s performance using Varnish

Lees in het Nederlands - Lisez en français

What is Varnish? And why is Thijs Feryn so amazed by it? Here is a brief description of what the tool does, and why it has become the cornerstone of Combell’s Performance hosting.

Interview with Varnish

Varnish Software, the company behind the popular Varnish technology, invited Combell evangelist Thijs Feryn to give a talk at the Varnish Summit in Amsterdam. As a PHP expert, Thijs indeed finds that Varnish makes websites written in PHP much faster. As an influencer, he is thus the ideal person to spread the word. After his talk, the people at Varnish asked Thijs why he believes so strongly in Varnish.

In the interview, Thijs was very clear: Varnish speaks http; you just need to install it in front of a website, update the DNS record, link Varnish to the back-end, and you are good to go! Varnish is a real lifesaver; it is a much cheaper solution than having to rewrite all your code. But what specific problems can Varnish solve? And why is it so good at it?

Slow websites… Who is to blame?

A common problem with new or existing websites is that they work flawlessly as long as they are in a test phase, on their own systems, but as soon as they are on the final hosting servers and need to process large numbers of visitors, they begin to slow down. Websites whose content is retrieved from databases are particularly vulnerable to this problem, as we at Combell can witness.

But what causes this problem? Has the developer written bad code? Or maybe he should have developed a better database? One may also wonder if the infrastructure is efficient enough, if there is a sufficient amount of RAM, if the CPU is powerful enough, if there is a sufficient quantity of servers, if the servers have been configured correctly, so that the resources allocated to process queries are sufficient...

Websites that load slowly are as detrimental as websites that are completely down. The performance of a website is crucial for user experience.

Finger-pointing, however, does not make much sense. As a developer who works in an infrastructure environment, Thijs has faced this situation many times already at Combell. Sometimes, the code may not be scalable. And other times, the problem is that bad decisions are taken during the development of the architecture. But what we eventually need is a solution, and that is where Varnish is a real lifesaver.

Caching with Varnish makes web pages load faster

Varnish cacheThe keyword here is caching – and Varnish is the ideal tool for this. Dynamic data, which are generally retrieved on the fly from the database, are stored in static form so that they can be displayed faster.

Varnish actually behaves somewhat like a proxy server, as used when Internet connections were still slow. Back then, the content of websites was stored on proxy servers, so that content that had already been viewed by other users could be displayed faster.

“Why have some information recalculated when it has not been updated? Why waste resources for this?”

What Varnish does is create a reverse proxy: the server is not on the side of the user; it sits in the data centre. The results produced by the servers are stored in cache and delivered in static form to visitors. This, of course, helps save a lot of time, because requests do not have to be processed by the back-end servers every time. Dynamic websites using a Varnish cache are therefore much faster.

Thijs’s tips to improve Varnish performance

Most of your caching problems will be solved when you will combine a good caching strategy to your software strategy from the start. Consider e.g. the following:

  • Avoid using cookies where they are unnecessary.
  • Make sure to develop an efficient cache invalidation strategy. Storing static data in the cache is essential, but an overly aggressive caching strategy is definitely not a good idea.
  • Caching dynamic pages is the top priority; static files do not really need it.

However, not everything can be cached. Varnish Configuration Language will allow you to set rules in this regard.

More tips on using Varnish

The cornerstone of Combell’s Performance hosting

Thijs is not the only one to consider Varnish a priority; Combell also appreciates its unrivalled usefulness. Varnish has been successfully used for a few years now – sometimes as an emergency solution, when an existing website delivers poor performance, but more and more often as a real foundation, which is included in the project of the website since the beginning.

Combell therefore makes every effort to constantly broaden its knowledge of this technology and develop its expertise in this open source reverse proxy software. As a proof of this commitment, Combell evangelist and PHP expert Thijs Feryn is now invited across the world to give talks about Varnish. It is a true honour for Thijs – an honour that he shares with Combell!

Discover our Performance hosting!