web performance optimization

47
Web Performance Optimization 2010 © Pavel Paulau

Upload: pavel-paulau

Post on 19-Nov-2014

1.260 views

Category:

Technology


0 download

DESCRIPTION

Slides from webinar "Web Performance Optimization"

TRANSCRIPT

Page 1: Web Performance Optimization

Web Performance Optimization

2010 © Pavel Paulau

Page 2: Web Performance Optimization

Getting started

2

• Look into web front-ends performance

• Learn how to- Estimate and track web performance- Analyze and diagnose page bottlenecks- Make website faster easily without code modification and eye candy losses

• Forget for a hour about load, transactions and servers

Page 3: Web Performance Optimization

3

End user experienceEnd user experience1

Automated web performance testingAutomated web performance testing2

In-depth performance analysisIn-depth performance analysis3

Effective content delivery and transformationEffective content delivery and transformation4

Optimization examplesOptimization examples5

ConclusionConclusion6

Page 4: Web Performance Optimization

Performance aspects

4

• AvailabilityThe amount of time an application is available to the

end user.

• Response timeThe amount of time it takes for the application to respond

to a user request.

• ThroughputThe rate at which application-oriented events occur.

• UtilizationThe percentage of the theoretical capacity of a

resource that is being used.

Page 5: Web Performance Optimization

Behind the scene

5

• Just one user’s click lead to- Tens of HTTP requests- Hundreds of XHR calls- Kilobytes of network traffic- Multiple CPU calls- Expensive IO operations

• However, the end user doesn’t know anything about HTTP, web technologies, browsers and servers

• The only thing the user experiences is a page load time

Page 6: Web Performance Optimization

Challenges

6

• Traditional performance testing techniques do not reflect real browser behavior

• Dependence on connection quality

• Multiple browsers and versions of browsers

• Lots of components and pages

• Third-party components

• A false view of the performance bottlenecks

Page 7: Web Performance Optimization

Browsers multiplicity

7

Firefox 3.x30.5

Opera 101.2

Chrome 57.6

IE 68.1Chrome 6

2.7

IE 829.3

Safari 52.6

IE 713.9

Safari 41.1

Browser Connections per Hostname* II Scripts Script* II Scripts Stylesheet* II Scripts Image* Async. Scripts* Cache Redirects*Chrome 5 6 Yes Yes Yes No YesChrome 6 6 Yes Yes Yes No YesFirefox 3.x 6 Yes Yes Yes Yes YesIE 6 2 No No No No NoIE 7 2 No No No No NoIE 8 6 Yes Yes No No NoOpera 10 8 No No No No NoSafari 4 6 Yes Yes Yes No NoSafari 5 6 Yes Yes Yes No Yes

* browserscope.org

Page 8: Web Performance Optimization

Different browsers offer different performance

8

Source: Gomez Real-User Monitoring

> Real users around the world> Broadband

> 466M pages over 30 days> 200+ sites

Page 9: Web Performance Optimization

Response time components

9

Server side Content delivery Rendering

Outside the application -still part of our responsibility

Critical forWeb 2.0

application

80-90% of the end-user response time is spent on the frontend

Page 10: Web Performance Optimization

Web performance anatomy

10

ServerBrowser

Latency

HTTP

Cache

ParsingLayoutingRendering

Ads, widgets, analytics

ImagesCSSJavaScriptFlash

DNS Server

3rd-partyservers

Internet

AJAX/XHRIE

FirefoxChrome

SafariOpera

Page 11: Web Performance Optimization

Performance impact

11

• E-commerce applications- People stay on website longer and view more pages

- People perceive business to be more trustworthy

- Significantly decreased visitor frustration levels

- Google uses site speed in web search ranking

• Enterprise applications- Faster responses keep users more attentive and

concentrated

- Some business processes require extremely fast interactions

Page 12: Web Performance Optimization

12

End user experienceEnd user experience1

Automated web performance testingAutomated web performance testing2

In-depth performance analysisIn-depth performance analysis3

Effective content delivery and transformationEffective content delivery and transformation4

Optimization examplesOptimization examples5

ConclusionConclusion6

Page 13: Web Performance Optimization

Performance metrics

13

There are two basic approaches to performance estimation• Time-driven testing – measuring absolute load time

- Time to first byte

- Time to first impression

- onLoad time

- Fully loaded time

• Rank-driven testing – based on best practices- Yahoo! YSlow grades

- Google Page Speed scores

- dynaTrace AJAX edition ranks

Page 14: Web Performance Optimization

Test automation framework

14

Analyst workstation Test environment LAMP (WAMP) Server

Show Slow

WebPagetest

URL Blast

Selenium Remote-Control

Test Controller(Java, C#, Python,Ruby, Perl, PHP)

Page 15: Web Performance Optimization

Advantages

15

• Open source solution> Free and flexible

• Websites testing with real browsers, not via HTTP requests

> Parsing and rendering aren’t ignored

• End-to-end process> Benchmark → Analysis → Optimization

• Scripting using the most popular languages> Java, C#, Python, Ruby, PHP, Perl.

Page 16: Web Performance Optimization

Features. Results storage and visualization

16

• Test results stored in MySQL database. Reliable and accessible approach

• “Measurements over time” feature provides the continuous control support

• Screen shots, waterfall views, visual comparison, video capture, content and domain breakdowns… not a full list of analytic solutions

Page 17: Web Performance Optimization

Features. WAN emulation

17

• Using Dummynet it’s possible to define the following connection options:

- Bandwidth download speed- Bandwidth upload speed- Network latency- Packet loss

• That’s an extremely important feature for worldwide applications without CDN

Page 18: Web Performance Optimization

Features. Optimization checklist

18

Page 19: Web Performance Optimization

19

End user experienceEnd user experience1

Automated web performance testingAutomated web performance testing2

In-depth performance analysisIn-depth performance analysis3

Effective content delivery and transformationEffective content delivery and transformation4

Optimization examplesOptimization examples5

ConclusionConclusion6

Page 20: Web Performance Optimization

Available tools

20

• Free and open source tools available for almost any browser:- Firebug with add-ons (Firefox)

- dynaTrace Ajax Edition (IE)

- Speed Tracer (Chrome)

- Web Inspector/Developer Tools (Safari/Chrome)

- HttpWatch (IE/Firefox)

- Dragonfly (Opera)

• These tools vary in functionality, flexibility and advantages, but together provide amazing capabilities

Page 21: Web Performance Optimization

21

It’s possible just to grade web pages total performance with any general rating system

or KPI’s.

Performance Ranking

Page 22: Web Performance Optimization

22

Sometimes it is not unlikely to notice a problem at a glance – just with HTTP waterfall charts. Blocking issues, non-existent elements, too long requests could be found within a minute.

HTTP waterfall charts

Page 23: Web Performance Optimization

23

Understanding of what is really going on inside of browser is a key point of page speed

analysis.

Timeline analysis

Page 24: Web Performance Optimization

24

When JavaScript becomes a trouble it’s extremely easy to analyze code execution and find the most

expensive call

JavaScript Profiling

Page 25: Web Performance Optimization

25

Not only JS-scripts but style spreadsheets lead to performance issues.Additional analysis features provide an ability to controls the effectiveness of CSS usage

CSS Usage Analysis

Page 26: Web Performance Optimization

26

The most delicious feature of these tools is a strong possibility to get an instantaneous advice

based on diverse best practices

Optimization advices

Page 27: Web Performance Optimization

27

End user experienceEnd user experience1

Automated web performance testingAutomated web performance testing2

In-depth performance analysisIn-depth performance analysis3

Effective content delivery and transformationEffective content delivery and transformation4

Optimization examplesOptimization examples5

ConclusionConclusion6

Page 28: Web Performance Optimization

2828

• Eliminate wasteful work

• Identify the action that's consuming most of user response time.

• Make the application do that action less often.

• Make the application do that action faster.

The fastest way to do something is don’t do it

Common optimization principles

Page 29: Web Performance Optimization

2929

Google, Yahoo! and dynaTrace specialists provide and constantly update best practices on

Cache optimization

Round-trip times minimization

Components size minimization

Parsing and rendering optimization

Available best practices

Page 30: Web Performance Optimization

Cache optimization

30

• A first-time visit to a page may require several HTTP requests to load all the components.

• By using Expires or Cache-Control headers these components become cacheable, which avoids unnecessary HTTP requests on subsequent page views.

• Expires headers are most often associated with images, but they can and should be used on all page components including scripts, stylesheets and Flash.

Page 31: Web Performance Optimization

Round-trip times minimization

31

• Decreasing the number of components on a page reduces the

number of HTTP requests and network packets required to

render the page, resulting in faster page loads.

• Common way to reduce the number of

components includes- Combine multiple scripts into one script

- Combine multiple CSS files into single stylesheet

- Use CSS Sprites and image maps

Page 32: Web Performance Optimization

Round-trip times minimization

32

• Inserting a redirect between the user and the final HTML document delays everything on the page since nothing on the page can be rendered and no components can be downloaded until the HTML document arrives.

• Reference to missing resources is a time wasting process

Page 33: Web Performance Optimization

XHR calls minimization

33

• JavaScript and XmlHttpRequests are the basis for what in general is called AJAX. Frameworks like jQuery make it very easy to make AJAX calls in order to retrieve additional content from the server.

• When the user navigates to the next page we request the next page via an AJAX call and refresh the DOM. This avoids a full round-trip and avoids the browser reloading the whole page.

• A mistake that is often made is that too much information is fetched dynamically with too many calls.

Page 34: Web Performance Optimization

Component size minimization

34

• Most modern browsers support data compression for HTML, CSS, and JavaScript files. This allows content to be sent over the network in more compact form and can result in a dramatic reduction in download time.

• Gzip is the most popular and effective compression method currently available and generally reduces the response size by about 70%.

Page 35: Web Performance Optimization

Component size minimization

35

• Minification removes unnecessary characters from a file to reduce its size, thereby improving load times.

• When a file is minified, comments and unneeded white space characters (spaces, newlines, and tabs) are removed. This improves response time since the size of the download files is reduced.

• Properly formatting and compressing images can save many bytes of data.

Page 36: Web Performance Optimization

Rendering optimization

36

• JavaScript scripts block parallel downloads - to help the page load faster, move scripts to the bottom of the page if they are deferrable.

• Moving stylesheets to the document head element helps pages appear to load quicker since this allows pages to render progressively.

• Specifying a width and height for all images allows for faster rendering by eliminating the need for unnecessary reflows and repaints.

Page 37: Web Performance Optimization

Effective DOM manipulation

37

• Many JavaScript libraries provide nice visual effects, e.g: dynamic popup menus, accordion effects, etc.

• Where most of these frameworks do a good job on sample web sites, some of them do not perform well on real life pages with large DOMs.

• It is important to analyze the impact of visual effects on the browser’s CPU, the rendering engine and the overall web site performance.

Page 38: Web Performance Optimization

3-rd party components

38

• You can't control it all

• Speed up what you can

Ensure that things you have control over are lightening fast

• Defer everything you can't control

Make sure it’s the last thing that is called on the page before it's done loading

Page 39: Web Performance Optimization

39

End user experienceEnd user experience1

Automated web performance testingAutomated web performance testing2

In-depth performance analysisIn-depth performance analysis3

Effective content delivery and transformationEffective content delivery and transformation4

Optimization examplesOptimization examples5

ConclusionConclusion6

Page 40: Web Performance Optimization

Sotheby’s landing page

40

• Page load time (IE7, 1024/512 Kbps, 50 ms RTT)• 15.5 seconds (first view)• 7.5 seconds (repeat view)

• Google Page Speed score• 67 (D)

• Yahoo! YSlow grade• 63 (D)

• dynaTrace AJAX edition rank• 73 (C)

Page 41: Web Performance Optimization

Optimization list

41

CSS merging eliminates 33 HTTP requests.

JS merging eliminates 16 HTTP requests.

CSS, JS and HTML minimization saves about 160 kilobytes of network traffic.

Images optimization reduce the page size by about 130 kilobytes.

GZip compression removes 420 kilobytes of unnecessary network traffic.

Cache tweaks (Expire headers and ETag optimization) to make repeat load faster.

Automatic adjustments with Apache mod_pagespeed.

Page 42: Web Performance Optimization

Page resources

42

Before

After

Page 43: Web Performance Optimization

Performance metrics

43

15.5 s

5.5 s

First View7.5 s

2.5 s

Repeat View

Page load time – 3x faster

Optimization ranks

67 (D)

91 (A)

Page Speed

63 (D)

90 (A)

YSlow

73 (C)

96 (A)

dynaTrace

Page 44: Web Performance Optimization

44

End user experienceEnd user experience1

Automated web performance testingAutomated web performance testing2

In-depth performance analysisIn-depth performance analysis3

Effective content delivery and transformationEffective content delivery and transformation4

Optimization examplesOptimization examples5

ConclusionConclusion6

Page 45: Web Performance Optimization

Resume

45

• Websites performance matters

• Traditional performance testing techniques cover only smallest part of the end user experience

• There are methods and tools to test, analyze and optimize websites speed

• These methods don’t contradict common performance testing approaches but complement them

Do not ignore front-ends!

Page 47: Web Performance Optimization

47

Tools

Google Page Speed Tools Familyhttp://code.google.com/speed/page-speed/

dynaTrace AJAX Editionhttp://ajax.dynatrace.com/ajax/en/

Yahoo! YSlowhttp://developer.yahoo.com/yslow/

WebPagetesthttp://www.webpagetest.org/

Show Slowhttp://www.showslow.com/

Let's Make the Web Fasterhttp://code.google.com/intl/en-EN/speed/tools.html