Top Banner
THE 7 HABITS OF EXCEPTIONAL PERFORMANCE Stoyan Stefanov http://phpied.com Nicole Sullivan http://stubbornella.org
72
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 7 Habits of Exceptional Performance

THE 7 HABITS OF EXCEPTIONAL PERFORMANCE

Stoyan Stefanovhttp://phpied.com

Nicole Sullivanhttp://stubbornella.org

Page 2: 7 Habits of Exceptional Performance

Quantify and improve the performance of all Yahoo!

products worldwide

Page 3: 7 Habits of Exceptional Performance

Y! Performance Research Engineering Team

Nicole Sullivan, Anande Kishore (intern), Stoyan Stefanov, Philip Tellis, Swapnil Shinde

Page 4: 7 Habits of Exceptional Performance

Why talk about performance?

Page 5: 7 Habits of Exceptional Performance

1: Because fast is better

Page 6: 7 Habits of Exceptional Performance

6

Page 7: 7 Habits of Exceptional Performance
Page 8: 7 Habits of Exceptional Performance
Page 9: 7 Habits of Exceptional Performance

9

Page 10: 7 Habits of Exceptional Performance

10

Page 11: 7 Habits of Exceptional Performance

11

Page 12: 7 Habits of Exceptional Performance

12

Page 13: 7 Habits of Exceptional Performance

2: Because sites are bigger

Page 14: 7 Habits of Exceptional Performance

Modern web sites & applications have changed

architecturally.

Page 15: 7 Habits of Exceptional Performance

From 2003 to 2008:97K to 312K.

25.7 to 49.9 objects.

Page 16: 7 Habits of Exceptional Performance

In past 12 months, Top 1000 sites:From 250K to 310.4K.

WebSiteOptimization.com/speed/tweak/average-web-page

Page 17: 7 Habits of Exceptional Performance

3: Time is money

Page 18: 7 Habits of Exceptional Performance

+100 ms

Page 19: 7 Habits of Exceptional Performance

Amazon:1% drop in sales

+100 ms

Page 20: 7 Habits of Exceptional Performance

+400 ms

Page 21: 7 Habits of Exceptional Performance

Yahoo!: 5-9% drop in full-page traffic

+400 ms

Page 22: 7 Habits of Exceptional Performance

+500 ms

Page 23: 7 Habits of Exceptional Performance

Google: 20% fewer searches

+500 ms

Page 24: 7 Habits of Exceptional Performance

What is performance?

Page 25: 7 Habits of Exceptional Performance

Two Flavors:Response Time

&System Efficiency

Page 26: 7 Habits of Exceptional Performance

Our focus is the response time of web

products

Page 27: 7 Habits of Exceptional Performance

Performance Fruit(some low, some high)

Page 28: 7 Habits of Exceptional Performance
Page 29: 7 Habits of Exceptional Performance

After YSlow “A”?1. Flush the buffer early

2. Use GET for AJAX requests

3. Post-load components

4. Preload components

5. Reduce the number of DOM elements

6. Split components across domains

7. Minimize the number of iframes

8. No 404s

9. Reduce cookie size

10. Use cookie-free domains for components

11. Minimize DOM access

12. Develop smart event handlers

13. Choose <link> over @import

14. Avoid filters

15. Optimize images

16. Optimize CSS sprites

17. Don't scale images in HTML

18. Make favicon.ico small and cacheable

19. iPhone 3G Breakthrough

20. Pack components into a multipart document

Page 30: 7 Habits of Exceptional Performance

After YSlow “A”?1. Flush the buffer early

2. Use GET for AJAX requests

3. Post-load components

4. Preload components

5. Reduce the number of DOM elements

6. Split components across domains

7. Minimize the number of iframes

8. No 404s

9. Reduce cookie size

10. Use cookie-free domains for components

11. Minimize DOM access

12. Develop smart event handlers

13. Choose <link> over @import

14. Avoid filters

15. Optimize images

16. Optimize CSS sprites

17. Don't scale images in HTML

18. Make favicon.ico small and cacheable

19. iPhone 3G breakthrough New!

20. Pack components into a multipart document

Page 31: 7 Habits of Exceptional Performance

Flush the buffer early

#1

Let the browser work while server is busy

Page 32: 7 Habits of Exceptional Performance

Com pon e n ts

down load in

paralle l with

HTML Text

Let the browser work while server is busy

#1

Page 33: 7 Habits of Exceptional Performance

Use GET for Ajax requests

• GET is for retrieving data

• GET request is one TCP packet (unless you have a lot of cookies)

• Max URL length 2K (because of IE)

• Yahoo! Mail Research

• POST without actually posting data is like GET

• POST is a two-step process (send headers, send data)

#2

Page 34: 7 Habits of Exceptional Performance

Post-load components

#3

Ask yourself: what's absolutely required in order to render the page initially?

Page 35: 7 Habits of Exceptional Performance

• Extras can wait (drag and drop, animations, hidden content, images below the fold)

• JavaScript is ideal candidate for splitting

• YUI Image Loader

• YUI Get Utility

Example: Yahoo.com

Page 36: 7 Habits of Exceptional Performance

Preload ComponentsPreload items you'll need in the future

#4

Page 37: 7 Habits of Exceptional Performance

3 flavorsUnconditionalConditional Anticipated

Page 38: 7 Habits of Exceptional Performance

Unconditional Preloadgoogle.com

Page 39: 7 Habits of Exceptional Performance

Conditional Preloadyahoo.com

Page 40: 7 Habits of Exceptional Performance

Anticipated Preload• Of course it’s slow:

• 100% of page views are with an empty cache.

• New Feature or full redesign?

• Preload components before launch;

• users will already have a primed cache when you go live.

“The redesign is cool, but it’s so slow!”

Page 41: 7 Habits of Exceptional Performance

Avoid filtersWhy is the AlphaImageLoader used?

IE6 and earlier don’t natively support alpha transparency. This filter forces that support.

#14

Page 42: 7 Habits of Exceptional Performance

Problem with filters

• Blocks rendering, freezes the browser

• Increased memory consumption

• Per element, not per image!

Page 43: 7 Habits of Exceptional Performance

Solution: Avoid AlphaImageLoader

1. BEST: avoid completely, use PNG8 which degrades gracefully in IE < 7

2. Fallback: use underscore hack so the filter is applied only to IE < 7

#elem {

background: url(some.png);_background: none;_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader (src='some.png', sizingMethod='crop');

}

Page 44: 7 Habits of Exceptional Performance

Progressively enhanced PNG8

Build a binary transparency image. In Fireworks, add a few alpha

transparent pixels.

Page 45: 7 Habits of Exceptional Performance

Good browsers get moreAnd the dinosaurs get an acceptable fallback

Page 46: 7 Habits of Exceptional Performance

Experimental DataRemoving Alpha Image Loader

100msYahoo! search

Page 47: 7 Habits of Exceptional Performance

iPhone 3G1000Kb cache limit

#19

Page 48: 7 Habits of Exceptional Performance

iPhone Cache has evolved

25Kb component limit no longer exists.Total cache limit is 1000K.

Cache limitations are not affected by gzipping.

Page 49: 7 Habits of Exceptional Performance

7 HABITS OF HIGH PERFORMANCE

Baking performance into development

Page 50: 7 Habits of Exceptional Performance

1. LOFNOLook out for number one!

Page 51: 7 Habits of Exceptional Performance

2. Harvest the low-hanging

fruitPick your battles, some

performance optimizations are easier to implement.

(Run YSlow)

Page 52: 7 Habits of Exceptional Performance

3. Balance features with speed

Page 53: 7 Habits of Exceptional Performance

Balancing the performance budget

Page 54: 7 Habits of Exceptional Performance

Three steps.

• Measure current performance and trends

• Estimate performance impact of all new features

• Estimate impact of all performance improvements.

Page 55: 7 Habits of Exceptional Performance

Estimates, how? track:

• Page Weight *

• Response Time

• HTTP requests

* For more complex sites, track page weight by component type; CSS, JS, Images, Flash

Page 56: 7 Habits of Exceptional Performance

Features = Optimizations

Page 57: 7 Habits of Exceptional Performance

Verify assumptions.

• Was the performance impact of each featurewhat you estimated it would be?

• Did the optimizations help as much as you thought they would?

Page 58: 7 Habits of Exceptional Performance

Allocate time, balance the budget

Performance Improvements versus

New Features

58

Page 59: 7 Habits of Exceptional Performance

4. Make performance part of the

processAvoid the response time roller

coaster.

Page 60: 7 Habits of Exceptional Performance

5. Measure and track results

Measurement is the first step to improvement.

Page 61: 7 Habits of Exceptional Performance

FirebugWeb development evolved.

Free.

Page 62: 7 Habits of Exceptional Performance

IBM Page Detailer

Packet sniffer. Windows only (IE, FF, any .exe). Free trial, $300 license

http://alphaworks.ibm.com/tech/pagedetailer

Page 63: 7 Habits of Exceptional Performance

LiveHTTPHeadersView HTTP headers. Firefox

extension. Free.

Page 64: 7 Habits of Exceptional Performance

YSlowPerformance insights and

analysis tool. Free.

Page 65: 7 Habits of Exceptional Performance

Gomez3rd party measurements. Competitor comparisons.

Page 66: 7 Habits of Exceptional Performance

Smush itImage Optimizationhttp://smushit.com

Page 67: 7 Habits of Exceptional Performance

6. Set targets

Page 68: 7 Habits of Exceptional Performance

7. Ask questions and challenge

answersEven smart people make

assumptions or repeat incorrect statements.

Page 69: 7 Habits of Exceptional Performance

Linksbook: http://www.oreilly.com/catalog/9780596514211/ examples: http://stevesouders.com/examples/ image maps: http://www.w3.org/TR/html401/struct/objects.html#h-13.6 CSS sprites: http://alistapart.com/articles/sprites inline images: http://tools.ietf.org/html/rfc2397 jsmin: http://crockford.com/javascript/jsmin dojo compressor: http://dojotoolkit.org/docs/shrinksafe HTTP status codes: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html IBM Page Detailer: http://alphaworks.ibm.com/tech/pagedetailer Fasterfox: http://fasterfox.mozdev.org/LiveHTTPHeaders: http://livehttpheaders.mozdev.org/Firebug: http://getfirebug.com/ YUIBlog: http://yuiblog.com/blog/2006/11/28/performance-research-part-1/ http://yuiblog.com/blog/2007/01/04/performance-research-part-2/ http://yuiblog.com/blog/2007/03/01/performance-research-part-3/ http://yuiblog.com/blog/2007/04/11/performance-research-part-4/YDN: http://developer.yahoo.net/blog/archives/2007/03/high_performanc.html http://developer.yahoo.net/blog/archives/2007/04/rule_1_make_few.html

Page 70: 7 Habits of Exceptional Performance

CC Images Used“Zipper Pocket” by jogales: http://www.flickr.com/photos/jogales/11519576/

“Need for Speed” by Amnemona: http://www.flickr.com/photos/marinacvinhal/379111290/

“I wonder what flavour it is?” by blather: http://www.flickr.com/photos/deadlyphoto/411770353/

“takeout boxes from Grand Shanghai” by massdistraction: http://www.flickr.com/photos/sharynmorrow/11263821/

“takeout” by dotpolka : http://www.flickr.com/photos/dotpolka/249129144/

“ice cream cone melting/rome” by Megandavid : http://www.flickr.com/photos/megandavid/189332042/

“nikon em bokeh” by dsevilla: http://www.flickr.com/photos/dsevilla/249202834/

“maybe” by Tal Bright: http://www.flickr.com/photos/bright/118197469/

“how do they do that” by Fort Photo: http://www.flickr.com/photos/fortphoto/388825145/

“Gorgeous iceberg 7 [Le Toit du Monde]” by Adventure Addict http://www.flickr.com/photos/adventureaddict/35290307/

“molasses-spice cookies” ilmungo: http://www.flickr.com/photos/ilmungo/65345233/

“Driving is fun” by Ben McLeod: http://www.flickr.com/photos/benmcleod/59948935/

“Dozen eggs” by aeA: http://www.flickr.com/photos/raeallen/96238870/

“Max speed 15kmh” by xxxtoff: http://www.flickr.com/photos/xxxtoff/219781763/

“Stairway to heaven” ognita: http://www.flickr.com/photos/ognita/503915547/

“flaps up” by http://www.flickr.com/photos/jurvetson/74274113/

“Fast Cat” by http://www.flickr.com/photos/raylopez/708023176/

“blues” by http://www.flickr.com/photos/pankaj/1877184829/

Page 71: 7 Habits of Exceptional Performance

CC Images Used“Vintage Kodak Studio Scales Set and Bottle” by http://www.flickr.com/photos/captkodak/

272746539/

“Assumtion, Minissota” by http://www.flickr.com/photos/afiler/226337382/

71

Thanks to Tenni Theurer and Nate Koechleyhttp://developer.yahoo.net/blog/archives/2008/01/the_7_habits_fo.html