Varnish is an HTTP accelerator designed for content-heavy dynamic web sites. It sits in front of your web server. Varnish caches and stores web pages in memory so that web servers don't have to create the same web page over and over again. Varnish Cache serves pages much faster than any application server; giving the website a significant speed up. We have seen use cases with Varnish , where pages can be delivered sub-second to the browsers.Some of the salient features of Varnish are,
- High performance HTTP accelerator
- In-memory cache
- Flexible configuration through the power of the Varnish Configuration Language
- Load balancing based on URL, client IP, cookies and more
- Edit any HTTP request or response as it passes through Varnish
Varnish is usually suitable for applications like Online Newspapers/magazines , Online Classifieds , Media sites which has more read pages and less of write operations(Publish once - Read many).
Example : In an online newspaper site , content is published once and not updated often . But it is read by millions in a day. Varnish page caching is suitable because the once formed-published page can be cached and served from the Varnish Layer instead of hitting the web server.
In online classifieds scenario , ads will be published and will not change quite often. In some classified sites , the ads usually go through an approval process before published. In such scenarios the ads can be cached and served from Varnish itself.
While architecting an high performance website on AWS we can chose to have Varnish Layer at following levels in the stack:
Level 1: Varnish is the entry point for your website
Level 2: Varnish below the Amazon ELB / Load Balancer
In the following articles we go in depth on the above architectures and the best practices in designing them in AWS.