1 / 45

My Web Site Is So Slow…and I Don’t Know What to Do about It!

Required Slide. SESSION CODE: WEB308. 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. Agenda. Why Web Performance Is Important Web Performance - The Basics Web Performance - Best Practices

nichelle
Télécharger la présentation

My Web Site Is So Slow…and I Don’t Know What to Do about It!

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Required Slide SESSION CODE: WEB308 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

  2. 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

  3. 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

  4. 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

  5. 2. Web Performance Basics • Terminology • The 80/20 Rule • Where to look for web performance improvements

  6. 2.1 Web Performance Terminology • 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 • 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 Source: Patterns of Enterprise Application Architecture

  7. 2.2 The 80/20 Rule Only 20% of the time is spent on the initial document requested The remaining 80 % are external resources

  8. Sluggish DEMO

  9. 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

  10. 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

  11. 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

  12. 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

  13. 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

  14. WinCache for PHP DEMO

  15. 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

  16. 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

  17. Output Caching DEMO

  18. 3.2 Sending Fewer Bytes over the Network

  19. 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?

  20. 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

  21. Latency DEMO

  22. 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

  23. 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

  24. IIS7 Compression DEMO

  25. 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

  26. Minification DEMO

  27. 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

  28. Image Optimization DEMO

  29. 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

  30. Viewstate DEMO

  31. 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

  32. Avoiding Conditional GETs DEMO

  33. 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

  34. 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!

  35. 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

  36. Browser Optimizations and Putting It All Together DEMO

  37. 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…

  38. Required Slide Track PMs will supply the content for this slide, which will be inserted during the final scrub. Track Resources • 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

  39. Required Slide Speakers, please list the Breakout Sessions, Interactive Sessions, Labs and Demo Stations that are related to your session. Related Content • 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)

  40. Required Slide Track PMs will supply the content for this slide, which will be inserted during the final scrub. Track Resources • ASP.NET – http://www.asp.net/ • Silverlight – http://silverlight/ • Expression – http://www.microsoft.com/expression/ • Internet Explorer – http://www.microsoft.com/windows/internet-explorer/default.aspx

  41. Required Slide Resources 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

  42. Required Slide Complete an evaluation on CommNet and enter to win!

  43. Sign up for Tech·Ed 2011 and save $500 starting June 8 – June 31st http://northamerica.msteched.com/registration You can also register at the North America 2011 kiosk located at registrationJoin us in Atlanta next year

  44. © 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.

  45. Required Slide

More Related