the cbc on a diet - slimming down for a whole nation

113
#SpotlightWPO The CBC on a Diet Slimming down for a whole nation

Upload: barbara-bermes

Post on 06-May-2015

3.872 views

Category:

Technology


3 download

DESCRIPTION

Talk at FITC Spotlight Web Performance and Optimization, March 16, 2013, Toronto. Synopsis: The CBC serves optimized content to millions of Canadians. We’ll share our experience & knowledge of optimizing content delivery for a high-scale & unpredictable audience. We will explain our performance stack from server-side optimization tricks to automated performance tools during deployment. We will discuss our challenges, findings and learnings of continually improving site delivery. http://fitc.ca/presentation/the-canadian-public-broadcaster-on-a-diet-slimming-down-for-a-whole-nation/

TRANSCRIPT

Page 1: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

The CBC on a DietSlimming down for a whole nation

Page 2: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Barbara // bbintoSenior Architect, Mobile Web

Digital Operations, CBC

Blake // blakecrosbyTeam Lead, Media Production SupportMO&T, CBC

Page 3: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Today’s workout• Quick dive into web performance• The CBC - weight problems and temptations• How to stay in shape• Real production exercises that worked for CBC• Our fitness tips summarized• Performance Quiz (if time permits)

Page 4: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

PerformanceWhy the need for speed?

Page 5: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Page 6: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Perception of Speed

• It feels slower when...• Unpleasant

• Unknown

• Boring

• It feels faster when...• Task is successful

• Responsive system

• Progress and informed

Page 7: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

“Ultimately performance is about respect”Brad Frost

Page 8: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Mobile & PerformanceWhy is performance for mobile so crucial?

Page 9: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

It’s a mobile (browser) world

Page 10: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Performance on Mobile

• Battery-driven device, heavy pages will drain the battery (excellent paper)

• Smaller CPU

• Network connectivity / latency

• Data usage - Don't make the user pay for bad performance

Page 11: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

You’re dealing with impatient users 74% of mobile web users expect a page to load in 5 seconds or lessGomez - What Mobile Users Want

Page 12: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Measure performance

Page 13: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Tools, Formats and Browser Plugins

• Browser plugins• “Waterfall” inside Firebug, Chrome etc

• PageSpeed, YSlow and YSlow Plugin for 3rd party

• HAR (ultrasound of a web page)• Based on the HTTP Archive specification

• Captures web page loading information in a JSON format

• Visualizing: HAR Viewer

Page 14: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Collecting measurements

Page 15: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Synthetic Testing and Real User Monitoring (RUM)Hand in hand

Page 16: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Synthetic Testing

• You run the test

• Establish a baseline performance level (e.g identify poor 3rd party scripts)

• Measuring one exact configuration (of your choice)

• Pitfalls• “[...] your real users are experiencing page load times that are

twice as long as their corresponding synthetic measurements.” (Steve Souders)

Page 17: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Synthetic Testing - Tools

• PageSpeed• Insights API

• Webpagetest.org• Public and private instances with RESTful API

• Headless Scripts and Tools• phantomJS, confess, or write your own script

curl "https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=http://sample.com&key=yourAPIKey"

http://www.webpagetest.org/runtest.php?url=example.com&runs=3&k=apikey&f=json

Page 18: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Real User Monitoring (RUM)

• User runs the test

• Measures the experience of the “actual” user• “It is the ground truth for what users are experiencing” (Steve

Souders)

• Get concrete information about user’s connectivity, latency, bandwidth etc.

Page 19: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

!"#$%&'()&*+,$-(.(,)$

/0123344454"5+6)3-73,&'()&*+,8*.(,)3$

RUM

• Based on navigation timing

• Free Tools• Boomerang

• Google Analytics

• Vendors• Keynote

• New Relic

• and more...

Page 20: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Canadian Broadcasting Corporation

Canadian crown corporation

National public radio and television broadcaster

Kind of like the BBC

but not really - the CBC employs commercial advertising to supplement its federal funding

Desktop site page views ~5Mio/day

Mobile Touch site page views ~ 500K/day

Page 21: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Mandate: The 1991 Broadcasting Acts states that..."...the Canadian Broadcasting Corporation, as the national public broadcaster, should provide radio and television services incorporating a wide range of programming that informs, enlightens and entertains;

...the programming provided by the Corporation should:vi. be made available throughout Canada by the most appropriate and efficient means and as resources become available for the purpose, andvii. reflect the multicultural and multiracial nature of Canada.”

Page 22: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Organizational Structure - Clients

Page 23: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

CBC’s digital ecosystem

Page 24: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

What constitutes a web product at CBC?

Page 25: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Anatomy of a CBC page

• 3rd party scripts• Tracking (SiteCatalyst, ComScore, ClickTale)

• Ads (GPT)

• Social plugins (Gigya)

• Content• Global header and footer (for branding)

• Actual content to tell a story, e.g. Text, Video, Audio, Images etc.

Page 26: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Weight Check: Desktop and Mobile

Page 27: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

A typical CBC story page

Page 28: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Let’s put them on a scale!Content Breakdown

Page 29: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Content Breakdown - Mobile

Page 30: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Content Breakdown - Mobile

Fully loaded

247kBHTTP requests

36

Page 31: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Content Breakdown - Desktop

Page 32: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Content Breakdown - Desktop

Page 33: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Content Breakdown - Desktop

Fully loaded

1,539kBHTTP requests

164

Page 34: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Too heavy? Compared to what though...?

Page 35: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

httparchive.orgThe HTTP Archive tracks how the web is built

Page 36: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Desktop - Total Transfer Size

November 2010 - March 2013: + ~50%

1211kB

90 req.

Page 37: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Mobile - Total Transfer Size

June 2011 - March 2013: + ~50%

720kB

60 req.

Page 38: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

The average page will hit 2MB by 2015Images and 3rd party scripts are the main culprits

Page 39: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Avoid Dangerous Temptations

Page 40: The CBC on a diet - Slimming down for a whole nation

Temptations

Yikes!

Oh No!

• That’s a lot of cookies

Page 41: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Temptations

Tipping the scale

Page 42: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Cookies on a Diet

• Use the path option to limit cookie scope

• Store your static assets at a different domain (images.cbc.ca)

• Don’t use cookies for fun. Ask: Do you really need them?

Page 43: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Common temptations of a front-end dev

Page 44: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Temptations

Sure, I’ll add that new social media plugin

I want to use that cool new plugin I just found

Yeah yeah, I’ll optimize later

Wait....I just want to make it pretty (and prettier)

Let’s use those 2MB retina images for e v e r y platform

Page 45: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

3rd Party Monsters

Page 46: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Monsters?

• Kinds of monsters• Ads, tracking, social buttons

• They are unpredictable, scary, disruptive, sneaky and• Could slow down your site

• Could bring down your site (Single Point of Failure)

• Could do things you don’t want them to do

• Add weight and complexity to your page

Page 47: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

What would a life without ads feel like....????

Page 48: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

The wonderful life without ads....

Page 49: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

CBC without mobile touch ads....

• Using server-side ads code over client-side code saved us ~20% of load time

• Using no ads in comparison to client-side ads reduced our load time by ~40%

Page 50: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

And the danger with all diets ....

Page 51: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Yo-yo effect

• Keep the excitement and awareness

• Be diligent and stay focused

• Don’t gain the weight back

Page 52: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Monitor your fitness levelSo you can identify your problem areas

Page 53: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Monitoring your fitness level

Alerts

Page 54: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Monitoring your fitness level

Automated Reports

Page 55: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Monitor and test your speed (Mobile)

• Device testing and speed simulation• Adobe Edge

• shim (Boston Globe)

• Slowy

• Remote debugging• Weinre / debug.phonegap.com

• Bookmarklets (Firebug Lite, YSlow)

• Safari Remote Web Inspector

Page 56: The CBC on a diet - Slimming down for a whole nation

Monitor and average the Unpredictable

Typical (breaking) news traffic • Difficult to measure average, visitors

Page 57: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Create your own performance dashboard

Page 58: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Create your own perf dashboard

• Run WebPageTest on your own server and export HAR files

• Automate your test runs

• Use js tools to visualize (Google chart tools, d3.js)

Page 59: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Create your own perf dashboard

• JavaScript based tools• PhantomJS: headless webkit with JavaScript API

• CasperJS: navigation scripting and testing utility for PhantomJS

• boomerang.js (JavaScript library for RUM): measures the page load time experienced by real users

Page 60: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Stay in shape

Page 61: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Page 62: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Front-End

• Google• https://developers.google.com/speed/docs/best-practices/

rules_intro

• Yahoo• http://developer.yahoo.com/performance/rules.html

Page 63: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Front-End

• Conditional loading

• Be careful on the 3rd party scripts (SPOF)

• Avoid re-rendering DOM elements

• Use data:uri • Encoded in base 64 format

• For example, can be used to replace background images < 2kB

Page 64: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

data:uri

• Task: CBC Gem

• Performance test• no background image, pure CSS

• png background image inside CSS

• data:uri (encoded png as base 64) inside CSS

• Conditions• all minified, concatenated, compressed

30px

30px

Page 65: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

data:uri - pure CSS

Page 66: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

data:uri - png bg img in CSS

Page 67: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

data:uri in CSS

Page 68: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Performance comparison

pure CSS PNG in CSS data:uri in CSS

HTTP requests 2 3 2

Bytes in kB 4.1 2.9 3.3

Load Time (Median) 0.303s 0.389 0.26

Page 69: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Server and Back-End

• Last mile acceleration (use GZip compression)

• Take advantage of a CDN, if possible

• Only use cookies where necessary

• Caches are your friend

Page 70: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Dedicated mobile sites

Page 71: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Server-side Optimization & Device Detection

• Decide on the server what to serve• Different websites (Text, Rich, Touch) for optimized experience

• Optimized and different images for all of our 3 mobile sites

• Edge side include technology (ESI) for device detection and/or conditional loading

Page 72: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Responsive Web Design and Web Performance“72% of the sites using responsive design don't optimize for mobile” (Guy Podjarny) (86% in 2012)

Page 73: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

How about RESS?

• Responsive Web Design with Server Side Components

• Heavy resource lifting should be done on the server

Page 74: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Second Screen Example - RESS

DesktopTabletTouch Mobilelow-res images and mobile ads retina high-res images and mobile ads high-res images and fullsite ads

Page 75: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

RESS - Server Side Component

Page 76: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

RESS - RWD component

Page 77: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Exercises that worked for CBC

Page 78: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

The Power of 304

• Very important to support If-Modified-Since requests

• Allows caches to properly cache content. Don’t cache bust!

Page 79: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

The Proof

28kb

12kb

Page 80: The CBC on a diet - Slimming down for a whole nation

Before.... After

Page 81: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Keep those 404s in check

• Heavy 404 Page?

• Browser will download the 404 page even if it’s for a broken image or other asset

Page 82: The CBC on a diet - Slimming down for a whole nation

Definitely not super-model thin...

Page 83: The CBC on a diet - Slimming down for a whole nation
Page 84: The CBC on a diet - Slimming down for a whole nation
Page 85: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

The Difference...

• 5.2kB versus 1.4kB

• Savings of ~75%

Page 86: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Global Shell

• Shared by all

• Visual representation• Non-visual representation

• SSI variables in header to serve ads and tracking

• Global scripts and stylesheets

• SiteCatalyst and ComScore

Page 87: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Improvement is easier than you think

Page 88: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

How did we improve? Simple!

• Re-factored code: Removed old/un-used code

• Moved some scripts to the bottom of page

• Minified and concatenated scripts and CSS files to reduce file size and HTTP requests

Page 89: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

How did we improve?

• Why optimizing manually if you can just automate it

• Included performance optimization into your deploy and release process

Page 90: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Automated & Built-in Performance Tips

• Maven, Ant Tools and Plugins• Closure Compiler (Google)

• Minify-maven-plugin

• HTMLCompressor

• Confess

• cssembed.jar for data:uri

Page 91: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Automated & Built-in Performance Tips

• If you can’t / don’t want to use Maven / Ant• Taskrunners and Scaffolding: Grunt, Yeoman

• Continuous integration• Jenkins and Hudson

Page 92: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

What were the results?

Page 93: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Global Shell

Page 94: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Global Shell

Area Before After Improvement (in %)

HTTP Requests

Page Weight

Page Load*

24 18 25

71.9kB 69.8kB 3

3.16s 1.91s 40

*Page load depends on connection and latency

Page 95: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

If you don’t monitor your weight, you can also make it worse......and you’ll get unexpected visitors again ..yo-yo effect

Page 96: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Page 97: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

!"

#"

$"

%"

&"

'"

()"

(("

$*+(*(+" $*+&*(+" %*#*(+" %*(+*(+" %*('*(+" %*+$*(+" &*+*(+" &*'*(+" &*($*(+" &*+,*(+" &*,)*(+" '*$*(+" '*(,*(+" '*+)*(+" '*+%*(+" ()*!*(+" ()*((*(+" ()*(&*(+"

!"#$%&

'(3rd Party Monsters interrupt

Global Shell

Client-side scriptsISP issues

Data from Keynote

Page 98: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

A user who has to endure an 8-second download delay spends only 1% of

their total viewing time looking at the featured

promotional space on a landing page.

In contrast, a user who receives

instantaneous page rendering spends

20% of viewing time within the

promotional area (source: Nielsen)

Page 99: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

CBC’s fitness tips - Take aways

Page 100: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Share your results

Fitness Tip

Page 101: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

“It’s not about what you can add, it’s about what you can’t take away”(Christian Heilmann, The Vanilla Web Diet)

Fitness Tip

Page 102: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

You can never measure and test enoughRun tests frequently

Fitness Tip

Page 103: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Show graphs and complexity to illustrate performance success and also bad hits

Fitness Tip

A picture is worth a thousand words

Page 104: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Make it fun and painless, make it part of your daily routineAutomated Performance within your organization

Fitness Tip

Page 105: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Watch those 3rd party monstersEvaluate their impact, ask and push for server-side solutions

Fitness Tip

Page 106: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Serve only what the client needsDevice Detection, Server-side components and Responsive Web Design

Fitness Tip

Page 107: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Share your ideas and knowledgeWeb Performance Working Group

Fitness Tip

Page 108: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Create a culture of performanceBring everyone on board

Fitness Tip

Page 109: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Set a Performance Budget

Fitness Tip

Page 110: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Performance Budget

• Be diligent and cautious about new features

• Set a baseline / weight (e.g. BBC 10 seconds on 3G/GPS)

• Evaluate a good conversion rate, cost vs. revenue

• Visit HTTP Archive for comparison

• Always evaluate what you can take away (content breakdown)

Page 111: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Samples of Performance Budget

• Set a budget for 3rd party scripts• “Should not weigh more than ...”

• Evaluate the need for frameworks

• Run quick performance tests on mocks

Page 112: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Questions?

#SpotlightWPO /blakecrosby /bbinto

Thank you!We’re hiring!

Page 113: The CBC on a diet - Slimming down for a whole nation

#SpotlightWPO

Photo Credits•http://beautygirlsmom.com/wp-content/uploads/2011/01/diet-funny-sign-spelled-out-vegetable.jpg•http://photobucket.com/images/yo+yo+puppy+dog+yoyo+animated+gif+funny/•http://www.wallpaper-welt.de/gros/film/monster-ag/Monster%20AG.jpg•http://www.passiveaggressivenotes.com/2007/07/29/this-is-why-your-server-is-cranky/•http://4.bp.blogspot.com/-NnFPM5Fgbao/TaIkVwyusEI/AAAAAAAAMPw/fdDbbvgJRb8/s1600/054.jpg•http://thefulltimedomesticgoddess.com/wp-content/uploads/2011/09/girls-holding-hands-bw.jpg•http://cartoonswalls.com/walls/monsters_university_desktop_wallpaper-wide.jpg•http://41inmylife.files.wordpress.com/2011/06/weight_scale.jpg•http://blogs.scientificamerican.com/the-curious-wavefunction/files/2012/08/boeing_777_cockpit.jpg

Sources•http://www.slideshare.net/stoyan/psychology-of-performance•http://www.stevesouders.com/blog/2012/11/14/comparing-rum-synthetic-page-load-times/•http://bradfrostweb.com/blog/post/performance-as-design/ •“Who killed my battery: Analyzing Mobile Browser Consumption” http://www2012.wwwconference.org/proceedings/proceedings/p41.pdf•http://www.slideshare.net/guypod/performance-implications-of-mobile-design •http://www.cbc.ca/m/touch/sports/story/2013/03/05/sp-paralympics-oscar-pistorius.html•Desktop: http://www.webpagetest.org/result/130315_TQ_WT1/•Mobile:http://www.webpagetest.org/result/130315_1X_X18/•http://coding.smashingmagazine.com/2012/11/13/the-vanilla-web-diet/•http://www.gomez.com/wp-content/downloads/19986_WhatMobileUsersWant_Wp.pdf