• Save
VCLをTDDで書いてデプロイする
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

VCLをTDDで書いてデプロイする

  • 4,870 views
Uploaded on

#v3rp #v3rp_tokyo #tokyovcl

#v3rp #v3rp_tokyo #tokyovcl

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
4,870
On Slideshare
2,690
From Embeds
2,180
Number of Embeds
17

Actions

Shares
Downloads
0
Comments
0
Likes
5

Embeds 2,180

http://d.hatena.ne.jp 1,677
http://flavors.me 411
http://webcache.googleusercontent.com 20
http://infra.rrdtool.net 12
http://jp.flavors.me 11
http://es.flavors.me 9
http://hmsk.flavors.me 9
url_unknown 9
http://pt.flavors.me 7
http://www.slideshare.net 3
http://www.hatena-anohito.appspot.com 3
http://coderwall.com 2
http://cc.bingj.com 2
http://fr.flavors.me 2
http://de.flavors.me 1
http://whooo.heroku.com 1
https://www.google.com 1

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Transcript

  • 1. TDD VCL @hmsk 2011/06/18
  • 2. @hmskKengo Hamasaki / @hmsk / id:hxmasaki Varnish2.1.5Varnish, Maatkit, Android, DevOps
  • 3. VCL
  • 4. VCLVarnish Configuration LanguageVCL -> C -> Binary varnishd 1 ...etc
  • 5. http://www.varnish-cache.org/trac/wiki/VarnishInternals
  • 6. http://www.varnish-cache.org/trac/wiki/VarnishInternals
  • 7. http://www.varnish-cache.org/trac/wiki/VarnishInternals
  • 8. sub vcl_fetch { unset beresp.http.Set-Cookie; if (!beresp.cacheable) { return (pass); } else if (beresp.status > 200) { set beresp.ttl = 0m; } else { set beresp.ttl = 1h; } return (deliver); }http://www.varnish-cache.org/trac/wiki/VarnishInternals
  • 9. ...?
  • 10. VCL
  • 11. VCL <-
  • 12. VCL <-
  • 13. VCL <- <-
  • 14. VCL <- Message from VCC-compiler: Expected an action, if, { or } (input Line 19 Pos 5) purge_url(req.url); <- ----#########---------- Running VCC-compiler failed, exit 1
  • 15. VCL <- <- <-
  • 16. VCL <- log "[purge]" req.url; log "[pipe]"req.url; log "[hit]"req.url; <- log "[miss]"req.url; log "[healthcheck-fail-OtherVarnish!]"req.url; <-
  • 17. VCL <- <- <-
  • 18. We need Tests !
  • 19. bin/varnishtest
  • 20. bin/varnishtest varnishncsavarnilog varnishsizesvarnishreplay varnishtestvarnishstatvarnishtopvarnishadmvarnishhist
  • 21. bin/varnishtest varnishncsavarnilog varnishsizesvarnishreplay varnishtestvarnishstatvarnishtopvarnishadmvarnishhist
  • 22. varnishtestVCL VarnishVarnish (ACL)
  • 23. varnishtestVCL Varnish # Start a varnish instance called "v1" varnish v1 -arg "-b localhost:9080" -startVarnish (ACL)
  • 24. varnishtestVCL VarnishVarnish (ACL)
  • 25. varnishtest # Create a server thread called "s1"VCL server s1 { Varnish # Receive a request rxreqVarnish # Send a standard response (ACL) txresp -hdr "Connection: close" -body "012345n" } # Start the server thread server s1 -start
  • 26. varnishtestVCL VarnishVarnish (ACL)
  • 27. varnishtest # Create a client thread called "c1"VCL client c1 { Varnish # Send a request txreq -url "/"Varnish # Wait for a response (ACL) rxresp # Insist that it be a success expect resp.status == 200 }
  • 28. $ varnishtest -v varnishtest.vcltest
  • 29. TDD VCL /
  • 30. TDD VCL /
  • 31. ...!
  • 32. VCL
  • 33. VarnishMac Homebrew $ brew install varnish3 https://gist.github.com/1027753
  • 34. Vim (vcl.vim) http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/ vim-syntax-vcl/vcl.vimEmacs (vcl-mode.el) http://varnish-cache.org/svn/trunk/varnish-tools/ emacs/vcl-mode.el
  • 35. watchr varnishtest
  • 36. watchr varnishtest[hamasaki@] # cat varnishtest.watchrwatch((.*).vtest) { |md| system("/usr/local/bin/varnishtest -v #{md[0]}") }
  • 37. Capistrano
  • 38. $ cap varnish:deploy$ cap varnish:purge github
  • 39. VMOD
  • 40. VMODhttp://www.varnish-cache.org/docs/trunk/reference/vmod.htmlVarnish 3.0VCL VCLVMODVCL
  • 41. VMOD ... VCL ...
  • 42. VMOD if (req.http.Accept-Encoding) { if (req.url ~ ".(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg) $") { # No point in compressing these unset req.http.Accept-Encoding; } else if (req.http.User-Agent ~ "MSIE 6") { unset req.http.Accept-Encoding; ... } else if (req.http.Accept-Encoding ~ "gzip") { set req.http.Accept-Encoding = "gzip"; VCL } else if (req.http.Accept-Encoding ~ "deflate") { set req.http.Accept-Encoding = "deflate"; } else { # unknown algorithm unset req.http.Accept-Encoding; } ... }
  • 43. https://github.com/varnish/libvmod-example
  • 44. VCL TDD ->VMOD
  • 45. Thank you !TDD VCL @hmsk 2011/06/18