Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

Hello < me irl

Slide 3

Slide 3 text

Lead Operations Engineer

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

Why this sucked

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

Current Generation edge shield app (python)

Slide 9

Slide 9 text

Why this is rad

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

edge shield app Onion skin view

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

edge 60,000 req/s

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

Cookies. as headers? Why?

Slide 19

Slide 19 text

Vary: Cookie-sessionid

Slide 20

Slide 20 text

shield 15,000 req/s

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

application 13,000 req/s

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

WaiT. 13,000 req/s still?

Slide 26

Slide 26 text

46% 53% 1% App Response Codes

Slide 27

Slide 27 text

46% 53% 1% App Response Codes 304 200

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

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

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

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