Csdn Drdobbs Tenni Theurer Yahoo


Published on

Published in: Technology
1 Comment
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Csdn Drdobbs Tenni Theurer Yahoo

    1. High Performance Web Sites Tenni Theurer, Yahoo! Engineering Manager http://developer.yahoo.com/performance CSDN-Dr.Dobbs Software Development 2.0 Conference 2007
    2. slow crawl boring snail stagnant unexceptional yawn unresponsive impatient delay moderate blah subdue drag apathetic prolong slack load sluggish sleepy late unexciting reduced lag complex heavy unmemorable obscure why wait perceived response time what is the end user’s experience? performance speed enjoyable urgent instant accelerate perception snap achievement better improve action pleasant pace quick promote swift cool maximum drive prompt advance fast hurry rush satisfying feel exceptional brisk rapid exciting
    3. Exceptional Performance <ul><li>quantify and improve the performance of all Yahoo! products worldwide </li></ul><ul><li>center of expertise </li></ul><ul><li>build tools, analyze data </li></ul><ul><li>gather, research, and evangelize best practices </li></ul>
    4. Evolution of Performance <ul><li>quantify </li></ul><ul><li>-> profile </li></ul><ul><li>-> research, case studies </li></ul><ul><li>-> best practices </li></ul><ul><li>-> evangelize </li></ul><ul><li>-> codify </li></ul><ul><li> -> rollout </li></ul><ul><li> -> publicize </li></ul>
    5. Today's Checklist <ul><li>perspective on performance turned upside down </li></ul><ul><li>3+ actionable takeaways </li></ul><ul><li>empowered to make everyone's web experience better </li></ul>
    6. The Importance of Front-End Performance Back-end = 5% Front-end = 95% Even here, front-end = 88%
    7. The Performance Golden Rule <ul><li>80-90% of the end-user response time is spent on the front-end. Start there. </li></ul><ul><li>Greater potential for improvement </li></ul><ul><li>Simpler </li></ul><ul><li>Proven to work </li></ul>
    8. Agenda <ul><li>Performance Research </li></ul><ul><li>14 Rules </li></ul><ul><li>Case Studies </li></ul><ul><li>Evangelism </li></ul>
    9. <ul><li>Performance Research </li></ul>
    10. http://yuiblog.com/blog/2006/11/28/performance-research-part-1/
    11. Empty vs. Primed Cache <ul><li> empty cache </li></ul><ul><li>2.4 seconds </li></ul><ul><li> primed cache </li></ul><ul><li>0.9 seconds </li></ul><ul><li>83% fewer bytes </li></ul><ul><li>90% fewer HTTP requests </li></ul>
    12. http://yuiblog.com/blog/2007/01/04/performance-research-part-2/
    13. Browser Cache Experiment <ul><li>Add a new image to your page </li></ul><ul><li><img src= &quot; image/blank.gif &quot; height= &quot; 1 &quot; width= &quot; 1 &quot; /> </li></ul><ul><li>with the following response headers: </li></ul><ul><ul><li>Expires: Thu, 15 Apr 2004 20:00:00 GMT </li></ul></ul><ul><ul><li>Last-Modified: Wed, 28 Sep 2006 23:49:57 GMT </li></ul></ul>} 1 px
    14. Surprising Results 40-60% ~20% page views with empty cache users with empty cache
    15. Experiment Takeaways <ul><li>The empty cache user experience is more prevalent than you think! </li></ul><ul><li>Optimize for both primed cache and empty cache experience. </li></ul>
    16. http://yuiblog.com/blog/2007/03/01/performance-research-part-3
    17. Impact of Cookies on Response Time 80 ms delay dialup users +78 ms 156 ms 3000 bytes +63 ms 141 ms 2500 bytes +47 ms 125 ms 2000 bytes +31 ms 109 ms 1500 bytes +16 ms 94 ms 1000 bytes +1 ms 79 ms 500 bytes 0 ms 78 ms 0 bytes Delta Time Cookie Size keep sizes low
    18. .yahoo.com cookie sizes
    19. http://yuiblog.com/blog/2007/04/11/performance-research-part-4/
    20. Parallel Downloads Two components in parallel per hostname HTTP/1.1 GIF GIF GIF GIF GIF GIF
    21. Maximizing Parallel Downloads response time (seconds) aliases
    22. Maximizing Parallel Downloads response time (seconds) rule of thumb: use at least two but no more than four aliases
    23. Summary <ul><li>What the 80/20 Rule Tells Us about Reducing HTTP Requests </li></ul><ul><li>http://yuiblog.com/blog/2007/04/11/performance-research-part-4/ </li></ul><ul><li>Browser Cache Usage – Exposed! </li></ul><ul><li>http://yuiblog.com/blog/2007/01/04/performance-research-part-2/ </li></ul><ul><li>When the Cookie Crumbles </li></ul><ul><li>http://yuiblog.com/blog/2007/01/04/performance-research-part-2/ </li></ul><ul><li>Maximizing Parallel Downloads in the Carpool Lane </li></ul><ul><li>http://yuiblog.com/blog/2007/04/11/performance-research-part-4/ </li></ul>
    24. <ul><li>14 Rules </li></ul>
    25. 14 Rules <ul><li>Make fewer HTTP requests </li></ul><ul><li>Use a CDN </li></ul><ul><li>Add an Expires header </li></ul><ul><li>Gzip components </li></ul><ul><li>Put stylesheets at the top </li></ul><ul><li>Move scripts to the bottom </li></ul><ul><li>Avoid CSS expressions </li></ul><ul><li>Make JS and CSS external </li></ul><ul><li>Reduce DNS lookups </li></ul><ul><li>Minify JS </li></ul><ul><li>Avoid redirects </li></ul><ul><li>Remove duplicate scripts </li></ul><ul><li>Configure ETags </li></ul><ul><li>Make AJAX cacheable </li></ul>
    26. Rule 1: Make fewer HTTP requests <ul><li>CSS sprites </li></ul><ul><li>combined scripts, combined stylesheets </li></ul><ul><li>image maps </li></ul><ul><li>inline images </li></ul>
    27. CSS Sprites – Preferred <ul><li>size of combined image is less </li></ul><ul><li>not supported in Opera 6 </li></ul>http://alistapart.com/articles/sprites <span style=&quot; background-image: url('sprites.gif'); background-position: -260px -90px;&quot;> </span>
    28. Combined Scripts, Combined Stylesheets 3 7 youtube.com 1.5 6.5 Average 1 4 yahoo.com 1 3 wikipedia.org 2 2 myspace.com 1 9 msn.com 1 1 froogle.google.com 2 7 ebay.com 2 11 cnn.com 1 18 aol.com 1 3 amazon.com Stylesheets Scripts
    29. Combined Scripts, Combined Stylesheets <ul><li>combining six scripts into one eliminates five HTTP requests </li></ul><ul><li>challenges: </li></ul><ul><ul><li>develop as separate modules </li></ul></ul><ul><ul><li>number of possible combinations vs. loading more than needed </li></ul></ul><ul><ul><li>maximize browser cache </li></ul></ul><ul><li>one solution: </li></ul><ul><ul><li>dynamically combine and cache </li></ul></ul>
    30. Rule 2: Use a CDN <ul><li>distribute your static content before distributing your dynamic content </li></ul>youtube.com Akamai yahoo.com wikipedia.org Akamai, Limelight myspace.com SAVVIS msn.com google.com Akamai, Mirror Image ebay.com cnn.com Akamai aol.com Akamai amazon.com
    31. Rule 3: Add an Expires header <ul><li>not just for images </li></ul>26 days 0% 0/7 0/3 0/32 youtube.com 100% 75% 0% 80% 4% 55% 1% 48% 0% % n/a 4/4 1/1 23/23 yahoo.com 1 day 2/3 1/1 6/8 wikipedia.org 1 day 0/2 0/2 0/18 myspace.com 34 days 3/9 1/1 32/35 msn.com 454 days 0/1 0/1 1/23 froogle.google.com 140 days 0/7 0/2 16/20 ebay.com 227 days 2/11 0/2 0/138 cnn.com 217 days 6/18 1/1 23/43 aol.com 114 days 0/3 0/1 0/62 amazon.com Median Age Scripts Stylesheets Images
    32. Rule 4: Gzip components <ul><li>you can affect users' download times </li></ul><ul><li>90%+ of browsers support compression </li></ul>
    33. Gzip: not just for HTML <ul><li>gzip scripts, stylesheets, XML, JSON (not images, PDF) </li></ul>some some x youtube.com x x x yahoo.com x x x wikipedia.org x x x myspace.com deflate deflate x msn.com x x x froogle.google.com x ebay.com cnn.com some some x aol.com x amazon.com Stylesheets Scripts HTML
    34. Gzip Edge Cases <ul><li><1% of browsers have problems with gzip </li></ul><ul><ul><li>IE 5.5: </li></ul></ul><ul><ul><li>http://support.microsoft.com/default.aspx?scid=kb;en-us;Q313712 </li></ul></ul><ul><ul><li>IE 6.0: </li></ul></ul><ul><ul><li>http://support.microsoft.com/default.aspx?scid=kb;en-us;Q31249 </li></ul></ul><ul><ul><li>Netscape 3.x, 4.x </li></ul></ul><ul><ul><li>http://www.schroepl.net/projekte/mod_gzip/browser.htm </li></ul></ul><ul><li>consider adding Cache-Control: Private </li></ul><ul><li>remove ETags (Rule 13) </li></ul><ul><li>hard to diagnose; problem getting smaller </li></ul>
    35. Rule 5: Put stylesheets at the top <ul><li>stylesheets block rendering in IE </li></ul><ul><ul><li>http://stevesouders.com/examples/css-bottom.php </li></ul></ul><ul><li>solution: put stylesheets in HEAD (per spec) </li></ul><ul><li>avoids Flash of Unstyled Content </li></ul><ul><li>use LINK (not @import) </li></ul>
    36. Slowest is Fastest <ul><li>CSS at the bottom: </li></ul><ul><ul><li>resources load faster, but nothing renders </li></ul></ul><ul><li>CSS at the top: </li></ul><ul><ul><li>resources take longer, but render progressively </li></ul></ul><ul><li>@import at the top: </li></ul><ul><ul><li>same problems as bottom </li></ul></ul>right choice
    37. Rule 6: Move scripts to the bottom <ul><li>scripts block parallel downloads across all hostnames </li></ul><ul><li>scripts block rendering of everything below them in the page </li></ul><ul><li>IE and FF </li></ul><ul><ul><li>http://stevesouders.com/examples/js-middle.php </li></ul></ul>
    38. Rule 6: Move scripts to the bottom <ul><li>script defer attribute is not a solution </li></ul><ul><ul><li>blocks rendering and downloads in FF </li></ul></ul><ul><ul><li>slight blocking in IE </li></ul></ul><ul><li>solution: move them as low in the page as possible </li></ul>
    39. Rule 7: Avoid CSS expressions <ul><li>used to set CSS properties dynamically in IE </li></ul><ul><ul><li>width: expression( </li></ul></ul><ul><ul><li>document.body.clientWidth < 600 ? </li></ul></ul><ul><ul><li>“ 600px” : “auto” ); </li></ul></ul><ul><li>problem: expressions execute many times </li></ul><ul><ul><li>mouse move, key press, resize, scroll, etc. </li></ul></ul><ul><li>http://stevesouders.com/examples/expression-counter.php </li></ul>
    40. Rule 8: Make JS and CSS external <ul><li>inline: HTML document is bigger </li></ul><ul><li>external: more HTTP requests, but cached </li></ul><ul><li>variables </li></ul><ul><ul><li>page views per user (per session) </li></ul></ul><ul><ul><li>empty vs. primed cache stats </li></ul></ul><ul><ul><li>component re-use </li></ul></ul><ul><li>external is typically better </li></ul><ul><ul><li>home pages may be an exception </li></ul></ul>
    41. Post-Onload Download <ul><li>inline in front page </li></ul><ul><li>download external files after onload </li></ul><ul><ul><li>window.onload = downloadComponents; </li></ul></ul><ul><ul><li>function downloadComponents() { </li></ul></ul><ul><ul><li>var elem = document.createElement(&quot;script&quot;); </li></ul></ul><ul><ul><li>elem.src = &quot;http://.../file1.js&quot;; </li></ul></ul><ul><ul><li>document.body.appendChild(elem); </li></ul></ul><ul><ul><li>... </li></ul></ul><ul><ul><li>} </li></ul></ul><ul><li>speeds up secondary pages </li></ul>
    42. Dynamic Inlining <ul><li>start with post-onload download </li></ul><ul><li>set cookie after components downloaded </li></ul><ul><li>server-side: </li></ul><ul><ul><li>if cookie, use external </li></ul></ul><ul><ul><li>else, do inline with post-onload download </li></ul></ul><ul><li>cookie expiration date is key </li></ul><ul><li>speeds up all pages </li></ul>
    43. Rule 9: Reduce DNS lookups <ul><li>typically 20-120 ms </li></ul><ul><li>block parallel downloads </li></ul><ul><li>OS and browser both have DNS caches </li></ul>
    44. Rule 10: Minify JavaScript minify inline scripts, too no yes no no yes yes yes no no no Minify External? no www.youtube.com yes www.yahoo.com no www.wikipedia.org no www.myspace.com yes www.msn.com yes froogle.google.com no www.ebay.com no www.cnn.com no www.aol.com no www.amazon.com Minify Inline?
    45. Minify vs. Obfuscate minify – it's safer http://crockford.com/javascript/jsmin http://dojotoolkit.org/docs/shrinksafe not much difference Dojo Savings JSMin Savings Original 21K (25%) 17K (21%) 85K Average 10K (29%) 8K (22%) 34K www.youtube.com 16K (38%) 14K (34%) 42K www.wikipedia.org 24K (28%) 23K (27%) 88K www.myspace.com 24K (25%) 19K (20%) 98K www.cnn.com 4K (10%) 4K (10%) 44K www.aol.com 48K (24%) 31K (15%) 204K www.amazon.com
    46. Rule 11: Avoid redirects <ul><li>3xx status codes – mostly 301 and 302 </li></ul><ul><ul><li>HTTP/1.1 301 Moved Permanently </li></ul></ul><ul><ul><li>Location: http://stevesouders.com/newuri </li></ul></ul><ul><li>add Expires headers to cache redirects </li></ul><ul><li>worst form of blocking </li></ul>http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
    47. Redirects no yes – secondary page yes – secondary page yes – secondary page yes – initial page no yes – secondary page yes – initial page yes – secondary page no Redirects www.youtube.com www.yahoo.com www.wikipedia.org www.myspace.com www.msn.com froogle.google.com www.ebay.com www.cnn.com www.aol.com www.amazon.com
    48. Rule 12: Remove duplicate scripts <ul><li>hurts performance </li></ul><ul><ul><li>extra HTTP requests (IE only) </li></ul></ul><ul><ul><li>extra executions </li></ul></ul><ul><li>atypical? </li></ul><ul><ul><li>2 of 10 top sites contain duplicate scripts </li></ul></ul><ul><li>team size, # of scripts </li></ul>
    49. Rule 13: Configure ETags <ul><li>unique identifier returned in response </li></ul><ul><ul><li>ETag: &quot;c8897e-aee-4165acf0&quot; </li></ul></ul><ul><ul><li>Last-Modified: Thu, 07 Oct 2004 20:54:08 GMT </li></ul></ul><ul><li>used in conditional GET requests </li></ul><ul><ul><li>If-None-Match: &quot;c8897e-aee-4165acf0&quot; </li></ul></ul><ul><ul><li>If-Modified-Since: Thu, 07 Oct 2004 20:54:08 GMT </li></ul></ul><ul><li>if ETag doesn't match, can't send 304 </li></ul>
    50. The Problem with ETags <ul><li>ETag format </li></ul><ul><ul><li>Apache: inode -size-timestamp </li></ul></ul><ul><ul><li>IIS: Filetimestamp: ChangeNumber </li></ul></ul><ul><li>ETag for a single entity differs across servers, by default </li></ul><ul><li>Sites with >1 server return too few 304s </li></ul><ul><ul><li>((n-1)/n)% wasted downloads </li></ul></ul><ul><li>Remove them </li></ul><ul><ul><li>Apache: FileETag none </li></ul></ul><ul><ul><li>IIS: http://support.microsoft.com/kb/922703/ </li></ul></ul>
    51. Rule 14: Make AJAX cacheable <ul><li>XHR, JSON, iframe, dynamic scripts can still be cached (and minified, and gzipped) </li></ul><ul><li>a personalized response should still be cacheable for that person </li></ul>
    52. AJAX Example: Yahoo! Mail Beta <ul><li>address book XML request </li></ul><ul><ul><li>-> GET /yab/[...]&r=0.5289571053069156 HTTP/1.1 </li></ul></ul><ul><ul><li>Host: us.xxx.mail.yahoo.com </li></ul></ul><ul><ul><li>← HTTP/1.1 200 OK </li></ul></ul><ul><ul><li>Date: Thu, 12 Apr 2007 19:39:09 GMT </li></ul></ul><ul><ul><li>Cache-Control: private,max-age=0 </li></ul></ul><ul><ul><li>Last-Modified: Sat, 31 Mar 2007 01:17:17 GMT </li></ul></ul><ul><ul><li>Content-Type: text/xml; charset=utf-8 </li></ul></ul><ul><ul><li>Content-Encoding: gzip </li></ul></ul><ul><li>address book changes infrequently </li></ul><ul><ul><li>cache it; add last-modified-time in URL </li></ul></ul>
    53. <ul><li>Case Studies </li></ul>
    54. Case Study: <ul><li>move JS to onload </li></ul><ul><li>remove bottom tabs </li></ul><ul><li>avoid redirects </li></ul><ul><li>image sprites </li></ul><ul><li>host JS on CDN </li></ul><ul><li>combine JS files </li></ul>40-50%
    55. Preloading 5 4 2 b be bec beck beckh beckha beckham <ul><li>Download Search components: </li></ul><ul><ul><li>ysch_srp_20070319.js yschx_20070320a.css </li></ul></ul><ul><ul><li>flat2_search.gif </li></ul></ul><ul><ul><li>dropdown.gif </li></ul></ul><ul><ul><li>bulb1.gif </li></ul></ul><ul><ul><li>ar_next.gif </li></ul></ul><ul><ul><li>addmy.gif </li></ul></ul>3 1
    56. What about performance and Web 2.0 apps? <ul><li>client-side CPU is more of an issue </li></ul><ul><li>user expectations are higher </li></ul><ul><li>these rules still apply, new rules will come out </li></ul><ul><li>start off on the right foot </li></ul>
    57. Case Study: Mail Mail Classic User Workflow mail.yahoo.com view inbox folder read messages (x3) compose message confirm send total time: Time 2.40 s 4.98 s 6.39 s 2.21 s 2.10 s 18.08 s Time 12.48 s 1.52 s 1.53 s 0.34 s 0s 15.87 s Delta +420% -70% -76% -85% -100% -12%
    58. Evangelism <ul><li>Book </li></ul><ul><ul><li>High Performance Web Sites </li></ul></ul><ul><li>Conferences </li></ul><ul><ul><li>Yahoo! F2E Summit </li></ul></ul><ul><ul><li>Web 2.0 Expo </li></ul></ul><ul><ul><li>Rich Web Experience </li></ul></ul><ul><ul><li>CSDN-Dr. Dobbs </li></ul></ul><ul><li>Blogs </li></ul><ul><ul><li>YUI Blog: http://yuiblog.com/blog/category/performance </li></ul></ul><ul><ul><li>YDN Blog: http://developer.yahoo.com/performance/ </li></ul></ul><ul><li>Open Source YSlow </li></ul><ul><ul><li>OSCon </li></ul></ul><ul><ul><li>Ajax Experience </li></ul></ul><ul><ul><li>Blogher </li></ul></ul><ul><ul><li>Future of Web Apps </li></ul></ul>
    59. <ul><li>http://developer.yahoo.com/yslow/ </li></ul>
    60. Ten Top U.S Web Sites 139K 178K 106K 205K 221K 18K 275K 502K 182K 405K Page Weight 9.6 sec 5.9 sec 6.2 sec 7.8 sec 9.3 sec 1.7 sec 9.6 sec 22.4 sec 11.5 sec 15.9 sec Response Time D www.youtube.com A www.yahoo.com C www.wikipedia.org D www.myspace.com F www.msn.com A froogle.google.com C www.ebay.com F www.cnn.com F www.aol.com D www.amazon.com YSlow Grade
    61. <ul><li>Conclusion </li></ul>
    62. Takeaways <ul><li>focus on the front-end </li></ul><ul><li>harvest the low-hanging fruit </li></ul><ul><li>you do control user response times </li></ul><ul><li>small investment up front keeps on giving </li></ul><ul><li>LOFNO – be an advocate for your users </li></ul>
    63. Today's Checklist <ul><li>perspective on performance turned upside down </li></ul><ul><li>3+ actionable takeaways </li></ul><ul><li>empowered to make everyone's web experience better </li></ul>
    64. Tenni Theurer [email_address]
    65. CC Images Used <ul><li>&quot;Need for Speed&quot; by Amnemon: http://www.flickr.com/photos/marinacvinhal/379111290/ </li></ul><ul><li>&quot;Max speed 15kmh&quot; by xxxtoff: http://www.flickr.com/photos/xxxtoff/219781763/ </li></ul><ul><li>&quot;maybe&quot; by Tal Bright: http://www.flickr.com/photos/bright/118197469/ </li></ul><ul><li>&quot;takeout&quot; by dotpolka: http://www.flickr.com/photos/dotpolka/249129144/ </li></ul><ul><li>&quot;how do they do that&quot; by Fort Photo: http://www.flickr.com/ photos/fortphoto/388825145 / </li></ul><ul><li>&quot;Absolutely Nothing is Allowed Here&quot; by Vicki & Chuck Rogers: http://www.flickr.com/photos/two-wrongs/205467442/ </li></ul><ul><li>&quot;Zipper Pocket&quot; by jogales: http://www.flickr.com/photos/jogales/11519576/ </li></ul><ul><li>&quot;new briefcase&quot; by dcJohn: http://www.flickr.com/photos/dcjohn/85504455/ </li></ul><ul><li>&quot;Told you it was me!&quot; by Pug!: http://flickr.com/photos/pugspace/1277023154/ </li></ul><ul><li>&quot;Robert's Legion&quot; by dancharvey: http://www.flickr.com/photos/dancharvey/2647529/ </li></ul><ul><li>&quot;thank you&quot; by nj dodge: http://flickr.com/photos/nj_dodge/187190601/ </li></ul>