frontend spof

30
Google Confidential and Proprietary Frontend SPOF Patrick Meenan

Upload: patrick-meenan

Post on 06-May-2015

3.311 views

Category:

Technology


0 download

DESCRIPTION

Presentation from the March Hamburg Web Performance Meetup about Frontend Single Points of Failure

TRANSCRIPT

Page 1: Frontend SPOF

Google Confidential and Proprietary

Frontend SPOFPatrick Meenan

Page 2: Frontend SPOF

Google Confidential and Proprietary

June 2010 - Steve Souders

http://www.stevesouders.com/blog/2010/06/01/frontend-spof/

Credit where credit is due

Page 3: Frontend SPOF

Google Confidential and Proprietary

See what it looks like: http://youtu.be/prToLDpjmPw

Page 4: Frontend SPOF

Google Confidential and Proprietary

<script src="https://platform.twitter.com/anywhere.js?id=ZV0JHq7YJkjozsfohDIleQ&v=1" type="text/javascript"></script>

All Because of...

Page 5: Frontend SPOF

Google Confidential and Proprietary

What Monitoring Says...Active Monitoring

○ Server Monitoring ✔ Base page responded in 1.5 Seconds

○ Full-Browser Monitoring✔ Page loaded in 29 Seconds (test timeout is 60)

Real-User Reporting

○ Analytics Page Views✔ Analytics loaded and executed asynchronously

○ RUM Performance✔ If user bailed before onload there is no performance data

Page 6: Frontend SPOF

Google Confidential and Proprietary

It Gets Worse!Windows Socket Connect Timeout: 20s Mac/Linux Socket Connect Timeout: Much Higher

PER CONNECTION

Page 7: Frontend SPOF

Google Confidential and Proprietary

On that one page, all before the main content: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript" src="http://scripts.verticalacuity.com/vat/mon/vt.js?1329448814"></script> <script type="text/javascript" src="http://cdn.sailthru.com/scout/v1.js?1329448814"></script> <script type="text/javascript" src="//cdn.optimizely.com/js/20728634.js?1329448814"></script> <script src="https://platform.twitter.com/anywhere.js?..." type="text/javascript"></script>

There's More!

Page 8: Frontend SPOF

Google Confidential and Proprietary

But I'd notice it is down...

Page 9: Frontend SPOF

Google Confidential and Proprietary

In Iran?

https://blogs.akamai.com/2012/02/a-view-of-the-iranian-internet-blockade-from-akamais-intelligent-platform.html

Page 10: Frontend SPOF

Google Confidential and Proprietary

or China?

http://calendar.perfplanet.com/2011/frontend-spof-in-beijing/

Page 11: Frontend SPOF

Google Confidential and Proprietary

We have solutions...

Page 12: Frontend SPOF

Google Confidential and Proprietary

Async SnippetGood for code with no dependencies (widgets):

Page 13: Frontend SPOF

Google Confidential and Proprietary

Async LoadersHelp for chaining together dependencies Control.js

○ http://stevesouders.com/controljs/LABjs

○ http://labjs.com/ ● Remember to load the loader safely ● Requires a fair bit of manual work

Page 14: Frontend SPOF

Google Confidential and Proprietary

Put scripts at the bottom

http://stevesouders.com/examples/rule-js-bottom.php

Page 15: Frontend SPOF

Google Confidential and Proprietary

Well...

Page 16: Frontend SPOF

Google Confidential and Proprietary

Almost...

Blocks onload except on IE and iOS 4

http://www.stevesouders.com/blog/2012/01/13/javascript-performance/

Page 17: Frontend SPOF

Google Confidential and Proprietary

So, How are we doing?

Page 18: Frontend SPOF

Google Confidential and Proprietary

WidgetsGoogle Analytics: AsyncGoogle +1: AsyncTwitter: AsyncFacebook: AsyncDelicious: Async (image/href)StumbleUpon: AsyncDigg: AsyncReditt: BlockingAddThis: BlockingShareThis: Blocking (as of February 2012)

Page 19: Frontend SPOF

Google Confidential and Proprietary

Code Libraries (samples)Jquery: Blocking in the headClosure Library: Blocking in the headYUI: BlockingDojo: Blocking in the headMoo Tools: Blocking in the headGoogle API's: Blocking (default, Async available in docs)

Page 20: Frontend SPOF

Google Confidential and Proprietary

Popular CMS's Wordpress: Blocking in the head Drupal: Blocking in the head Joomla: Blocking in the head

Page 21: Frontend SPOF

Google Confidential and Proprietary

Testing for Frontend SPOF

Page 22: Frontend SPOF

Google Confidential and Proprietary

Routing to localhost Fails FAST! (connections are rejected) Not good for testing real failure scenarios

Page 23: Frontend SPOF

Google Confidential and Proprietary

You need a black hole

http://blog.patrickmeenan.com/2011/10/testing-for-frontend-spof.html

blackhole.webpagetest.org 72.66.115.13

Hosts File72.66.115.13 ajax.googleapis.com 72.66.115.13 apis.google.com 72.66.115.13 www.google-analytics.com72.66.115.13 connect.facebook.net 72.66.115.13 platform.twitter.com ...

On WebPagetestsetDnsName ajax.googleapis.com blackhole.webpagetest.orgsetDnsName apis.google.com blackhole.webpagetest.orgsetDnsName www.google-analytics.com blackhole.webpagetest.orgsetDnsName connect.facebook.net blackhole.webpagetest.orgsetDnsName platform.twitter.com blackhole.webpagetest.org...navigate your.url.com

http://www.jpl.nasa.go/spaceimages/details.php?id=PIA13168

Page 24: Frontend SPOF

Google Confidential and Proprietary

How pervasive is the problem?

Page 25: Frontend SPOF

Google Confidential and Proprietary

"Broken" Sites● CNN● MSNBC● New York Times● LA Times● Bloomberg● ABC News● CNet news.com● Pinterest● ESPN● AARP● Business Insider ...From just 20 minutes of looking

Page 26: Frontend SPOF

Google Confidential and Proprietary

What do we need to do?

Page 27: Frontend SPOF

Google Confidential and Proprietary

Browsers● Provide an easier way to asynchronously load complex

dependency chains○ async does not maintain order○ defer does not work for inline scripts

■ and is broken in several versions of IE

● Not block onload for Async scripts

○ Sadly, the spec requires onload blocking

● Implement Resource Timing

Page 28: Frontend SPOF

Google Confidential and Proprietary

Widget Owners● Never EVER provide blocking snippets ● All examples should be asynchronous ● Do not force HTTPS if it isn't required ● Where possible, allow for sites to self-host any critical

code

Page 29: Frontend SPOF

Google Confidential and Proprietary

CMS Developers● Build frameworks that encourage async code loading

(and encourage their use for default operation) ● Provide a mechanism for tracking the performance of

individual plugins

Page 30: Frontend SPOF

Google Confidential and Proprietary

Site Owners● Never load resources that you do not control synchronously (and refuse

3rd party code that doesn't have an async option) ● Do not rely on onload for important functionality

● Make sure your monitoring has aggressive time limits (under 20 seconds) ● Make sure your RUM reporting has an aggressive timeout ● Track RUM failures by region ● Leverage Resource Timing and field RUM analytics when available