View stunning SlideShares in full-screen with the new iOS app!Introducing SlideShare for AndroidExplore all your favorite topics in the SlideShare appGet the SlideShare app to Save for Later — even offline
View stunning SlideShares in full-screen with the new Android app!View stunning SlideShares in full-screen with the new iOS app!
Web Performance OptimizationJust one second please !Maxime Lemaitre
• Introduction• Goals & Objectives• Why performance matters ?• Web application delivery chain• Some rules & Some tools• Next Steps2Agenda
• Evangelize performance and explain why it isimportant– Have a performance culture !– Have a performance plan !• Do performance tests, setup production metrics& KPIs, do monitoring and reports• And of course, increase responsiveness ofyour website !3Goals & Objectives• We won’t talk (today) about– Load Testing– How to write efficient data acces queries– Which is the fastest between C#, Java or Php ?– ….
4Web performance matters ?short history : from a tech challenge to a differentiator• First decade of the webs existence (1993 – 2003).– Performance focus on :• Optimize website code (simple scripts)• Improve data access (use indexes, fewer queries, …)• Reduce packet loss and retransmission• Pushing hardware limitations (CPU, Memory, IO…) Not focused on browser display speed• An emerging industry (2004-2009)– Steve Souders (Yahoo), pioneer in « web performance optimization »• 85% of the time that it takes to download and view a website is controlled by the front-end structure• 10 predictions (fast by default, Visibility into the browser, monitoring, mobile, … => a differientator)– Velocity 2009 Conference is a key event in web performance• Many case studies from Microsoft, AOL, Amazon, ShopZilla , …• Not only for techs but also other parts of the organization (management, marketing, sales, …)• Last years (2010 – Now)– Google : « we’ve decided to take site speed into account in our search rankings »– For an ecommerce website, it’s been proven that speed = money– Trend : make the web faster because web pages are bigger and more complex than ever
Bing : page that was 2 seconds slower resulted in a 4.3% drop in revenue/userYahoo : 400 milliseconds slowdown resulted in a 5-9% drop in full-page trafficGoogle : 400 millisecond delay caused a 0.59% drop in searches/userEven after the delay was removed, these users still had -0.21% fewer searches slower user experience affects long term behaviorAOL : page views drop off as page load times increaseMozilla : Shaving 2.2 seconds off their home page increased downloads by 15.4%ShopZilla : 5 second speed up• 25% increase in page views• 7-12% increase in revenue• 50% reduction in hardwareAmazon : Every 100ms delay costs 1% of sales5Web performance matters ?case studies in web industry
6Why performance matters ?for customers (source : Velocity Conf, Aberdeen, Gomez, Akamai)Is Web Performance important for your company ?• Are you in a competitive industry ?• Do you sell something ?• Does another website sell basically the « samething »• Is is important to attract new users ?• Is SEO important for you ?• Does you marketing team wants to showeverything on your homepage ?• ….
• Better user experience– Customers will be happier and will tell others how good we are– Keep them more focused on our content, rather than waiting for scripts/images• Improve SEO– One of the 200 signals used in Google Rankings• Mobile performance : a new challenge– Tablets/Smartphones are slower than desktops– Much more limits and latency• Improve conversion rate– every second win, will boost customer confidence and trust in your site• Reduce costs– Bandwidth– Less Hardware/Servers• Better Scalability7Why performance matters ?for techs & devs
• Final page speed is a depending on– User computer and browser– User current activity– User network connection/ISP– Internet Backbone– Web Hosting location– HTML (JS, CSS, Images, ..)– Third-Party libraries / Ads / Analytics– CDN– Firewall/Load balancer– Web Page / server code– Frontend servers / Web Farms– API/WebServices Calls– Middle Tier / Backend servers– Database– …8Web Application Delivery Chainperformance at the bottom lineDo not trust that every user have aCore i5 CPU with 8 Go Ram onWindows 7 on a 100 Mbits/sconnection ! It’s false !Try to test performance on slowestcomputers and slowest bandwidth
80-90% of the end-user response time is spent on the frontend !9Web Performancewhere to start ?
“We should forget about small efficiencies, sayabout 97% of the time: premature optimization isthe root of all evil”Donald KnuthNever automatically apply tips, bestpractices & improvements withoutchecking before/after the changes.=> Profiling and Micro-Benchmark10Important Notebefore going deeper
• Yslow & PageSpeed– Proven front-end best practices & recommandations– Very popular & easy to install (browser extension or online service)– Current : Yslow (23 best practices) & PageSpeed (31 rules)• But …– does not look at our Infrastructure, Application Performance, CDN, DB Queries,datacenter distribution, load balancing, …– does not include the actual speed of the tested page !– Lower scores/grades can load faster than Higher scores11Web Performance auditorsGoogle PageSpeed & YSlow
14Less than 6 connections per hostnameLimit number of requests
Web images take up the majority of the download time in most web pages• Choose an appropriate file format (JPG, PNG, GIF)– For JPG, use progressive image (demo)• Optimize image size– Crop whitespace, Remove useless data (color palette, EXIFF, ..)– Apply a Lossless compressor (OptiPNG or PNGOUT)• Try to apply width and height for each <img> tag– Avoid unnecessary repaints and reflows during rendering– But do not use it to scale images : server already scaled images• Use Sprites (see )– reduced the number of HTTP requests and avoided any potential delay• Use Data-URI– inline the content of the URI you would normally point to16Images OptimizationsWeb images take up the majority of the download time in most web pages
• Styles are downloaded and applied when renderingBrowsers block rendering a web page until all external stylesheets have beendownloaded- Put styles in head allow the browser to progressively render the page- Put styles in body can cause repaints & reflows (demo)• Scripts are downloaded, parsed and executedThe page has to wait for the script blocks to be fully downloaded, parsed andexecuted before being able to parse and render any following HTML– Block the rendering of any following HTML– Block the downloading of resources referenced in the document after the script18Quick Focus : Styles & ScriptsWhy is it so important to optimize styles & scripts?
What is the page speed (with/without Cache) for thisridicoulous page ?19ScriptsStop paying the Script tax
• First View• Repeat View• Repeat View (on my laptop in power saving mode)20ScriptsStop paying the Script tax²Even from cache (nodownload), it takes afew ms to parse &exec Scripts.Not so fast …
22How to mesure/improve performance ?hopefully there are many tools !• Sql Profiler• Graphite• Web DeveloppersTools• WebPageTest.org• PhantomJS• Selenium Web Driver• Har Viewer• Google Page Speed• Yslow• dotTrace• Pingdom tools• Fiddler• jsPerf• MVC MiniProfiler• dynaTrace• Google Analytics• IIS & Apache Logs• Performance coutners• Visual Studio WebPerf• Gtmetrix• Micro Benchmark• Google Site Speed• Centreon• New Relic• Node.js• DB Provider ClientStatistics• SpeedTrace• Headless Browsers• Boomerang.js• MVC Bundles• Optipng• Glimpse• SpriteMe• Firebug• Your own tool here!
• Learn how to improve Web performance• Investigate available performance tools– Dev customs tools if necessary• Automate performance testing• …It’s only the beginning !PS : And of course, check Performance of your Web Site 23Next Steps