840 likes | 969 Views
From Slow To Fast: Improving Performance On Intuit Web Sites By Up To 5x. Velocity NY Oct 16, 2013. Our Story. 1 year. 50 pages. 6 sites. 2 seconds. Agenda: History + Buy-in Phase 1: 15s to 6s Phase 2: 6s to 2s Business Impact Takeaways. Who we are. Jay Hung / @ jayhung
E N D
From Slow To Fast:Improving Performance On Intuit Web Sites By Up To 5x Velocity NY Oct 16, 2013
Our Story 1 year. 50 pages. 6 sites. 2 seconds. Agenda: • History + Buy-in • Phase 1: 15s to 6s • Phase 2: 6s to 2s • Business Impact • Takeaways
Who we are • Jay Hung / @jayhung • Chief Architect, WebMocha LLC • Ex-Yahoo engineer • 16+ yrs in consumer web + digital media • Performance consultant; frontend optimization since 2006 • Norberth Danson • Staff Software Engineer, Intuit Inc. • Full stack engineer • 9+ yrs web development • Member of Intuit core performance team
The earlydays… Image source: Internet Archive (edited)
Built when this was top of the line… Image source: Eliot Phillips (aka RobotSkirts) via Flickr
Dated Technology Before Web Standards
Over the years… www.intuit.com quickbooks.intuit.com quickbooksonline.intuit.com payroll.intuit.com payments.intuit.com websites.intuit.com and more… Includes New Code Many Devs Refactors Copy & Pastes 1996-1999 2012
…it became this: + Image source: vibrant.com Image source: Jesse Hernandez Photography
…it also became this: SLOW! 15s pageload Source: httparchive.org, Feb 2012 + Image source: vibrant.com Image source: Jesse Hernandez
Negatively affecting: • Users’ Experience • SEO • Pageviews • Conversions (sign-ups!)
Downright embarrassing! Image source: Alex E. Proimos via Flickr
Engineering presented a case: • cited experts like Steve Souders • research/examples from Google / Bing / Yahoo • blog posts on performance lifting conversions But people didn’t get it. Couldn’t get buy-in. Image source: DJ Octoon
Engineering presented a case: • cited experts like Steve Souders • research/examples from Google / Bing / Yahoo • blog posts on performance lifting conversions Too busy. No time. No resources. But people didn’t get it. Couldn’t get buy-in. Image source: DJ Octoon
A/B test showed a faster page increased conversion, improvedSEO & lifted organic traffic.
Conversation went from “not interested”to “how soon can we makeall of our pages faster?” Image source: onlinemarketingwithvince.com
80-90% of the end-user response time is spent on the frontend. Start there. Steve Souders - Performance Golden Rule
But before we could start, we needed: Image source: selfmadefitness.com
Common Ground • Pageload times are frontend (client-side) only • Common tool (webpagetest.org) • DSL connection speed • Doc Complete load time • Average from 9 iterations Image source: selfmadefitness.com
Our Mission Reduce page load timesfor top 50 pages of 6 marketing sites by ~50%
Phase 1: 12-15 seconds 6seconds
Original Rules of High Performance Image credit: Gregory Mancuso
Original Rules of High Performance • Minimize HTTP requests • Use CDN • Add expires header • Gzip components • Put stylesheets at top • Put scripts at bottom • Avoid CSS expressions • Make JS & CSS external • Reduce DNS lookups • Minify JS & CSS • Avoid redirects • Remove duplicate scripts • Configure Etags • Make Ajax cacheable Bonus 1: • Compress images • Lazyload images • Removed custom fonts Bonus 2: • Cookie-less domains • Reduce beacons • Optimize JS/DOM
A Typical Page • Total Bytes: 1.5M-2M+ • Images: 50-70+ (1.2M) • External CSS/JS: 30-40+ • JavaScript: 400k+ • 30x Redirects: 20+ • HTTP Requests: 120+
Performance Rule #1 General Problem: • Each http request has overhead • Connection setup/teardown • DNS lookup times Minimize HTTP requests Our Problem: • Excessive CSS files (10+) • Excessive JS files (30+) • Excessive images (50-70+) • Excessive beacons (20+)
Merge + Minify CSS/JS NOT SO EASY! • Many shared files & embedded snippets • Numerous copy-n-paste variations • document.write() statements around every corner • Expensive DOM traversals • Non-contained CSS • Global JS vars & functions everywhere Bleeding and collisions galore!
Merge + Minify CSS/JS HOW SOLVED • Cleaned & refactored all CSS/JS • Optimized handful of JS DOM Traversals • Created global-global mergeset (shared across all sites) • Created site-global mergesets (shared across all pages of same-site) A BIG WIN, BUT WITH SOME COST • CSS + JS containment extremely tedious • 2 ubermergesets == lots of unused code on most pages • Other pages aside from our top-50 included these CSS/JS files • Other sites (outside of our 6 sites) also included these CSS/JS files • all hell broke loose • Seems every commit, more things broke Took FAR longer than expected, but we got it done.
Merge + Minify CSS/JS HOW SOLVED • Cleaned & refactored all CSS/JS • Optimized JS DOM Traversals • Created global-global mergeset (shared across all sites) • Created site-global mergesets (shared across all pages of same-site) A BIG WIN, BUT WITH SOME COST • CSS + JS containment extremely tedious • 2 ubermergesets == lots of unused code on most pages • Other pages aside from our top-50 included these CSS/JS files • Other sites (outside of our 6 sites) also included these CSS/JS files • all hell broke loose • Seems every commit, more things broke Took FAR longer than expected, but we got it done. Reduced global CSS/JS requests from 30-40 down to 3-4 (10x reduction)
Spriting Images • Combines images • Reduces HTTP requests … A good thing, right?
Spriting Woes – Take 1 PROBLEM • This image is a whopping 306k as a 24-bit PNG alpha-transparent gradients HOW SOLVED • Worked with design, removed alpha-transparency • Saved as a JPG (came in < 50K) • Saved > 250k
Spriting Woes – Take 1 PROBLEM • This image is a whopping 306k as a 24-bit PNG > 1/4 Megabyte! alpha-transparent gradients HOW SOLVED • Worked with design, removed alpha-transparency • Saved as a JPG (came in < 50K) • Saved > 250k
Spriting Woes – Take 2 PROBLEM • This image is 179K as a 24-bit PNG alpha-transparent only used if no Flash installed, < 1%! HOW SOLVED • If get rid of third image, can save as JPG (< 50k) • Instead, we rewrote player code to show play button as icon (< 20k) • Saved > 150k
Spriting Woes – Take 3 Each screen: 1024x768 Dimensions: 4096x9216 Filesize: 5MB!
Spriting Woes – Take 3 Each screen: 1024x768 Dimensions: 4096x9216 Filesize: 5MB! Er… 5 megs of wrong!
Spriting Woes – Take 3 Each screen: 1024x768 Dimensions: 4096x9216 Filesize: 5MB! Sprite correctly. Sprite intelligently.
CDN (Content Delivery Network) THE GOOD THING • Wasn’t configured properly • Gzip, Expires, etc. • Assets loaded from multiple sources • Some from CDN • Others from app servers • All sites shared same CDN domain • images.smallbusiness.intuit.com • Already using Akamai PROBLEM Photo credit: Forbes.com
Angry Cookie Monster • Domain cookies are passed with every http request for that domain • CDN domain: images.smallbusiness.intuit.com • Avg cookie size: ~800b-1k • Total cookie bytes/page = ~100k+ • ~1k * ~100 reqs PROBLEM Image source: cheezburger.com
Happy Cookie Monster • Reconfigured Akamai • Load ALL static assets from CDN • Cookie-less CDN domain: • {sitename}-s{#}.intuitstatic.com HOW SOLVED Image source: birdonacake.blogspot.com
Beacons + Redirects PROBLEM • Marketing sites (we tracked everything) • Excessive beacons (20-30+) • Many 302-redirects (adds http requests) • Over the years, many beacons added • but hardly any removed Image credit: GunGodTheGreat via deviantart.com
Beacons + Redirects HOW SOLVED • Inventoried all beacons • Benchmarked all beacons • Asked marketers to review • Removed many legacy beacons • Pinged vendors for current beacons that were sub-optimal • replaced with faster versions Image source: wikipedia.org
Beacons + Redirects HOW SOLVED • Inventoried all beacons • Benchmarked all beacons • Asked marketers to review • Removed many legacy beacons • Pinged vendors for current beacons that were sub-optimal • replaced with faster versions Reduced beacon requests from 20-30 down to 8-10 Image source: wikipedia.org
Other Optimizations • Recompressed all images • low hanging fruit + a big win • Lazyloaded images below fold • another big win • Removed custom fonts • Removed duplicate code • Removed more 30x redirects • Remaining usual suspects
Eventually, we hit 6s… yay! But then the question came… Can we go faster?
6 seconds?! Very nice! • Photo credit: http://merionminor.deviantart.com/
15 seconds 6seconds Photo credit: David Endelman, NetCarShow.com
Our Biggest Bottlenecks • A/B Testing Software • Inefficient video players • Slooow global header full of surprises • … good ole JavaScript