Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Varnish: How We Do It

Varnish: How We Do It

SF Varnish Meetup
June 1st, 2015

Matt Robenolt

June 01, 2015
Tweet

More Decks by Matt Robenolt

Other Decks in Technology

Transcript

  1. Varnish:
    How we do it
    SF Varnish Meetup
    June 1st 2015
    Matt Robenolt

    View Slide

  2. Hello
    < me irl

    View Slide

  3. Lead Operations Engineer

    View Slide

  4. First Generation
    edge
    (haproxy)
    shield
    app
    (python)
    Failover

    View Slide

  5. Why this sucked

    View Slide

  6. Duplicate routing logic
    Complex Caching logic
    WasteD RAM for failover
    Why this sucked

    View Slide

  7. Failover == lose all cache
    Varnish held cache rules
    Hard to add/remove backends
    Why this sucked

    View Slide

  8. Current Generation
    edge
    shield
    app
    (python)

    View Slide

  9. Why this is rad

    View Slide

  10. App owns all caching logic
    Unified request routing
    Utilize RAM from all nodes
    Why this is rad

    View Slide

  11. If-Modified-Since
    Vary on cookie values
    Less deploys to Varnish
    Why this is rad

    View Slide

  12. 60,000
    15,000
    13,000
    Caching funnel
    edge
    shield
    app

    View Slide

  13. edge
    shield
    app
    Onion skin view

    View Slide

  14. edge
    shield
    app
    recv
    pass
    fetch
    hit
    miss
    hash
    synth
    fetch
    deliver
    error
    Onion skin view

    View Slide

  15. edge 60,000 req/s

    View Slide

  16. edge
    Closest to users (geographically)
    Absorbs most traffic
    Blocks abuse
    60,000 req/s

    View Slide

  17. edge
    Makes decisions for shield
    Sort querystrings (boltsort/std)
    Promote cookies to headers
    60,000 req/s

    View Slide

  18. Cookies.
    as headers?
    Why?

    View Slide

  19. Vary: Cookie-sessionid

    View Slide

  20. shield 15,000 req/s

    View Slide

  21. shield
    Routing to app backends
    Serve stale content (grace)
    Do If-modified-Since
    15,000 req/s

    View Slide

  22. shield
    Parse response cache rules
    Backend healthchecks
    Store lots of content
    15,000 req/s

    View Slide

  23. application 13,000 req/s

    View Slide

  24. application
    Declare response cache rules
    Respond to If-modified-Since
    13,000 req/s

    View Slide

  25. WaiT.
    13,000 req/s still?

    View Slide

  26. 46%
    53%
    1%
    App Response Codes

    View Slide

  27. 46%
    53%
    1%
    App Response Codes
    304
    200

    View Slide

  28. miss Hit Hit/update
    If-Modified-Since
    Hit/IMS
    200 OK 200 OK 304 Not Modified
    v1 v2

    View Slide

  29. tl;dr
    60k req -> 7k at app
    Every request thru Varinsh
    Complex logic written once

    View Slide

  30. tl;dr
    App has complete control
    We still <3 haproxy
    Each layer worth deep dive

    View Slide

  31. We’re hiring people
    who hate comptuers.
    disqus.com/jobs

    View Slide

  32. Check it.
    HTTP for Great Good
    speakerdeck.com/mattrobenolt/http-for-great-good
    Cheating Your Way to
    #webscale
    speakerdeck.com/mattrobenolt/cheating-your-way-to-webscale

    View Slide

  33. Questions? I have answers.
    ^
    github.com/mattrobenolt
    @mattrobenolt
    some

    View Slide