280 likes | 471 Views
Performance Troubleshooting EPiServer CMS Web Sites . Steve Celius – EPiServer Geek. The Different Approaches to Performance. This presentation focuses on troubleshooting existing sites with performance problems Finding the cause and what you can do about it
E N D
Performance Troubleshooting EPiServer CMS Web Sites Steve Celius – EPiServer Geek
The Different Approaches to Performance • This presentation focuses on troubleshooting existing sites with performance problems • Finding the cause and what you can do about it • The tools you need, and the common causes • Performance is much much more • Clientside (everything not in your aspx) can be 80% of the download time (when you’re not having server trouble) • I’ll cover this the next time
The cost of fixing performance problems Thanks to Stuart Tuppert
Finding the slow parts of your site • Analyse IIS Logs • Check time_taken, # requests per hour / min (find the peaks) • Check for errors (404 / 500 status) • LogParser & Visual Log Parser • Find the most requested pages • Find errors and long running requests • Easier with Visual LogParser • Use Fiddler • Performance Monitor • Lots of information on the net • Check cpu, req/s and req. queue
The Large List Problem • Large collections of pages will kill performance • Understanding the cache is important • GetPage / GetChildren gets copies of PageData objects • Memory and CPU intense (lots of allocations and deallocations) • Dynamic Properties – are they really neccessary? • Pages with large strings (MainBody) is also a problem • News archives will slowly kill your site • Edit mode, expanding the tree loads two levels
Key Points • The devil is in the details • You don’t TRULY know until you have profiled • Things changes with content • What does not hurt you today might hurt you tomorrow • Make sure you optimize the important things
Easy Fix Fixing it! • Split up page lists with more then 250 pages into subtrees • Why 250? Practical reasons for editors • Use ”Date Containers” (/News/2007/June/My-news-article) • Moving pages using code is easy • You don’t even need to recompile (no code behind file neccessary). See ArchiveBuilder.aspx • If there are many pages, it will take some time • Cache the list • Move Dynamic Properties to the Start Page • This problem has less impact in CMS 5
FindPagesWithCriteria (FPWC) The most resource intensive operation in EPiServer Very useful, and most sites need it It will search the database, returning all pages that match the criterias ”With great power comes great responsibility”
Medium Fix Fixing it! • Use log4net to detect FPWC calls • Log all FPWC calls to one file, with page id and search ref • Limit the use of FPWC • Always think of alternative solutions • Limit the count of returned pages. The database call is not the problem, working with a large resultset is • Cache what you can cache • Enter EPiCode Cache Framework...
Medium Fix EPiCode Cache Framework for EPiServer 4 • All sites will have some complex and/or heavy queries (not only FPWC) • You should recognize them when you write the code • Prevent these queries to run too often, cache the result • Designed for low impact on existing code • Download from: • www.coderesort.com/p/epicode/wiki/CacheFramework
Easy Fix Use output caching Configurable, turn on in web.config Will cache the html output from your pages Can give you extreme performance Whole cache is invalidated on page publishing Not available for logged in users and POST ”VaryBy” – don’t vary by browser if you do not have to /3GB in boot.ini (?) It won’t fix your problems though
Beware of what you cannot see • RSS Feeds in particular • Long lists, requested often • Check the IIS log file • Use the cache framework • Bots, Crawlers and Spiders • They might fill our output cache • Will visit the ”uninteresting” pages, like the sitemap and news archive. Pages you hope no one visits
Expensive Fix Scale out • Buy more hardware • Load balance on several servers • Especially if the load is the problem • Requires cache invalidation and file sync • Session state (are you using it?) • State Server or SQL Server
Expensive Fix Migrate to EPiServer CMS 5 • You will need to rewrite some of the code • The Migration Tool helps with data migration • This is another presentation altogether • See Marek Blotny’s excellent blog post on EPiServer 5 vs. EPiServer 4.61 • CMS 5 scales much better
Important Tools Fiddler JetBrainsDotTrace WebLoad / Jmeter / WAPT Load Testing log4net Trace Diagnostics IIS Diagnostics ASP.NET Viewstate Helper Performance Viewer (Windows) LogParser & Visual Log Parser IIS Traffic Monitor
Discount 15% b4zLrhD/g23bNieHrY8oV6EIezUiCzad Special offer to all EPiServer Developer Summit 2008 attendees Extended trial period (10 30 days) Offer lasts for 30 days – from now! Read more, download evaluation and order on:http://www.jetbrains.com/profiler Eval and Coupon code:
Release Mode • Compile the site in Release Mode (in VS) • <compilation debug=”false” /> in web.config • This will give you ~10% performance gain • ASP.NET will not time out with debug = true • Just as important as the performance gain • WebResources.axd scripts can be cached • Site will use less memory
Enterprise Gotcha • Same source code, many different web sites • One place to deploy code • One config file to update • But... • Config changes will restart all sites • This is heavy lifting! • Logging with log4net is a pain • All sites uses same config, with file locking, first site to start ”wins”. Without locking, log file is a mess • One change affects all sites, needs recompiling
Enterprise Gotcha, contd. • Use deployment scripts to copy files to all sites • With delays to allow recompilation and startup peaks • This also goes for web.config
IIS Settings • Log more • Review the IIS log settings. Turn on most log settings • Remember ”time-taken” • Process Recycling – dont rely on it • It will only help on memory or resource leaks, temporarily • More often used on .NET 1.0/1.1 sites than 2.0 and up • Web Gardens • No, no and no! It can actually hurt performance
Minimize Viewstate Think Green - Save Bandwidth www.binaryfortress.com/aspnet-viewstate-helper
Links Performance Tuning and Optimization of EPiServer CMS (Fredrik Haglund) EPiServer 5 vs. EPiServer 4.61 part I - GetPage()(Marek Blotny) The challenges of a high traffic site with EPiServer(Adam Najmanowicz) Performance Pitfalls in EPiServer (Mats Hellström) The Output Cache - When and Why(Daniel van den Tempel) Caching Custom Data in EPiServer EPiServer Labs
Medium Fix Per Request Cache • Don’t do expensive operations more than once in a request • Example: • Checking if the current page is in a given structure • Refactor into utililty methods • Keep the impact on existing code low • Store in HttpContext.Current.Items • Request bound, thread safe
Tool IIS Traffic Monitor Analyses IIS log files on the fly Simple and quick to use Uses Log Parser 2.2 http://niknak.org/software/IIsTrafficMonitor
Use Fiddler to see real traffic • Server performance is important, but don’t neglect the client side performance • Check the Yahoo Performance Blog (and YSlow) • Percieved performance is also important! • Make sure the clients cache effiently