Thomas Deml - Improve Slow Websites
Upcoming SlideShare
Loading in...5
×
 

Thomas Deml - Improve Slow Websites

on

  • 2,159 views

Best Practices for websites.

Best Practices for websites.

Statistics

Views

Total Views
2,159
Views on SlideShare
2,158
Embed Views
1

Actions

Likes
0
Downloads
6
Comments
0

1 Embed 1

http://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • * If you are in China then you can get JavaScript files from a server located in China* If you visit a website that retrieves JavaScript from the CDN in one domain, you do not need to re-download the same JavaScript files when you visit a second website that also uses the same CDN.

Thomas Deml - Improve Slow Websites Thomas Deml - Improve Slow Websites Presentation Transcript

  • Required Slide
  • My Web Site Is So Slow…and I Don’t Know What to Do about It!
    Thomas Deml
    Principal Program Manager
    Web Platform and Tools
    Microsoft Corporation
    Required Slide
    SESSION CODE: WEB308
  • Agenda
    Why Web Performance Is Important
    Web Performance - The Basics
    Web Performance - Best Practices
    Web Performance - Tools and Resources
    Not in scope for this talk:
    Database Tuning
    Distributed Caching / AppFabric / Velocity
    Ajax and Web Services
  • 1.1 Why Care About Performance?
    Customers will abandon your site
    4 second abandonment threshold
    75% of the 1,058 people asked would not return to websites that took longer than four seconds to load.
    Source: Keep Page Download Speed Times Fast (How Fast? 4 Seconds!) | Hobo
    http://www.websiteoptimization.com/speed/tweak/psychology-web-performance/
    It will be harder to find you on the Net
    Search Crawlers will spend less time on your site
    Site Performance part of Google search rankings
  • 1.2 Impact of Speed-ups and Slow-downs
    Slow Downs:
    Bing
    A page that was 2 seconds slower resulted in a 4.3% drop in revenue/user.
    Google
    A 400 millisecond delay caused a 0.59% drop in searches/user.
    Yahoo!
    A 400 milliseconds slowdown resulted in a 5-9% drop in full-page traffic.
    Speed-Ups:
    Shopzilla
    Speeding up their site by 5 seconds increased the conversion rate 7-12%, doubled the number of sessions from search engine marketing, and cut the number of required servers in half.
    Mozilla
    Shaving 2.2 seconds off their landing pages increased download conversions by 15.4%, which they estimate will result in 60 million more Firefox downloads per year.
    Netflix
    Adopting a single optimization, gzip compression, resulted in a 13-25% speedup and cut their outbound network traffic by 50%.
    http://www.stevesouders.com/blog/2010/05/07/wpo-web-performance-optimization/Source: O'Reilly Velocity Conference, May 2009
  • 2. Web Performance Basics
    Terminology
    The 80/20 Rule
    Where to look for web performance improvements
  • 2.1 Web Performance Terminology
    Load Sensitivity
    How response time varies with the load
    Efficiency
    Performance divided by resources, e.g. 30 rps/2CPUs = 15 rps/CPU
    Capacity
    Maximum acceptable throughput
    Scalability
    How adding hardware affects performance
    Vertical Scalability (scaling up): Adding memory and/or CPUs
    Horizontal Scalability (scaling out): Adding more servers
    Response Time
    Time it takes to process a request
    Responsiveness
    Acknowledgement of the request opposed to completion of the request
    Latency
    Minimum time required to get any form of response
    Throughput
    How much can be done within a given amount of time
    Load
    Stress the system is under
    Source: Patterns of Enterprise Application Architecture
  • 2.2 The 80/20 Rule
    Only 20% of the time is spent on the initial document requested
    The remaining 80 % are external resources
  • Sluggish
    DEMO
  • Areas for Speeding Up Your Web Site
    Bandwidth
    Latency
    Server Execution Time
    Network
    Number of objects transferred
    Amount of data transferred
    Browser
    Rendering and Layout
  • 3. Web Site Performance In Detail
    Areas for Improving Web Site Performance
    Speed up Execution Time on the Server
    Do more, faster and with fewer resources
    The Network – send fewer bytes
    Amount of data transferred
    Number of objects transferred
    Frontend Optimizations
    Optimize download of page resources
    Optimize rendering and layout of pages
    Other Issues
    The first impression counts!
    This is where server admins and devs usually look
  • 3.1 Execution Time Tuning Side Note
    Goal is to max out the CPU
    If CPU can’t be maxed it might be that
    The Network is maxed out
    The Disk can’t keep up
    Some other lock (e.g. database) blocks execution
    Only if CPU is maxed it makes sense to look how the CPU load can be reduced
  • 3.1.1 Speeding Up IIS Execution TimeBest Practices
    Run Windows Server 2008 on new hardware
    It's optimized for new CPU architectures
    Existing default document on top of list
    Use IIS7 Output Caching for semi-dynamic content
    Turn off features you don't need
    Authentication and SSL only if necessary
    Auth introduces round-trip to backend (AD)
    Encryption impacts processing time and caching
    Request tracing
    But use it if for performance troubleshooting
  • 3.1.3 Speeding Up PHP Execution TimeBest Practices
    Use FastCGI
    Enable WinCache
    Set FastCGIMaxInstances to 0 (FastCGI 1.5)
    enables auto-tuning of FastCGI processes based on system load
  • WinCache for PHP
    DEMO
  • 3.1.2 Speeding Up ASP.NET Execution TimeBest Practices
    Turn off ASP.NET compilation/debug
    No compiler optimizations, increased memory footprint, etc.
    Use <deployment retail="true" /> to enforce across machine
    Read through ASP.NET Performance Coding Best Practices in the Prescriptive Architecture Guides
    Under Memory Pressure?
    Read about the Large Object Heap
    The First Impression Counts!
    Use ASPNET_COMPILER to optimize for the first impression
    Do you really need IIS idle timeout and proactive recycling?
    ASP.NET Thread Pool Settings should be optimized for high throughput sites
    maxConcurrentRequestsPerCPU defaults to 12
  • IIS/ASP.NET Caching Primer
    IIS/ASP.NET Output Cache allows caching across all tiers
    On browsers and proxies via Cache-Control and Expires Headers
    Programmatically in ASP.NET
    SetCacheability(), SetETag(), SetExpires(), SetLastModified(), SetMaxAge(), …
    Declarative in ASP.NET:
    <%@ OutputCache Duration="1000" Location="Client" VaryByParam="none" %>
    Via configuration settings in IIS
    On the Server
    IIS7 Kernel Mode Caching
    Enabled for static files
    Can cache all files with a particular extension: .aspx, .yourextension, …
    Can cache a particular file: e.g. default.aspx
    ASP.Net Application Cache
    Control when items are cached programmatically
    Mix cached and non-cached content
  • Output Caching
    DEMO
  • 3.2 Sending Fewer Bytes over the Network
  • 3.2.1 A Word about Latency
    You don’t see the performance issues your client sees
    As the Developer
    Your cache is primed
    You sit close to the server that is running your app
    You have lots of bandwidth
    You use the latest browser versions and the latest hardware
    Approx. Latencies
    Asia->US
    ~250ms latency/TCP packet
    US Eastcoast US Westcoast
    ~100ms latency/TCP Packet
    Did we talk about latency on cell phones yet?
  • Browser Cache
    Don't assume it's primed
    Browser Temporary Files Cache Size is small by default
    Internet Explorer 8: 50MB
    Firefox 3.6: 50MB
    Yahoo Study (TBD: hyperlink)
    65-70% of customers visit Yahoo site with unprimed cache
  • Latency
    DEMO
  • 3.2.2 Use Content Distribution Networks
    Content Delivery Networks improve your website performance because:
    Files get cached across the world
    Files get cached across domains
    Files get compressed
    Files get cached on the browser with a far future expiration header
    Example:
    The free Microsoft Ajax CDN contains
    Microsoft Ajax Library
    jQuery
    jQuery Validation Library
    ASP.NET Framework JavaScript
  • 3.2.3 Use IIS Compression
    Static Compression (on by default)
    IIS caches compressed resources
    Compression is done on second request
    Dynamic Compression (not installed by default)
    Compression is done on every response
    ~ 5-10% higher CPU load
    IIS7 Compression
    Supports compression levels 1-10
    Is based on MIME Maps
    Supports high and low watermarking
    Can be combined with output caching
    Don't rely on compression alone
    10-15% of requests don't support compression
  • IIS7 Compression
    DEMO
  • 3.2.4 Minify CSS and Javascript
    Crunch Javascript and CSS with AjaxMin
    Comments, white spaces
    Mungesfunction and variable names (converted into smaller strings)
    Other Javascript Optimizations
    Code Splitting
    The Idea behind Microsoft Doloto
    Start with a small piece of code on the client
    Download required code on demand (pull)
    Leads to
    Better application responsiveness
    Faster startup times
    Rarely executed code is rarely downloaded
  • Minification
    DEMO
  • 3.2.5 Optimize ImagesBest Practices
    Do not scale images in HTML!!
    Formats:
    Use jpg for photos
    Use pngfor graphics
    Remove metadata
    CSS Sprites
    Allows combination of multiple images into one
    Issues:
    SEO: can't use the ALT Tag
    Changing a single sprite will force download of full image
    Additional HTML and CSS markup
    Try Image Crushing Tools
  • Image Optimization
    DEMO
  • 3.2.6 ASP.NET Viewstate
    State stored across round trips
    Disable View State whenever possible
    Set EnableViewState="false"
    ViewStateversus ControlState
    Never need ViewState when displaying data
  • Viewstate
    DEMO
  • 3.2.7 Help the Browser Cache Content
    Conditional GETs introduce network round trips
    Use the Cache-Control Header
    Use Versioning for cached content that changes
    Request:
    GET /Logo.png HTTP/1.1
    If-Modified-Since: Mon, 10 Nov 2008 21:53:27 GMT
    1st Response:
    HTTP/1.1 200 OK
    Last-Modified: Mon, 10 Nov 2008 21:59:09 GMT
    <content>…
    2nd Response:
    HTTP/1.1 304 Not Modified
    Last-Modified: Mon, 2 Nov 2008 20:59:09 GMT
  • Avoiding Conditional GETs
    DEMO
  • 3.2.8 Additional Best Practices to Reduce Network Traffic
    Avoid Redirects
    Additional network round-trips
    Use 301's instead of 302's
    Combine Javascript and Cascading Style Sheets (CSS) as much as possible
    Avoids additional network round-trips
    Strip unnecessary response headers
    X-Powered-By
    ETag
    Reduce DNS Lookups
    Use authentication and SSL only for content that really needs protection
    Images?
    Script?
    Are you dealing with bandwidth hogs?
    Try the IIS Bitrate Throttling Module
  • 3.2.8 More Best Practices to Reduce Network Traffic
    Look at your Cookies
    Do you need all of them?
    Use dedicated domain name for static content, e.g. static.contoso.com
    Can you use the Cookie path feature?
    Keep ASP.NET Master Pages lean
    They are part of every ASP.NET page response
    i.e. do not include Javascript etc.
    Careful with the ETag on IIS 6.0
    Use lowercase to reference your resources
    Browser Cache is case-sensitive!
  • 3.3 Optimize the Frontend
    Optimize Downloads
    Strive for parallel downloads
    Best Practices:
    Script should go to the bottom of the page
    If script tag is encountered, no new downloads are started
    I.e. rendering of page cannot start
    Stylesheets should go at the beginning of the <head> section
    CSS needed for rendering and need to be downloaded as early as possible
    Avoid CSS Expressions
  • Browser Optimizations and Putting It All Together
    DEMO
  • Summary
    Performance Matters!
    Speed == Eyeballs
    You can improve performance on three fronts:
    On the Server by doing things faster and more efficient
    On the Network by sending fewer bytes and reducing the round-trips
    On the Browser by optimizing the download and rendering of the page and its resources
    And: There is lot’s of great tools and information out there…
  • Track Resources
    Required Slide
    Track PMs will supply the content for this slide, which will be inserted during the final scrub.
    Steve SoudersBlog (http://www.stevesouders.com) and books
    Yahoo’s Performance Web-Site (http://developer.yahoo.com/performance/)
    Links to everything discussed today will be on http://blogs.iis.net/thomad tonight. Promise!
    Books
  • Resources
    Required Slide
    Learning
    Sessions On-Demand & Community
    Microsoft Certification & Training Resources
    www.microsoft.com/teched
    www.microsoft.com/learning
    Resources for IT Professionals
    Resources for Developers
    http://microsoft.com/technet
    http://microsoft.com/msdn
  • Related Content
    Required Slide
    Speakers, please list the Breakout Sessions, Interactive Sessions, Labs and Demo Stations that are related to your session.
    WEB305: Build Web-Sites Faster With Visual Studio 2010
    WEB303-INT: Developing, Extending, and Deploying Web Applications on Internet Information Services (IIS)
    WSV02-HOL: Deploying and Managing Microsoft ASP.NET Using Internet Information Services (IIS) 7.5 on Server Core (V3.0)
    TLC-58: Windows Server 2008 R2 Internet Information Services (IIS)
  • Required Slide
    Complete an evaluation on CommNet and enter to win!
  • © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.
    The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.