Engineers Widely known for standards - 802.3, 802.11 World’s largest technology professional association - 400,000 engineers in 160 countries Publishes nearly a third of the world’s technical literature in EE/CS IEEE Spectrum http://spectrum.ieee.org - 100% Grails
in page traffic (Yahoo) 100ms delay = 1% drop in revenue (Amazon) 1s improvement = up to 2% conversion rate (Walmart) 57% of online consumers will abandon a site after waiting 3 seconds for a page to load. 80% of these people will not return (Akamai) 250ms delay = users will visit website less than competitors (Microsoft) Akamai http://www.akamai.com/html/about/press/releases/2010/press_061410.html Yahoo http://www.slideshare.net/stoyan/yslow-20-presentation Amazon http://sites.google.com/site/glinden/Home/StanfordDataMining.2006-11-28.ppt?attredirects=0 Walmart http://minus.com/msM8y8nyh#2e http://www.nytimes.com/2012/03/01/technology/impatient-web-users-flee-slow-loading-sites.html
Keynote A site might be fast in NJ but slow in CA …or Asia User perception trumps absolute performance metrics You don’t know if something is fast or slow unless you measure it
takes for the initial HTML page to start downloading ~0.4s out of ~2.0s Source: http://www.stevesouders.com/blog/2012/02/10/the-performance-golden-rule/
TTFB) Lots of lines: too many objects Long lines: slow downloading objects Wide chart: slow overall page load Total page weight, total page load time, response codes
Delivery Network (CDN) Add Expires or Cache-Control Header Gzip Components Put Stylesheets at Top Put Scripts at Bottom Avoid CSS Expressions Make JavaScript and CSS External Reduce DNS Lookups Minify JavaScript and CSS Avoid Redirects Remove Duplicate Scripts Configure ETags Make Ajax Cacheable Flush Buffer Early Use GET for Ajax Requests Postload Components Preload Components Reduce the Number of DOM Elements Split Components Across Domains Minimize Number of iframes Avoid 404s Reduce Cookie Size Use Cookie-Free Domains for Components Source: http://developer.yahoo.com/performance/
a page Many small objects slower than few larger objects Combine many small files into one Delay loading of content, especially hidden content More requests = more waiting Many of the “rules” are aimed at this goal
their transfer size by 366.2KiB (80% reduction). • Compressing /assets/css/site.css could save 145.8KiB (87% reduction). • Compressing /getGlobalNavData could save 98.3KiB (85% reduction). • Compressing / could save 44.8KiB (75% reduction). • Compressing /assets/js/script1.js could save 30.4KiB (75% reduction). • Compressing /.../jquery.isotope.min.js could save 10.6KiB (68% reduction). • Compressing /assets/js/libs/plugins.js could save 10.0KiB (66% reduction). • Compressing /.../modernizr-2.5.3.min.js could save 9.0KiB (60% reduction). • Compressing /assets/css/style.css could save 6.8KiB (68% reduction). • Compressing /assets/js/libs/spin.min.js could save 2.1KiB (51% reduction). • Compressing /.../jquery.lazyload.min.js could save 2.0KiB (64% reduction). • Compressing /assets/js/slimbox2.min.js could save 1.8KiB (53% reduction). • Compressing /assets/css/sb.css could save 1.2KiB (66% reduction). • Compressing /.../spec4-style-updates-1-30.css could save 970B (69% reduction). • Compressing /.../jquery.touchwipe.min.js could save 813B (52% reduction). • Compressing /.../masonry-ads-right.min.js could save 798B (58% reduction). • Compressing /assets/css/slimbox2.css could save 698B (56% reduction). Enabling gzip compression - Spectrum home page 366.2 KiB (80%) reduction (total 1.2 MB)
(primed cache) Set cache headers in application or web server Cache images forever (set “expires” header) Rename objects when updating to facilitate caching Can be more complex than it seems Tread carefully - once objects are cached in users’ browsers, you can’t easily remove them
some advanced smarts Google Closure compiler, Yahoo YUI Compressor Use minified versions of JS libraries (*.min.js) Concatenate CSS and JS files Use tools for bundling assets
page or load parts after document ready Cache AJAX responses Beware of impacts to analytics, ad serving, page history, etc. Can add significant application complexity May break searchability
concerns Many additional plugins that collaborate with grails- resources processing pipeline Does some processing at runtime instead of build time Stores generated files locally?
resources “forever” Facilitates CDN caching and browser caching No need for manual object versioning - generates file names based on SHA of file contents
declaration Eases maintenance of code - use smaller files during development without performance hit Changing one of the resources in the bundle will trigger a rebuild of the bundle
screen Don't confuse server load with front end performance - test separately Database query performance Server-side caching (cache plugin family) Server memory, thread contention, disk performance
of cache plugin family Cache-ehcache, Cache-redis, Cache-gemfire extensions Cache GSPs: @Cacheable annotation on controller methods Cache Services: @Cacheable on services Be careful to set cache key correctly for services
to automatically apply performance optimizations on-the-fly Akamai Blaze, Strangeloop, Google PageSpeed Service, many others mod_pagespeed - many experimental optimizations available https://developers.google.com/speed/pagespeed/