Você está na página 1de 123

90 Minute Optimization Life Cycle

“Fast by Default” before our eyes


Author of presentation
Today’s Hosts

Hooman Beheshti Joshua Bixby


VP Products President
Strangeloop Strangeloop

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 2


Agenda

• Why is faster better


• Making a site faster
• Measurement
• Diagnosis
• Demos
• What did we miss
• Q&A

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 3


Methodology

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 4


Why is faster better?
http://www.webperformancetoday.com/2010/06/15/everything-
you-wanted-to-know-about-web-performance
/

(http://bit.ly/8YB3ET )
© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 5
© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 6
© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 7
© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 8
© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 9
© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 10
Impact of page load time on average daily
searches per user
0.00%

-0.10%

-0.20%

-0.30%

-0.40%

-0.50%

-0.60%

-0.70%

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 11


© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 12
Impact of additional delay on business
metrics
Percent change

0.00%
-0.50%
-1.00%
-1.50%
-2.00%
-2.50%
-3.00%
-3.50%
-4.00%
-4.50%
-5.00%
50 200 500 1000 2000
Added delay

Queries per visitor Query refinement Revenue per visitor


Any clicks Satisfaction

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 13


© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 14
Shopzilla had another angle
Big, high-traffic site 16 month re-engineering
◦ 100M impressions a day ◦ Page load from 6 seconds
◦ 8,000 searches a second to 1.2
◦ 20-29M unique visitors a ◦ Uptime from 99.65% to
month 99.97%
◦ 100M products ◦ 10% of previous hardware
needs

© 2010 Strangeloop Networks http://en.oreilly.com/velocity2009/public/schedule/detail/7709


Strangeloop. Faster Websites. Automatically. 15
5-12% increase in revenue

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 16


© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 17
© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 18
© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 19
© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 20
© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 21
© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 22
© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 23
© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 24
© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 25
Measurement:

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 26


Where should we start?

Ylsow from

Page Speed from

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 27


© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 28
Example: Gomez

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 29


HTTP Watch

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 30


Webpagetest.org

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 31


Visualizing the problem

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 32


Web Performance Problem
Definitions
• Backend:
Time from when the user makes the request to when the
last byte of the HTML document arrives. Includes the time
for the initial request to go up, the Web server to stitch
together the HTML, and for the response to come back.

• Frontend:
Shorthand for everything after the HTML document arrives.
In reality, includes backend time (primarily reading static
files) and network time, as well as true frontend activities
such as parsing HTML, CSS, and JS, and executing JS.

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 33


www.strangeloopnetworks.com 33
Front-end Problem is getting worse
75.25
600

Average Number of Objects


70
Average Page Size (K) 498
500
Average Number of Objects
60
Total Bytes (K)

400
49.92 312.05 50
300
40
200 25.7 30
20
100 93.7
2.3
14.1 10
0
0
Waterfall chart

35
© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 35
Waterfall chart
HTML

36
© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 36
Waterfall chart
HTML

Resources

37
© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 37
Waterfall chart
Start Document Fully
Render Complete Loaded

38
© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 38
Waterfall component breakdown

DNS lookup
DNS Lookup

• Takes one packet in each


direction

• Time is limited to the latency of


the connection (DSL/Cable/etc)
for the single round trip

39
© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 39
Waterfall component breakdown

TCP
Connection
TCP Connection

• 3 packets

- ClientServer (SYN)
- ServerClient (SYN/ACK)
- ClientServer (ACK)

• Time is limited to the latency


of the connection
(DSL/Cable/etc) for the
single round trip

40
© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 40
Waterfall component breakdown

Time To First
Byte
Time to First Byte

• Time from the request packet


(usually 1) to the first packet of
the response

• Includes the latency of the


connect ion (DSL/Cable/etc)
for a single round trip

• Also includes whatever server


think time was involved in
generating the response

41
© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 41
Waterfall component breakdown

Content
Download
Download

• Time it takes for the entire


content of the response to get
to the browser

• Mostly limited by the


bandwidth limit of the
connection (DSL/Cable/etc)

42
© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 42
Let’s Accelerate
The unsuspecting victim

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 43


© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 44
A Few Points of Clarification
• We’re using this page because it’s more fun!
• We’ll use it to describe where performance
pain points are, but that doesn’t mean the
page actually has these problems
• What we’re going to do:
Improve performance incrementally

Not so good Awesome


(slow) (fast)

* The real Velocity site is somewhere in the middle!


© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 45
Performance Summary

http://bit.ly/au01VY /

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 46


Waterfall
First View Repeat View

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 47


Per Object

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 48


Content Analysis by Type

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 49


Content Analysis by Domain

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 50


Show Me Where It Hurts
Problem Analysis

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 51


Performance Problems
• Too many connections (too much orange)

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 52


Too Many Connections

97 Connections
(almost one per request)

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 53


Too Many Connections

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 54


Performance Problems
• Too many connections (too much orange)
• Too many bytes (too much blue)

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 55


Too Many Bytes

By Type By Domain

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 56


Performance Problems
• Too many connections (too much orange)
• Too many bytes (too much blue)
• Concurrency

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 57


Concurrency
• Browsers can only open and use so many
connections at once

• www.browserscope.org
© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 58
Performance Problems
• Too many connections (too much orange)
• Too many bytes (too much blue)
• Concurrency
• Bad Caching for repeat views

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 59


Bad Repeat View
Full Fetches

Validation

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 60


Bad Repeat View
Connections Bytes

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 61


Performance Problems
• Too many connections (too much orange)
• Too many bytes (too much blue)
• Concurrency
• Bad Caching for repeat views
• No CDN (the greens are too big)

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 62


The Green Problem #1: No CDN
TTFB

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 63


Time To First Byte
• HTTP overhead
• Subjected to latency every time
• The more objects, the bigger the problem
• Concurrency helps, but not a lot
GET /javascripts/application.js?1276735447 HTTP/1.1
Accept: */*
Referer: http://en.oreilly.com/velocity2010/
Accept-Language: en-us
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2;
Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR
3.0.4506.2152; .NET CLR 3.5.30729)
Accept-Encoding: gzip, deflate
Host: en.oreilly.com
Cookie: _session_id=6e76e8d4a4eccc63b4be7937e719ca9e

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 64


Performance Problems
• Too many connections (too much orange)
• Too many bytes (too much blue)
• Concurrency
• Bad Caching for repeat views
• No CDN (the greens are too big)
• Too Many Roundtrips (too many greens)

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 65


The Green Problem #2: Roundtrips

First View Repeat View

80 Requests 78 Requests

27 Requests
14 Requests

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 66


The Green Problem #2: Roundtrips
• Every fetch still pays the HTTP overhead
penalty  TTFB is still a problem
• Exacerbated by concurrency issues
• Getting worse as number of objects per page
grows
• Generally, the hardest problem to solve

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 67


Performance Problems
• Too many connections
• Too many bytes (too much blue)
• Concurrency
• Bad Caching for repeat views
• No CDN (the greens are too big)
• Too Many Roundtrips (too many greens)
• Others

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 68


Examples of Other Problems
• Blocking Javascript

• 3rd party calls (http://stevesouders.com/p3pc/)

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 69


What does it look like

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 70


Summary

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 71


Let’s Fix It!!

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 72


Set-Up

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 73


Testing Environment

WebPageTest Client SERVICE (CLOUD) O’Reilly Datacenter


(East Coast) (West Coast)

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 74


Possible Deployments

SERVICE (CLOUD) APPLIANCE VIRTUAL

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 75


Acceleration Methodology

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 76


Stepwise Acceleration
• Start from the beginning and fix the easy stuff

• Step by step acceleration of the page


– Apply techniques/methods/etc and see the result
– Try to make it as fast as possible

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 77


Kind of Like a Video Game
Easy Hard
Page Performance

Level

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 78


Page Performance Kind of Like a Video Game

Not Good Enough

Level

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 79


Strangeloop Site Optimizer UI

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 80


Step 1:
Low Hanging Fruit

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 81


Keep-Alive
• Solves the too-many connection problem (Less
Orange!)
• Will help alleviate the TCP connection setup
overhead

97
Connections

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 82


Compression
• Addresses the too-many-bytes problem (Less
Blue!)
• We’ll compress textual content (html/css/etc)
• Not the only solution to less blue, but the
easiest

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 83


WebPageTest

http://bit.ly/cKkjGz
© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 84
Before and After

~17.8sec ~10.5sec

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 85


What We Helped: Keep-Alive

97 Connections  19 Connections

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 86


What We Helped: Compression

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 87


How Did We Do?
Original

KA+Comp

Improvement
First View 52% 40% 34% 31% 23%

Repeat View 71% 62% 94% 51% 75%

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 88


How Does It Look

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 89


Pros and Cons
• Pros
– Really easy to do
– Single configuration switches in servers, proxies,
or load balancers
– Good benefit seen right away
• Cons
– Compression has processing overhead
– On their own they’re just not enough

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 90


Step 2:
Repeat View Problem

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 91


Poor Client Side Caching

Original

KA+Comp

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 92


Problem Still Exists

~6.2sec

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 93


How Do We Get Better Caching
• RFC 2616, Section 13
• Caching headers should be used on static
(non-changing) objects, so they can be cached
browser-side
– And by intermediate caching proxies
• Validators are not enough

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 94


WebPageTest

http://bit.ly/aCP3iX

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 95


Before and After

~2.0sec

~6.2sec

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 96


How Did We Do?
KA+Comp

With Good Caching

Improvement
Repeat View 70% 67% 42%

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 97


Pros and Cons
• Pros
– Good caching can have a major performance
impact on repeat visits to a page
– Sometimes it’s easy to do
– Browsers generally pay attention (although
interpretation may vary slightly)
• Cons
– The spec appears scary
– Invalidation and stale content

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 98


Step 3:
CDN

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 99


What Does a CDN do?
• Global network of
proxy caches

• Get cacheable content


close to users

• Reduce TTFB (smaller


greens)

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 100


TTFB Problem

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 101


WebPageTest

http://bit.ly/a9ZJcF

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 102


Before and After

~10.5sec ~8.3sec

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 103


TTFB Savings

Per object TTFB savings of ~50%

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 104


How Did We Do?
KA+Comp

+CDN

Improvement
First View 21% 22% 17%

Seconds Gained 0.7 sec 2.3 sec 2.7 sec

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 105


How Does It Look

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 106


Pros and Cons
• Pro
– Good mitigation of the TTFB problem
– Established industry: lots of vendors to choose
from
• Cons
– Sometimes costly
– May require code change (CDN’ed objects should
be written to the CDN domain)

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 107


Step 4:
Steroids- the Hard Stuff

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 108


We Can Get Better!

Still too many roundtrips

Still too many bytes

Not Fast Enough!!

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 109


What to do Next?
• Reduce Roundtrips
– Combine images
– Combine JavaScript
– Combine CSS
• Reduce Payload even more
– Minify CSS and JavaScript
– Add Image Compression
• Increase Concurrency
– Add a couple of domains to the mix

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 110


WebPageTest

http://bit.ly/bbT3v4

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 111


Before and After

~3.8sec

~8.3sec

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 112


How Did We Do?
+CDN

81 107

+Strangeloop

11 37

Improvement
First View 19% 54% 45% 30% 31%

Seconds Gained 0.5 sec 4.6 sec 4.1 sec

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 113


How Does It Look

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 114


Pros and Cons
• Pros
– Most significant benefit for the hardest part of the
acceleration lifecycle
– Address multiple performance points (somtimes
multiple ones with the same technique)
• Cons
– It’s not easy
– Regression

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 115


Congratulations - we are done…right?

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 116


3rd Party Content

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 117


Server Think Time
Server Think Time

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 118


Browsers?

Performance differences across browsers


4
3.5
3
2.5
2
1.5
1
0.5
0
e4 e5 fari
x2 x3 IE 6 IE 7 IE 8 4 Sa
ro m ro m Fo Fo fari bile
Ch Ch Fire Fire Sa M o

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 119


Mobile Web

fast by default

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 120


Flow

Conversion

? ? ?

3.8 Seconds
11 Roundtrips

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 121


Regression
“Our Developers have repeatedly redesigned
the web site’s software to scale but the job is
never done. It’s kind of like painting the
Golden Gate Bridge, where every time you
finish, it’s time to start over again. There are
many lessons to be learned and we learn
them the hard way by coding.”

Jim Benedetto
MySpace Vice President
Technology

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 122


Q&A

© 2010 Strangeloop Networks Strangeloop. Faster Websites. Automatically. 123

Você também pode gostar