Nucleus - Varnish e-book

Varnish is a web accelerator, a technical tool that can make your website quite a bit faster. That is of course what everyone wants, but Varnish is a complex tool. That means there is quite a bit of knowledge and effort required from both your developers and system administrator.

Because Varnish is so complex, we will try to explain in a couple of videos what Varnish is, how it works, what you can do with it, where the pitfalls are, and how you get started. In this first edition of “Chalk Talk” we explain what Varnish is.

The transcript of our Chalk Talk about Varnish

Welcome to Chalk Talk, a series of videos where we try to explain complicated technologies with just one chalkboard. In this video we are looking at Varnish.

What is Varnish?

Varnish is a web accelerator that you can introduce to your software stack to significantly improve the speed of your website. But first let’s look at what makes a website slow in the first place.

What slows down websites?

Traditionally, if you have a user behind his laptop visiting your site, he is going to connect to a webserver – an Apache or an Nginx – that in turn will trigger a PHP process that is going to hit your code. Your code will talk to a database like MySQL or PostgresSQL. It might talk to a cache like Redis or Memcached, or it might talk to external API’s that you don’t really have under control, like Facebook or Twitter API or things like it.

At the end of the day when all data is gathered, your PHP will generate a response to be handed over to your Apache webserver. The response is basically the HTML code that your client is going to see. And it delivers that to your client. But he is not very happy!

And the next person that comes to your webserver will trigger the exact same response, hitting Apache, followed by a PHP process, talking to the database or the API… You get the picture, it may take a while.
And at the end of the day, the response being given to that user is probably the same as the previous one. So why don’t we try to be smarter about that?

Is Varnish a smart solution?

If you start getting more and more visitors, traditionally you would use a bigger server. Or add another one. And another one. That doesn’t seem that efficient! So, how can we solve this with more finesse and more intelligence? We could introduce an additional layer on top of your Apache webserver, called Varnish.

Varnish is a simple tool that is going to keep previously sent responses in memory, to be served faster to the next visitor. So all this complicated logic will only be triggered once. The HTML response will be sent to Varnish. Varnish will send it to the visitor and the next visitor will just talk to Varnish, asking “give me your homepage”, and it can deliver that in milliseconds, without talking to PHP, MySQL, your API, you name it.

So this makes Varnish a web accelerator. Technically it is a proxy, sitting between the client and your webserver, but it accelerates your visitors.

Varnish as load balancer

Varnish can also act as load balancer. If the amount of visitors exceeds the capacity of a single server, you can add multiple web servers to serve all your visitors. Vanish can act as the middleman determining where that request should be sent. If your first webserver is unavailable, being in the maintenance or offline, Varnish will take that one out of commission and send requests to other available servers.

It also allows you to do rolling upgrades, where you gradually deploy your code to the next server without interrupting a visitor.

By introducing Varnish, you can create a smarter solution for scalability. Instead of throwing in more hardware, you introduce intelligence that eliminates CPU, memory and disk access. It makes everything a lot faster. If you introduce Varnish to your stack, you will have less PHP, less MySQL, less database. Basically, less of everything, and happier clients. The end result is a site that is a lot faster. Think milliseconds instead of seconds.

Better SEO results thanks to Varnish

On top of that, you have the benefit that sites like Google and Bing take the speed of your website as one of the indicators to determine the ranking of your site.

So the faster your site, the higher you can rank. You can’t do that with just PHP. You need to be smart and introduce a caching layer on top of that.

Next time on Chalk Talk?

In the next videos we’ll look at Varnish in depth. We will get into how you can use Varnish as a developer or sysadmin, develop a content strategy for your website, and how to make integrating Varnish into your project a success.

See you next time for a new episode of Chalk Talk!

Related posts
GDPR

GDPR: What do you have to know as a Nucleus customer?

GDPR, the new European regulation about privacy will be in effect starting May 25th 2018. But what does this new European law mean for […]

Read more

Uptime-as-a-Service

8 reasons why an ever increasing number of customers choose Uptime-as-a-Service

We strongly believe that Uptime-as-a-Service is the future of hosting. An ever-growing number of customers join us in that belief. KMDA, the umbrella organization of the Antwerp Zoo and Planckendael, and Antum, a start-up from Mechelen, recently testified about their choice for Uptime-as-a-Service.

Read more

HTTPS

Google Chrome will mark websites without HTTPS as not secure starting July 2018

Starting July 2018, the Google Chrome web browser will mark all websites that don’t use HTTPS, as not secure. In doing so, Google compels […]

Read more