Getting the most out of Varnish (DrupalCamp Galway 2014)

Getting the most out of Varnish (DrupalCamp Galway 2014)

Best practices for tuning cache configuration
Recording: https://www.youtube.com/watch?v=u0G6PUe-n30&feature=youtu.be

3abfc9128fe1aeae3058edc36936f360?s=128

Jochen Lillich

November 07, 2014
Tweet

Transcript

  1. Getting the most out of Varnish

  2. Basics • Reverse HTTP caching proxy • Load balancing •

    High performance • No SSL • Avoids "Thundering herd" • Caching logic in VCL
  3. Setup

  4. Configure sane resource limits • cache memory • thread_pools •

    threadpoolmin, threadpoolmax
  5. Caching logic

  6. vcl_recv • Normalize and rewrite client input • Pick a

    backend web server • Decide caching policy • Access control
  7. Enable grace mode

  8. Drop unnecessary cookies

  9. Force pass for sensitive URLs

  10. vcl_hash • Defines what is unique about a request. •

    Executed directly after vcl_recv
  11. Do not Vary on User- Agent

  12. vcl_hit • Right after an object has been found (hit)

    in the cache • You can change the TTL or issue purge • Often used to throw out an old object
  13. vcl_miss • Right after an object was looked up and

    not found in cache • Mostly used to issue purge • Can also be used to modify backend request headers
  14. vcl_pass • Run after a pass in vcl_recv or after

    a lookup that returned a hitpass • Not run after vcl_fetch
  15. vcl_fetch • Sanitize server response • Override cache duration

  16. Understand hit_for_pass

  17. vcl_deliver • Common last exit point for all (except vcl_pipe)

    code paths • Often used to add and remove debug-headers
  18. Application

  19. Use Far Future Expiration

  20. Operation

  21. Monitor KPI • cache_hit • cache_miss • backend_fail • backend_toolate

    • lru_nuked
  22. Monitor syslog

  23. Questions?

  24. Thanks! • Sad Cookie by Hey Paul Studios, on Flickr