VARNISH CACHE V/S CDN

Varnish Cache

Varnish is a reverse HTTP proxy, sometimes referred to as a HTTP accelerator or a web accelerator. It stores files or fragments of files in memory, allowing them to be served quickly. It is essentially a key/value store that usually uses the URL as a key. It is designed for modern hardware, modern operating systems and modern workloads.

Sitting in front of your website, Varnish Cache deals with serving static or quasi-static content directly, (It can cache certain static elements, such as images or JavaScript but you can also use it for other purposes such as Load balancing or some additional security.) without passing the request back to the web server (i.e. Apache) to process over and over again. Since a lot of content (despite the amount of time they will be accessed) needs to be computed and generated only once, storing and then serving them from the fast access memory greatly reduces the load bore by the web server and increases the amount of requests that can be simultaneously handled by our system as a whole.

To Note: Unless we use a separate application server instance for Varnish (which we should, for many good reasons!) this is technically not scaling (neither up, nor out), but having a good system architecture and basically being smart. However, due to the increase of load that can be handled by a single server, this could be referred to as scaling in some ways, as we are going to have much better overall performance from our system. This is really the result expected from scaling, and we end up with a system architecture that is ready to truly scale if necessary; however, it must be noted that better performance alone does not mean scaling.

 

At the same time, Varnish is flexible. The Varnish Configuration Language is lightning fast and allows the administrator to express their wanted policy rather than being constrained by what the Varnish developers want to cater for or could think of. Varnish has shown itself to work well both on large (and expensive) servers and tiny appliances.

Properties of Caching Reverse Proxy

A caching reverse proxy server typically has these properties:

  • Local (close) to the web application
  • Reduces the load on web/application servers for cacheable content
  • Can cache many kinds of content, including dynamically-generated content
  • Full control of cache flushes is with you
  • The web application is ‘unaware’ of the caching taking place and does not need to be  modified for the benefits of reverse proxy caching to be had

 

CDN (Content Delivery Network):

A content delivery network (CDN) is a system of distributed servers (network) that deliver webpages and other Web content to a user based on the geographic locations of the user, the origin of the webpage and a content delivery server. This service is effective in speeding the delivery of content of websites with high traffic and websites that have global reach. The closer the CDN server is to the user geographically, the faster the content will be delivered to the user. CDNs also provide protection from large surges in traffic.

Properties of a CDN

A CDN typically has the following properties:

  • A set of “edge” servers which are located in various distinct geographic locations
  • Suitable for slowly-changing content, because content propagation times are relatively high (hours)
  • Owned by a third party
  • Usually combined with custom DNS solutions (with low DNS TTL values) to effect the geo-direction
  • Disconnected (by design) from the web application
  • Typically serve “static” content such as images, Flash, video, etc.
  • Cannot effectively cache dynamically-generated content
  • URLs or applications often need to be modified to work with the CDN

Where to use Varnish Cache:

  • If you need to reduce load on web or application servers for common content, use a caching reverse proxy.
  • A caching reverse proxy reduces load on web/application servers and avoids unnecessary trips to a database or other content store for frequently-accessed content.

 

Where to use CDN:

  • If your users are geographically spread, use a CDN.
  • A CDN locates static content geographically close to end-users to avoid transmission delay

 Recommendation:

  • If you need to address above mentioned issues, use both a CDN and Varnish as a caching reverse proxy.
  • Varnish can sit in front of your site as an act as the caching gate keeper. A pull CDN will cache content/assets on the edge of the network. When a CDN node doesn’t have a copy of the page or asset it will call back to the origin (aka your server) for that item. If you don’t have Varnish in place and are using a CDN with many POPs (points of presence) your server will still get hammered with requests when adding new content.
Advertisements

About rajnautiyal
Experience in Design and Development of web projects in struts,hibernate,springs,ajax,Flex . Development .Experienced in the implementation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: