To the Edge of Web Performance and Beyond

1,601 views
1,521 views

Published on

An examination of ESI, who you should care and how you can use it in your Rails application.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,601
On SlideShare
0
From Embeds
0
Number of Embeds
10
Actions
Shares
0
Downloads
33
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

To the Edge of Web Performance and Beyond

  1. 1. To the Edge of Web Performance and Beyond Joshua Hull @joshbuddy http://github.com/joshbuddy
  2. 2. Preamble Joshua Hull @joshbuddy http://github.com/joshbuddy
  3. 3. Preamble Joshua Hull @joshbuddy http://github.com/joshbuddy joshbuddy@gmail.com (not switching to Python) Joshua Hull @joshbuddy http://github.com/joshbuddy
  4. 4. Preamble m e ! lo a d o w n D http://www.slideshare.net/joshbuddy/to-the-edge-of-web-performance-and-beyond Joshua Hull @joshbuddy http://github.com/joshbuddy
  5. 5. To the Edge of Web Performance and Beyond Joshua Hull @joshbuddy http://github.com/joshbuddy
  6. 6. To the Edge of Web Performance and Beyond Joshua Hull @joshbuddy http://github.com/joshbuddy
  7. 7. To the Edge of Web Performance and Beyond (with solutions!) Joshua Hull @joshbuddy http://github.com/joshbuddy
  8. 8. ESI Joshua Hull @joshbuddy http://github.com/joshbuddy
  9. 9. ESI Edge Side Includes Joshua Hull @joshbuddy http://github.com/joshbuddy
  10. 10. ESI Edge Side Includes (not the origin) (not only includes) Joshua Hull @joshbuddy http://github.com/joshbuddy
  11. 11. ESI Edge http://www.w3.org/Icons/w3c_icon.svg Side Includes 18/07/09 8:46 AM Joshua Hull @joshbuddy http://github.com/joshbuddy
  12. 12. ESI Edge Side Includes <esi:include src="http://www.example.com/new_user.html"/> Joshua Hull @joshbuddy http://github.com/joshbuddy
  13. 13. ESI Your caching is probably evil What does this ESI you speak of look like? How can I actually use ESI? Problems! Joshua Hull @joshbuddy http://github.com/joshbuddy
  14. 14. Your caching is probably evil Joshua Hull @joshbuddy http://github.com/joshbuddy
  15. 15. Your caching is probably evil Fast Fast Joshua Hull @joshbuddy http://github.com/joshbuddy
  16. 16. Your caching is probably evil (incorrect) Correct Joshua Hull @joshbuddy http://github.com/joshbuddy
  17. 17. Your caching is probably evil Caching is great Caching really sucks Joshua Hull @joshbuddy http://github.com/joshbuddy
  18. 18. Your caching is probably evil Caching is great Joshua Hull @joshbuddy http://github.com/joshbuddy
  19. 19. Your caching is probably evil Caching is great <html> <head> <title> My Page </head> </title Cache > <body> This pa ge rock </body> s. </html> Hard work Joshua Hull @joshbuddy http://github.com/joshbuddy
  20. 20. Your caching is probably evil Caching is great Everything is peachy Cache Cache Joshua Hull @joshbuddy http://github.com/joshbuddy
  21. 21. Your caching is probably evil Victory? Joshua Hull @joshbuddy http://github.com/joshbuddy
  22. 22. Your caching is probably evil Caching really sucks Joshua Hull @joshbuddy http://github.com/joshbuddy
  23. 23. Your caching is probably evil Caching really sucks Joshua Hull @joshbuddy http://github.com/joshbuddy
  24. 24. Your caching is probably evil Caching really sucks Expensive DB call Expensive filesystem magic Joshua Hull @joshbuddy http://github.com/joshbuddy
  25. 25. Your caching is probably evil User-specific Caching really sucks Result of web service DB intensive Other work ? Joshua Hull @joshbuddy http://github.com/joshbuddy
  26. 26. Your caching is probably evil Caching really sucks Joshua Hull @joshbuddy http://github.com/joshbuddy
  27. 27. Your caching is probably evil Caching really sucks 1 4 0er v ic es webs Joshua Hull @joshbuddy http://github.com/joshbuddy
  28. 28. Your caching is probably evil Fragment caching Joshua Hull @joshbuddy http://github.com/joshbuddy
  29. 29. Your caching is probably evil Fragment caching <html> <head> <title>My Page</title> </head> <body> <% cache do('my_fragment') %> This fragment rocks. <% end %> </body> </html> Joshua Hull @joshbuddy http://github.com/joshbuddy
  30. 30. Your caching is probably evil Fragment caching <html> <head> <title>My Page</title> is this </head> Who <body> ents’ <% cache do('my_fragment') %> fragm This fragment rocks. ller? <% end %> ontro </body> c </html> Joshua Hull @joshbuddy http://github.com/joshbuddy
  31. 31. Your caching is probably evil Fragment caching “Kitchen Sink” controllers MainController HomepageController NotAResourceController Joshua Hull @joshbuddy http://github.com/joshbuddy
  32. 32. Your caching is probably evil Fragment caching “Kitchen Sink” controllers MainController HomepageController NotAResourceController Bake controller logic Do a lot of extra logic into your fragments in your controller Joshua Hull @joshbuddy http://github.com/joshbuddy
  33. 33. Your caching is probably evil Fragment caching “Kitchen Sink” controllers MainController HomepageController NotAResourceController Bake controller logic Do a lot of extra logic into your fragments in your controller Not correct Not fast Joshua Hull @joshbuddy http://github.com/joshbuddy
  34. 34. Your caching is probably evil Joshua Hull @joshbuddy http://github.com/joshbuddy
  35. 35. Your caching is probably evil http://upload.wikimedia.org/wikipedia/en/8/8b/Akamai_logo.svg 18/07/09 8:44 AM Joshua Hull @joshbuddy http://github.com/joshbuddy
  36. 36. Your caching is probably evil http://upload.wikimedia.org/wikipedia/en/8/8b/Akamai_logo.svg 18/07/09 8:44 AM A web page = A bunch of resources + a bit of logic Joshua Hull @joshbuddy http://github.com/joshbuddy
  37. 37. Your caching is probably evil http://upload.wikimedia.org/wikipedia/en/8/8b/Akamai_logo.svg 18/07/09 8:44 AM A web page = A bunch of resources + a bit of logic E S I http://www.w3.org/TR/esi-lang Joshua Hull @joshbuddy http://github.com/joshbuddy
  38. 38. What does this ESI you speak of look like? Joshua Hull @joshbuddy http://github.com/joshbuddy
  39. 39. What does this ESI you speak of look like? include try vars choose Joshua Hull @joshbuddy http://github.com/joshbuddy
  40. 40. What does this ESI you speak of look like? include <esi:include src="URI" alt="URI" onerror="continue" /> Examples <esi:include src="/header" /> <esi:include src="/header" alt="/alternate-header" /> <esi:include src="/header" alt="/alternate-header" onerror="continue" /> Joshua Hull @joshbuddy http://github.com/joshbuddy
  41. 41. What does this ESI you speak of look like? try <esi:try> <esi:attempt> ... </esi:attempt> <esi:otherwise> ... </esi:otherwise> </esi:try> Example <esi:try> <esi:attempt> <esi:include src="/my-resource"/> </esi:attempt> <esi:except>This is bad</esi:except> </esi:try> Joshua Hull @joshbuddy http://github.com/joshbuddy
  42. 42. What does this ESI you speak of look like? choose <esi:choose> <esi:when test=”...”> ... </esi:when> <esi:otherwise> ... </esi:otherwise> </esi:choose> Example <html><body> <esi:choose> <esi:when test="$(HTTP_ACCEPT_LANGUAGE{ja})">I speak Japanese</esi:when> </esi:choose> <esi:otherwise> I don't speak it, sorry bout that. </esi:otherwise> </body></html> Joshua Hull @joshbuddy http://github.com/joshbuddy
  43. 43. What does this ESI you speak of look like? vars <esi:vars>...</esi:vars> Examples <esi:vars><img src="http://www.example.com/$(QUERY_STRING{greet})/hello.gif"/ ></esi:vars> <esi:vars>Your ID is $(HTTP_COOKIE{id})</esi:vars> Joshua Hull @joshbuddy http://github.com/joshbuddy
  44. 44. What does this ESI you speak of look like? variable substitution HTTP_ACCEPT_LANGUAGE Set (da, en-gb, en) HTTP_COOKIE Hash HTTP_HOST String HTTP_REFERER String HTTP_USER_AGENT Hash (os, version, browser) QUERY_STRING Hash Joshua Hull @joshbuddy http://github.com/joshbuddy
  45. 45. What does this ESI you speak of look like? other bits ==, !=, <, >, <=, >= Comparison ! Unary negation & Logical and | Logical or Joshua Hull @joshbuddy http://github.com/joshbuddy
  46. 46. How can I actually use ESI? Joshua Hull @joshbuddy http://github.com/joshbuddy
  47. 47. How can I actually use ESI? Solutions! Joshua Hull @joshbuddy http://github.com/joshbuddy
  48. 48. How can I actually use ESI? Actual working implementations Joshua Hull @joshbuddy http://github.com/joshbuddy
  49. 49. How can I actually use ESI? Taf2 / nginx-esi http://github.com/taf2/nginx-esi Taf2 / mongrel-esi http://github.com/taf2/mongrel-esi Qerub / rack-esi http://github.com/Qerub/rack-esi Varnish http://varnish.projects.linpro.no/ Joshbuddy / esi-for-rack http://varnish.projects.linpro.no/ Joshua Hull @joshbuddy http://github.com/joshbuddy
  50. 50. How can I actually use ESI? Taf2 / nginx-esi http://github.com/taf2/nginx-esi Taf2 / mongrel-esi A nd http://github.com/taf2/mongrel-esi ba bly Qerub / rack-esi pro re! http://github.com/Qerub/rack-esi mo Varnish http://varnish.projects.linpro.no/ Joshbuddy / esi-for-rack http://varnish.projects.linpro.no/ Joshua Hull @joshbuddy http://github.com/joshbuddy
  51. 51. How can I actually use ESI? Easy to work with Joshua Hull @joshbuddy http://github.com/joshbuddy
  52. 52. How can I actually use ESI? Joshbuddy / spackle http://github.com/joshbuddy/spackle Joshua Hull @joshbuddy http://github.com/joshbuddy
  53. 53. How can I actually use ESI? Joshbuddy / spackle http://github.com/joshbuddy/spackle Controller esi(:user_bar, :path => ":variable/$(HTTP_COOKIE{esi-cookie})", :binds => [:cookie]) do |esi_params| render :text => "variable is #{params[:variable]}, cookie is #{params[:cookie]}" end Joshua Hull @joshbuddy http://github.com/joshbuddy
  54. 54. How can I actually use ESI? Joshbuddy / spackle http://github.com/joshbuddy/spackle Controller esi(:user_bar, :path => ":variable/$(HTTP_COOKIE{esi-cookie})", :binds => [:cookie]) do |esi_params| render :text => "variable is #{params[:variable]}, cookie is #{params[:cookie]}" end def user_bar # setup ... user_bar_body end def user_bar_body # your block end Joshua Hull @joshbuddy http://github.com/joshbuddy
  55. 55. How can I actually use ESI? Joshbuddy / spackle http://github.com/joshbuddy/spackle View <%=esi_include(:user_bar, :test => "testing") %> <% esi_try do %> <% esi_attempt do %> <%=esi_include(:user_bar, :test => "testing") %> <% end %> <% end %> <% esi_include do %> <%=esi_src(:user_bar, 'testing') %> <%=esi_alt("http://www.slashdot.org/") %> <% end %> Joshua Hull @joshbuddy http://github.com/joshbuddy
  56. 56. How can I actually use ESI? Security Joshua Hull @joshbuddy http://github.com/joshbuddy
  57. 57. How can I actually use ESI? Joshbuddy / rack-tamperproof http://github.com/joshbuddy/rack-tamperproof Joshua Hull @joshbuddy http://github.com/joshbuddy
  58. 58. How can I actually use ESI? Joshbuddy / rack-tamperproof http://github.com/joshbuddy/rack-tamperproof use Rack::Tamperproof(:default_key => "123u9ew90uqn") do delete_for :just_delete_this exception_for :don_t_tamper end # delete_for cookies will delete if they are tampered # with and your request passes through normally # # exception_for produces an exception if the cookie # is tampered with Joshua Hull @joshbuddy http://github.com/joshbuddy
  59. 59. Problems! Joshua Hull @joshbuddy http://github.com/joshbuddy
  60. 60. Problems! Specification can be vague Implementations support different features Spackle doesn’t have tests Joshua Hull @joshbuddy http://github.com/joshbuddy
  61. 61. Questions Joshua Hull @joshbuddy http://github.com/joshbuddy

×