Wednesday, May 28, 2014

Accelerating Web Applications with Varnish - Notes

My Notes From: Accelerating Web Applications with Varnish
https://joind.in/10648
* About Me
Varnish is the first real revolutionary tech encountered

Static content continues to dominate the web
No One Likes Stale

Dynamic content is expensive to delivery but cheap to maintain

Content Delivery via HTTP (Historical)

Dynamic Backends
Databases! Venerable! Relational!
More and More Complex Databases Start to Be Terrible

SQL Query is Relational Algebra

Cacheing
Eliminate repeated interactions at cost of freshness.
Increases performance of course (throw in front of a DB)
Reddis: Cache and Datastore are starting to merge.
Cacheing proxies

Memcache is developer focused
CDN is not flexible
Static Pre-Rendering
  Just render all files statically and serve those
  Hides terrible performance
Cache Reverse Proxies
  Symfony2 Comes with a Reverse Proxy

Varnish 3 (Varnish 4 exists and is cool/fun)

Virtual Memory is a cache!
Caching-Reverse Proxies.. Squid writes objects to disk, written to memory when requested

Varnish works within the Operating Systems VM.
Trusts the kernel to do the kernel's job.

varnish-cache.org
varnish-software.com

VCL is Varnish Config Language (You can Inline C Programming if you are crazy)
VCL is compiled into memory and can be hard to configure

-f VCL file to load
-s Config storage
-T Where Varnish listens for admin
-a Where Varnish listens for HTTP

Backend - Apache, NGINX, etc.
Can use a cluster of backends.

Logical clusters of backends

Load Balancing to Varnish Server.
Varnish Server to Load Balanacing to Origin Servers.
Round Robin to a bunch of servers.

Directors are rules that Varnish follows so you can tell Varnish how to run

Probes
Kind of Object Oriented VCS. Something about Varnish 4.

ACLs
Bypass the proxy for local clients.

Hooks
Pre-defined points in the request-response cycle.
recv,pipe,pass,hit,miss
fech,backend_fech,

Grace Mode
If it can't access a resouces you can make it return the last available resouce.

Saint Mode
Return expired objects
200/50x

Managing Varnish
Command Line Interface is available

Purging is pretty simple.
PURGE /obsolete/resource
Clears memory
Not instantly happening

Banning Objects
Never delivery from cache, always origin.
Is Instant, but doesn't clear memor.

Vary
gzip/deflate are usually variations of the same thing so no need to try both.

Edge Side Includes
Varnish supports a subset of ESI
esi:include
esi:remove

Replaying Traffic
A log that can be played on cold Varnish to warm it up

Complex
A programming language that you have learn.
Default is an ugly flow chart.
It is C so you can break it easily.

Politico doesn't use memcached now.
All services live behind varnish servers.

Varnish -> Application -> Varnish -> API

VCL has "Objects" that are modular.
Modular Stuff!

Varnish does suport SSL (according to the documenation)

A/B Testing Server Side stuff would be terribly more difficult than the JS stuff we do.

No comments:

Post a Comment